31 lines
2.2 KiB
C++
31 lines
2.2 KiB
C++
// #150: native 70334 slash commands whose packets need a Tortoise form (found by the LOCAL slash sweep 2026-11-27).
|
|
#include "world_translation.hpp"
|
|
#include <algorithm>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
int main(){
|
|
// Value-initialize through the default constructor: GCC 16 misdiagnoses aggregate cleanup at -O2.
|
|
auto world = NativeWorldTranslation();world.selected.guid=4520;world.selected.name="Fixture";world.realm=70;
|
|
try{world.gameplay(0x3e018a,{});return 1;}catch(const Error&){} // not in world yet
|
|
world.self_created=true;
|
|
auto pvp=world.gameplay(0x3e018a,{});
|
|
if(pvp.opcode!=0x253 || !pvp.body.empty())return 2; // /pvp
|
|
try{world.gameplay(0x3e018a,Bytes{1});return 3;}catch(const Error&){} // TogglePvP has no body
|
|
// #151 /h hardcore chat: Tortoise SMSG_MESSAGECHAT 0x5E reaches the OctoHardcore add-on as "<name>\t<tag>\t<text>".
|
|
auto hc=[](uint64_t sender,std::string text){Bytes b{0x5e};le(b,0,4);le(b,sender,8);le(b,text.size()+1,4);
|
|
b.insert(b.end(),text.begin(),text.end());b.push_back(0);b.push_back(0);return b;};
|
|
{auto out=world.translate({0x96,hc(4520,"still alive")},0x46010046,0,nullptr);
|
|
const std::string want=std::string("Fixture\t0\tstill alive");
|
|
if(std::search(out.begin(),out.end(),want.begin(),want.end())==out.end())return 4;
|
|
const std::string prefix(HardcorePrefix);
|
|
if(std::search(out.begin(),out.end(),prefix.begin(),prefix.end())==out.end())return 5;}
|
|
{auto before=world.requests.size();world.translate({0x96,hc(777,"hello")},0x46010046,0,nullptr);
|
|
if(world.requests.size()!=before+1 || world.requests.back().opcode!=0x50)return 6;} // unknown sender: name query first
|
|
{auto line=turtle_hardcore_message(hc(777,"hi"));if(line.sender!=777 || line.text!="hi" || octo_hardcore_line(line,"Bob")!="Bob\t0\thi")return 7;}
|
|
{Bytes want;le(want,0x5e,4);le(want,0,4);for(char c:std::string("go"))want.push_back(uint8_t(c));want.push_back(0);
|
|
if(turtle_hardcore_request("go",0)!=want)return 8;}
|
|
try{turtle_hardcore_request("",0);return 9;}catch(const Error&){}
|
|
std::cout<<"native slash command translations PASS\n";return EXIT_SUCCESS;
|
|
}
|