883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
80 lines
5.0 KiB
C++
80 lines
5.0 KiB
C++
#include "gateway/world.hpp"
|
|
#include "gateway/roster_translation.hpp"
|
|
#include <bit>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <limits>
|
|
#include <stdexcept>
|
|
#include <string_view>
|
|
|
|
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 movement accepted");}
|
|
// This synthetic packet reproduces the captured flags/57-byte shape, not the
|
|
// private original payload. The independent legacy layout follows source
|
|
// MovementInfo::Read rather than reusing a gateway movement encoder.
|
|
Bytes native(uint64_t flags,uint64_t identity=4509,float pitch=.25f){
|
|
auto b=pack_guid(forever_player_guid(identity,70));le(b,flags,8);le(b,1234,4);
|
|
for(float f:{1.f,2.f,3.f,.5f,pitch,0.f})le(b,std::bit_cast<uint32_t>(f),4);
|
|
le(b,0,4);le(b,17,4);le(b,std::bit_cast<uint32_t>(1.f),4);le(b,0,2);return b;
|
|
}
|
|
Bytes source_wire(uint32_t flags,float pitch=.25f){
|
|
Bytes b;le(b,flags,4);le(b,1234,4);
|
|
for(float f:{1.f,2.f,3.f,.5f})le(b,std::bit_cast<uint32_t>(f),4);
|
|
if(flags&0x200000)le(b,std::bit_cast<uint32_t>(pitch),4);
|
|
le(b,0,4);return b;
|
|
}
|
|
void source_read(std::span<const uint8_t> payload,uint32_t expected,float pitch){
|
|
Reader r(payload);auto flags=r.le(4);check(flags==expected,"legacy flags collide or disappear");
|
|
check(r.le(4)==1234,"timestamp changed");
|
|
for(float f:{1.f,2.f,3.f,.5f})check(r.f32()==f,"world XYZ/orientation changed");
|
|
if(flags&0x200000)check(r.f32()==pitch,"swim pitch changed");
|
|
check(r.le(4)==0,"unexpected fallTime");r.end();
|
|
}
|
|
}
|
|
int main(int argc,char** argv){try{
|
|
Character c{};c.guid=4509;std::vector<Character> owned{c};
|
|
const auto captured_shape=native(0x300004);check(captured_shape.size()==57,"captured metadata fixture shape differs");
|
|
if(argc==2 && std::string_view(argv[1])=="--expect-old-rejection"){
|
|
try{forever_basic_movement(captured_shape,70,owned);}catch(const Error& e){
|
|
check(std::string_view(e.what())=="movement outside basic walk/fall/swim subset","unexpected baseline rejection");
|
|
std::cout<<"Frozen baseline rejects synthetic captured57-byte flags0x300004 at shared basic movement flag gate\n";return 0;
|
|
}
|
|
throw std::runtime_error("frozen baseline unexpectedly accepted fixture");
|
|
}
|
|
for(uint64_t vertical:{0x200000ULL,0x400000ULL}){
|
|
for(uint64_t direction:{0ULL,1ULL,2ULL,4ULL,8ULL,0x10ULL,0x20ULL}){
|
|
const auto packet=native(0x100000|vertical|direction);
|
|
auto move=forever_basic_movement(packet,70,owned);auto legacy=turtle_basic_movement(move);
|
|
check(move.swimming && move.swim_pitch==.25f,"swimming state/pitch lost");
|
|
check(legacy==source_wire(0x200000|uint32_t(direction)),"complete vanilla packet differs");
|
|
source_read(legacy,0x200000|uint32_t(direction),.25f);
|
|
}
|
|
}
|
|
// Known horizontal/grounded modes keep their exact previous wire bytes.
|
|
for(uint64_t flags:{0ULL,1ULL,4ULL,0x100004ULL}){
|
|
auto legacy=turtle_basic_movement(forever_basic_movement(native(flags),70,owned));
|
|
auto expected=uint32_t(flags&0x13f)|((flags&0x100000)?0x200000:0);
|
|
check(legacy==source_wire(expected),"existing movement projection changed");source_read(legacy,expected,.25f);
|
|
}
|
|
auto waterwalk=turtle_basic_movement(forever_basic_movement(native(0x4300004),70,owned));
|
|
check(waterwalk==source_wire(0x10200004),"reviewed waterwalking mode lost");
|
|
for(uint64_t flags:{0x200004ULL,0x400004ULL,0x700004ULL,0xb00004ULL,0x1300004ULL,
|
|
0x300204ULL,0x300404ULL,0x300804ULL,0x3000040000000004ULL,
|
|
0x20300004ULL,0x2300004ULL,0x30000cULL})
|
|
rejects([&]{forever_basic_movement(native(flags),70,owned);});
|
|
rejects([&]{forever_basic_movement(native(0x300004,4510),70,owned);});
|
|
rejects([&]{forever_basic_movement(native(0x300004,4509,std::numeric_limits<float>::infinity()),70,owned);});
|
|
for(size_t n=0;n<captured_shape.size();++n)rejects([&]{forever_basic_movement(std::span(captured_shape).first(n),70,owned);});
|
|
auto nan_position=captured_shape;size_t offset=pack_guid(forever_player_guid(4509,70)).size()+8+4;
|
|
auto nan=std::bit_cast<uint32_t>(std::numeric_limits<float>::quiet_NaN());
|
|
for(unsigned i=0;i<4;++i)nan_position[offset+i]=uint8_t(nan>>(8*i));
|
|
rejects([&]{forever_basic_movement(nan_position,70,owned);});
|
|
// Transport/unknown options still fail rather than being silently omitted.
|
|
auto optional=captured_shape;optional[optional.size()-2]=0x40;rejects([&]{forever_basic_movement(optional,70,owned);});
|
|
auto trailing=captured_shape;trailing.push_back(0);rejects([&]{forever_basic_movement(trailing,70,owned);});
|
|
std::cout<<"Swimming-only vertical input preserves complete source XYZ/pitch/wire; ownership, flags, options, finite values and truncation guards PASS\n";
|
|
return 0;
|
|
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}
|