883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
80 lines
5.1 KiB
C++
80 lines
5.1 KiB
C++
#include "gateway/world.hpp"
|
|
#include "gateway/roster_translation.hpp"
|
|
#include <array>
|
|
#include <bit>
|
|
#include <iostream>
|
|
#include <limits>
|
|
#include <stdexcept>
|
|
using namespace gateway;
|
|
namespace {
|
|
void check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
|
|
template<class F>void rejects(F action){try{action();}catch(const Error&){return;}throw std::runtime_error("unsupported extension context accepted");}
|
|
void number(Bytes& b,float f){le(b,std::bit_cast<uint32_t>(f),4);}
|
|
Bytes packet(uint64_t flags,bool fall=false,uint64_t owner=4509,float pitch=.25f){
|
|
auto b=pack_guid(forever_player_guid(owner,70));le(b,flags,8);le(b,1234,4);
|
|
for(float f:{1.f,2.f,3.f,.5f,pitch,1.25f})number(b,f);
|
|
le(b,0,4);le(b,17,4);number(b,1);le(b,fall?0x20:0,1);le(b,0,1);
|
|
if(fall){le(b,50,4);number(b,4);le(b,0x80,1);for(float f:{0.f,1.f,3.f})number(b,f);}
|
|
return b;
|
|
}
|
|
// Source Object.cpp::MovementInfo::Read layout, independently encoded.
|
|
Bytes source(uint32_t flags,bool fall){
|
|
Bytes b;le(b,flags,4);le(b,1234,4);for(float f:{1.f,2.f,3.f,.5f})number(b,f);
|
|
if(flags&0x200000)number(b,.25f);
|
|
le(b,fall?50:0,4);
|
|
if(flags&0x2000)for(float f:{4.f,1.f,0.f,3.f})number(b,f);
|
|
if(flags&0x4000000)number(b,1.25f);
|
|
return b;
|
|
}
|
|
struct Context {uint64_t native;uint32_t legacy;bool fall=false;};
|
|
}
|
|
int main(){try{
|
|
Character character{};character.guid=4509;const std::vector<Character> owned{character};
|
|
// Exact enum/introspection-only family; no wildcard high-bit allowance.
|
|
constexpr std::array<unsigned,8> bits{43,47,48,50,55,56,57,58};uint64_t all=0;
|
|
for(auto bit:bits)all|=uint64_t(1)<<bit;
|
|
constexpr std::array<std::pair<uint64_t,uint32_t>,4> modes{{{0x400,0x1000},{0x4000000,0x10000000},{0x8000000,0x20000000},{0x800000000000000,0x40000000}}};
|
|
std::vector<Context> contexts;
|
|
for(unsigned combination=0;combination<16;++combination){
|
|
uint64_t native=0;uint32_t legacy=0;
|
|
for(unsigned i=0;i<4;++i)if(combination&(1u<<i)){native|=modes[i].first;legacy|=modes[i].second;}
|
|
const uint32_t direction=(combination&1)?0x10:4;
|
|
contexts.push_back({native,legacy});contexts.push_back({native|direction,legacy|direction});
|
|
const uint32_t pitch=(combination&1)?0x10:0x40;
|
|
contexts.push_back({native|pitch,legacy|pitch});
|
|
contexts.push_back({native|0x100000,legacy|0x200000});
|
|
contexts.push_back({native|0x100000|direction,legacy|0x200000|direction});
|
|
if(!(combination&1)){
|
|
contexts.push_back({native|0x300004,legacy|0x200004});contexts.push_back({native|0x500004,legacy|0x200004});
|
|
contexts.push_back({native|0x2000004,legacy|0x4000004});
|
|
contexts.push_back({native|0x804,legacy|0x2004,true});contexts.push_back({native|0x1804,legacy|0x6004,true});
|
|
}
|
|
}
|
|
size_t checks=0;
|
|
for(unsigned combination=0;combination<256;++combination){
|
|
uint64_t extensions=0;for(unsigned i=0;i<8;++i)if(combination&(1u<<i))extensions|=uint64_t(1)<<bits[i];
|
|
for(auto context:contexts){
|
|
auto input=packet(context.native|extensions,context.fall);auto move=forever_basic_movement(input,70,owned);
|
|
check(move.native_opaque_extensions==extensions,"opaque native metadata was lost or fabricated");
|
|
check(turtle_basic_movement(move)==source(context.legacy,context.fall),"source movement wire/physics flags changed");++checks;
|
|
}
|
|
}
|
|
// Exact reported metadata: SWIMMING plus UNK47,57bytes, no options.
|
|
auto reported=packet(0x0000800000100000ULL);check(reported.size()==57,"reported shape differs");
|
|
auto actual=forever_basic_movement(reported,70,owned);
|
|
check(actual.native_opaque_extensions==(1ULL<<47),"UNK47 not retained");
|
|
check(turtle_basic_movement(actual)==source(0x200000,false),"reported swim projection differs");
|
|
for(uint64_t forbidden:{0x200ULL,0x800000ULL,0x1000000ULL,0x10000000ULL,0x20000000ULL,0x40000000ULL,
|
|
1ULL<<45,1ULL<<46,1ULL<<60,1ULL<<61,1ULL<<62,1ULL<<63})
|
|
rejects([&]{forever_basic_movement(packet(all|0x100000|forbidden),70,owned);});
|
|
for(uint64_t bad:{0xc0ULL,0x440ULL,0x700000ULL,0x200000ULL})rejects([&]{forever_basic_movement(packet(all|bad),70,owned);});
|
|
rejects([&]{forever_basic_movement(packet(all|0x100000,false,4510),70,owned);});
|
|
rejects([&]{forever_basic_movement(packet(all|0x100000,false,4509,std::numeric_limits<float>::infinity()),70,owned);});
|
|
for(size_t size=0;size<reported.size();++size)rejects([&]{forever_basic_movement(std::span(reported).first(size),70,owned);});
|
|
for(uint8_t option:{uint8_t(0x40),uint8_t(0x10),uint8_t(0x08),uint8_t(0x04),uint8_t(0x02),uint8_t(0x01)}){
|
|
auto bad=packet(all|0x100000);bad[bad.size()-2]=option;rejects([&]{forever_basic_movement(bad,70,owned);});
|
|
}
|
|
auto future=reported;future.back()=0x80;rejects([&]{forever_basic_movement(future,70,owned);});
|
|
std::cout<<"Opaque movement extension family PASS: "<<checks<<" complete source-wire cases, all256 masks across "<<contexts.size()<<" known contexts; native opaque metadata retained; unsupported capabilities/options still rejected\n";return 0;
|
|
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}
|