883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
32 lines
2.8 KiB
C++
32 lines
2.8 KiB
C++
#include "inventory_translation.hpp"
|
|
#include "gateway/turtle_entity_profile.hpp"
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
namespace F=gateway::turtle_entity_fields;
|
|
static void check(bool value){if(!value)throw Error("owned inventory destroy relationship assertion");}
|
|
static Bytes request(uint32_t count,uint8_t bag=255,uint8_t slot=35){Bytes b;le(b,count,4);le(b,bag,1);le(b,slot,1);return b;}
|
|
int main(){try{
|
|
NativeInventoryTranslation state;
|
|
constexpr uint64_t self=42,item=(uint64_t(0x4000)<<48)|75,bag=(uint64_t(0x4000)<<48)|76;
|
|
LegacyObjectUpdate owned;owned.type=1;owned.guid=item;owned.fields={{3,2592},{6,uint32_t(self)},{8,uint32_t(self)},{14,2}};
|
|
state.items[item]=owned;state.player_fields[F::PLAYER_FIELD_PACK_SLOT_1]=uint32_t(item);state.player_fields[F::PLAYER_FIELD_PACK_SLOT_1+1]=uint32_t(item>>32);
|
|
const auto before=state.items.at(item).fields;
|
|
auto result=state.gameplay(0x3e016c,request(2));check(result.opcode==0x111 && result.body==Bytes({255,23,2,0,0,0}));
|
|
check(state.gameplay(0x3e016c,request(0)).body==Bytes({255,23,0,0,0,0}));
|
|
check(state.gameplay(0x3e016c,request(1)).body==Bytes({255,23,1,0,0,0}));
|
|
check(state.items.at(item).fields==before && state.items.size()==1 && state.requests.empty());
|
|
auto rejected=[&](const Bytes& body){bool held=false;try{state.gameplay(0x3e016c,body);}catch(const Error&){held=true;}check(held);};
|
|
rejected(request(3));rejected(request(256));rejected(request(1,255,36));rejected(request(1,29,0));
|
|
for(size_t n=0;n<6;++n){auto body=request(1);body.resize(n);rejected(body);}
|
|
auto extra=request(1);extra.push_back(0);rejected(extra);
|
|
state.items[item].fields[14]=0;rejected(request(0));state.items[item].fields[14]=2;
|
|
LegacyObjectUpdate container;container.type=2;container.guid=bag;container.fields={{3,4240},{6,uint32_t(self)},{8,uint32_t(self)},{14,1},{F::CONTAINER_FIELD_NUM_SLOTS,2},{F::CONTAINER_FIELD_SLOT_1,uint32_t(item)},{F::CONTAINER_FIELD_SLOT_1+1,uint32_t(item>>32)}};
|
|
state.items[bag]=container;state.player_fields[F::PLAYER_FIELD_INV_SLOT_HEAD+2*19]=uint32_t(bag);state.player_fields[F::PLAYER_FIELD_INV_SLOT_HEAD+2*19+1]=uint32_t(bag>>32);
|
|
state.player_fields.erase(F::PLAYER_FIELD_PACK_SLOT_1);state.player_fields.erase(F::PLAYER_FIELD_PACK_SLOT_1+1);
|
|
state.items[item].fields[8]=uint32_t(bag);state.items[item].fields[9]=uint32_t(bag>>32);
|
|
check(state.gameplay(0x3e016c,request(2,30,0)).body==Bytes({19,0,2,0,0,0}));
|
|
rejected(request(2,30,1));rejected(request(2,30,2));rejected(request(2,31,0));
|
|
state.items[item].fields[8]=uint32_t(self);state.items[item].fields[9]=0;rejected(request(2,30,0));
|
|
std::cout<<"Owned inventory destroy source count/container/identity and strict framing PASS; no network deletion.\n";
|
|
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}
|