883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
63 lines
3.7 KiB
Python
63 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""New codec-byte boundary only; reuses original peer builders and VisibleItem goldens."""
|
|
import importlib.util,os,struct,sys
|
|
from pathlib import Path
|
|
P=struct.pack
|
|
codec=Path(sys.argv[1]).resolve()
|
|
os.environ['GW_TEST_CODEC_PATH']=str(codec)
|
|
if codec.suffix.lower()=='.dll':_dll=os.add_dll_directory(str(codec.parent))
|
|
sys.path.insert(0,str(Path(__file__).resolve().parent))
|
|
from native_codec_driver import load,serialize,MODES
|
|
library=load()
|
|
saved=sys.argv[:];sys.argv=[sys.argv[0]]
|
|
spec=importlib.util.spec_from_file_location('peer_builders',Path(__file__).with_name('peer_player_serializer_fixture.py'))
|
|
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);sys.argv=saved
|
|
def encode(mode,body):return serialize(library,MODES.index(mode),body)
|
|
def inventory(fields):
|
|
body=P('<QHII',4509,70,0,1)+P('<QBBH',4509,4,0,len(fields))
|
|
return encode('--inventory-objects',body+b''.join(P('<HI',i,v)for i,v in sorted(fields.items())))
|
|
def peer(fields,delta=None):
|
|
packet=m.source_packet(m.create_record(fields=fields) if delta is None else m.values_record(delta))
|
|
return encode('--players' if delta is None else '--player-values',m.descriptor(packet,fields))
|
|
def self_create(slot,flags):
|
|
fields={22:80,28:80,34:60,35:1,36:0x01000101,190:flags,
|
|
486+2*slot:75,487+2*slot:0x40000000,260+12*slot:50427,718:98,719:0x012c012c}
|
|
masks=[0]*23
|
|
for i in fields:masks[i//32]|=1<<(i%32)
|
|
body=P('<IBB',2,0,3)+bytes.fromhex('039d11')+bytes([4,0x21])
|
|
body+=P('<II4fI',0,100,1,2,3,0,0)+P('<6f',2.5,7,4.5,4.72,2.5,3.14)
|
|
body+=bytes([23])+P('<23I',*masks)+b''.join(P('<I',fields[i])for i in sorted(fields))
|
|
item={3:50427,6:4509,8:4509,14:1}
|
|
body+=bytes([2,0x81,75,0x40,1,0,1])+P('<I',sum(1<<i for i in item))+b''.join(P('<I',item[i])for i in sorted(item))
|
|
header=P('<QHIIIII',4509,70,0x46010046,0,12,0,0)+b'Fixture\0'+bytes([1,1,0])+P('<I',0xa9)
|
|
return serialize(library,0,header+body)
|
|
cases={}
|
|
def accept(kind,ok):
|
|
assert ok,kind
|
|
cases[kind]=cases.get(kind,0)+1
|
|
for slot,mask in ((0,0x400),(14,0x800)):
|
|
field=260+12*slot
|
|
shown=inventory({190:0,field:50427})
|
|
hidden=inventory({190:mask,field:50427})
|
|
empty=inventory({190:mask,field:0})
|
|
accept('self_inventory_hidden_equals_original_empty_slot',hidden==empty and hidden!=shown)
|
|
accept('self_inventory_original_empty_tail',hidden.endswith(bytes.fromhex('3090')+P('<iHI',0,0,0)))
|
|
restored=inventory({190:0,field:50427})
|
|
accept('self_inventory_restore_same_item',restored==shown)
|
|
raw={**m.FIELDS,190:mask,field:50427}
|
|
zero={**raw,field:0}
|
|
accept('peer_create_hidden_equals_empty_slot',peer(raw)==peer(zero) and peer(raw)!=peer({**raw,190:0}))
|
|
accept('peer_flag_only_hidden_equals_empty_slot',peer(raw,{190:mask})==peer(zero,{190:mask,field:0}))
|
|
restored_raw={**raw,190:0}
|
|
accept('peer_flag_only_restore_equals_explicit_slot',peer(restored_raw,{190:0})==peer(restored_raw,{190:0,field:50427}))
|
|
accept('peer_hidden_equipment_replacement_remains_hidden',peer({**raw,field:25},{field:25})==peer({**raw,field:0},{field:0}))
|
|
show=self_create(slot,0);hide=self_create(slot,mask)
|
|
# Existing70334 initial-self VisibleItem full-row golden; replacing this
|
|
# one visual row must leave the real owned ItemData and all other bytes.
|
|
visual=P('<4iHHIBB',50427,0,0,0,0,0,318030,0,0)+b'\0'
|
|
accept('self_create_visual_row_only',show.count(visual)==1 and hide==show.replace(visual,bytes(len(visual)),1))
|
|
# Combined flags must affect only head/back; other equipped slot unchanged.
|
|
raw={**m.FIELDS,190:0xc00,260:50427,428:50427,308:50427}
|
|
accept('combined_peer_head_back_only',peer(raw)==peer({**raw,260:0,428:0}) and peer(raw)!=peer({**raw,308:0}))
|
|
print('PASS',sum(cases.values()),'codec byte cases:',cases)
|