Files
WoW-Hybrid-gateway/tests/pvp_player_flags_codec_fixture.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

22 lines
1.4 KiB
Python

"""Focused original PlayerFlags writer boundary; Source acknowledgment owns desired state."""
import ctypes, os, struct, sys
from pathlib import Path
P=struct.pack
codec=Path(sys.argv[1]).resolve();handles=[]
if codec.suffix.lower()=='.dll':handles.append(os.add_dll_directory(str(codec.parent)))
library=ctypes.CDLL(str(codec));fn=library.gw_codec_serialize
fn.argtypes=[ctypes.c_uint32,ctypes.c_void_p,ctypes.c_uint32,ctypes.c_uint32,ctypes.c_void_p,ctypes.c_uint32,ctypes.POINTER(ctypes.c_uint32)];fn.restype=ctypes.c_int
def encode(flags):
index=190;n=index//32+1
body=P('<IBB',1,0,0)+bytes.fromhex('039d11')+bytes([n])+b''.join(P('<I',(1<<(index%32)) if i==index//32 else 0) for i in range(n))+P('<I',flags)
data=P('<HIQI',70,0,4509,0xA9)+body;source=ctypes.create_string_buffer(data);out=ctypes.create_string_buffer(1048576);written=ctypes.c_uint32()
assert fn(6,source,len(data),0,out,len(out),ctypes.byref(written))==0
return out.raw[:written.value]
zero=encode(0)
for flags in (0x200,0,0x40000,0x40200,0xffffffff,0xcc0,0x10):
packet=encode(flags)
assert packet[:-4]==zero[:-4], 'Unrelated original writer bytes changed'
assert packet[-4:]==P('<I',flags&0x6333f), ('PlayerFlags projection',hex(flags),packet[-4:].hex())
assert encode(0x200)!=zero and encode(0xcc0)==zero
print('PASS native original PlayerFlags writer: desired enable/clear, timer preservation and unrelated-bit isolation')