883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
35 lines
3.9 KiB
C++
35 lines
3.9 KiB
C++
#include "loot_receipt_translation.hpp"
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
namespace F=turtle_entity_fields;
|
|
void check(bool v){if(!v)throw Error("receipt correlation test failed");}
|
|
constexpr uint64_t self=4509,id=0x40000000000f4342ULL;
|
|
void item(NativeInventoryTranslation& i,uint64_t guid,uint32_t count,uint64_t owner=self){auto& x=i.items[guid];x.guid=guid;x.type=1;x.fields[F::OBJECT_FIELD_ENTRY]=84507;x.fields[F::ITEM_FIELD_OWNER]=uint32_t(owner);x.fields[F::ITEM_FIELD_CONTAINED]=uint32_t(owner);x.fields[F::ITEM_FIELD_STACK_COUNT]=count;}
|
|
void slot(NativeInventoryTranslation& i,uint64_t guid,unsigned index=34){i.player_fields[F::PLAYER_FIELD_INV_SLOT_HEAD+2*index]=uint32_t(guid);i.player_fields[F::PLAYER_FIELD_INV_SLOT_HEAD+2*index+1]=uint32_t(guid>>32);}
|
|
TurtleLootItem award(uint32_t count=1){TurtleLootItem x;x.item=84507;x.count=count;return x;}
|
|
TurtleItemPush push(uint32_t count=1){TurtleItemPush x;x.player=self;x.item=84507;x.count=count;x.bag=255;x.slot=34;x.show_in_chat=true;return x;}
|
|
int main(){try{
|
|
NativeInventoryTranslation inventory;NativeLootReceipts receipts;receipts.observe(inventory,self,true);
|
|
receipts.roll(award());check(receipts.take().empty());item(inventory,id,1);receipts.observe(inventory,self);check(receipts.take().empty());slot(inventory,id);receipts.observe(inventory,self);
|
|
auto out=receipts.take();check(out.size()==1 && out[0].find(" 84507 1 0 12")!=std::string::npos);check(receipts.take().empty());
|
|
// A later ordinary receipt for this same delivered item must not duplicate it.
|
|
receipts.push(push(),self);check(receipts.take().empty());
|
|
// A genuine stack increase is separate delivery, without inventing a create.
|
|
receipts.roll(award(2));item(inventory,id,3);receipts.observe(inventory,self);out=receipts.take();check(out.size()==1 && out[0].find(" 84507 2 ")!=std::string::npos);
|
|
// Ordinary Source receipt before object delta waits, then wins over fallback.
|
|
receipts.roll(award());receipts.push(push(),self);check(receipts.take().empty());item(inventory,id,4);receipts.observe(inventory,self);out=receipts.take();check(out.size()==1);check(receipts.take().empty());
|
|
// A future ordinary stack receipt must not reuse an older consumed delta.
|
|
receipts.push(push(),self);check(receipts.take().empty());item(inventory,id,5);receipts.observe(inventory,self);out=receipts.take();check(out.size()==1);
|
|
// Item movement and metadata edits do not count as receipt.
|
|
slot(inventory,0);slot(inventory,id,33);receipts.observe(inventory,self);check(receipts.take().empty());
|
|
// Foreign ownership, bank-only rows and initial login never establish delivery.
|
|
NativeInventoryTranslation held;NativeLootReceipts gates;gates.observe(held,self,true);gates.roll(award());item(held,id,1,9999);slot(held,id);gates.observe(held,self);check(gates.take().empty());
|
|
held.items.clear();gates.observe(held,self);item(held,id,1);slot(held,0);slot(held,id,40);gates.observe(held,self);check(gates.take().empty());
|
|
gates.observe(held,self,true);slot(held,id,34);gates.observe(held,self);check(gates.take().empty());
|
|
// Explicit Source show=false consumes the proof without a fallback message.
|
|
NativeInventoryTranslation silent;NativeLootReceipts h;h.observe(silent,self,true);h.roll(award());auto hidden=push();hidden.show_in_chat=false;h.push(hidden,self);item(silent,id,1);slot(silent,id);h.observe(silent,self);check(h.take().empty());check(h.intents.empty());
|
|
// A split stack award is one receipt for the exact sum, once both slots exist.
|
|
NativeInventoryTranslation split;NativeLootReceipts s;item(split,id,10);slot(split,id);s.observe(split,self,true);s.roll(award(3));item(split,id,12);item(split,id+1,1);s.observe(split,self);check(s.take().empty());slot(split,id+1,35);s.observe(split,self);out=s.take();check(out.size()==1 && out[0].find(" 84507 3 ")!=std::string::npos);
|
|
std::cout<<"PASS exact delivery, slot gate, stack/split award, ordinary dedup, hidden receipt, foreign/bank/login holds\n";
|
|
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}
|