883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
55 lines
3.1 KiB
Python
55 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Original70334 ItemModList and VisibleItem transmog-flag goldens; offline."""
|
|
import os,struct,sys
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parent))
|
|
from native_codec_driver import load,serialize,ROOT,MODES
|
|
if not Path(os.environ.get('GW_TEST_CODEC_PATH',ROOT/'build/forever-schema/libforever_codec.so')).is_file():sys.exit(77)
|
|
library=load();P=struct.pack;MODE=MODES.index('--item-appearance');assert MODE==39;item=(0x4000<<48)|75
|
|
|
|
def bits(value):
|
|
value+='0'*((-len(value))%8);return int(value,2).to_bytes(len(value)//8,'big')
|
|
def packed(raw):return P('<H',sum(1<<i for i,b in enumerate(raw)if b))+bytes(b for b in raw if b)
|
|
def block(guid,values):return b'\0'+packed(guid)+P('<I',len(values))+values
|
|
|
|
def expected(appearance,slot):
|
|
# Independent original ItemData outer mask bit0+17, nested ItemModList
|
|
# mask/7bit size/changed index. Type0 is ALL_SPECS appearance, not item ID.
|
|
outer=bits('01'+f'{(1<<17)|1:032b}')
|
|
nested=b'\x81\x80\0'+P('<I',appearance)if appearance else b'\x80'
|
|
values=bytes([1,0,3])+P('<I',2)+outer+nested
|
|
first=block(P('<QQ',75,3<<58),values)
|
|
# PlayerData original Classic group233, slot234+index,11 presence bits,
|
|
# extra false noQuestLogMask flag, and VisibleItem mask0+1/HasTransmog.
|
|
pm=bits(f'{1<<7:011b}'+f'{(1<<9)|(1<<(10+slot)):032b}'+'0')
|
|
vm=bits(f'{3:012b}'+str(int(bool(appearance))))
|
|
player=bytes([1,0,3])+P('<I',1<<6)+pm+vm
|
|
second=block(P('<QQ',4518,(2<<58)|(70<<42)),player)
|
|
return P('<HIBI',1,2,128,len(first)+len(second))+first+second
|
|
|
|
def body(appearance,slot=4):return P('<HHQHQIBBB',1,70,4518,1,item,appearance,1,slot,bool(appearance))
|
|
for slot in(0,4,18):
|
|
for appearance in(0,160297,318030,0x7fffffff):
|
|
data=body(appearance,slot)
|
|
assert serialize(library,MODE,data)==expected(appearance,slot),'Native modifier/visible flag update or explicit clear differs'
|
|
for n in range(len(data)):
|
|
try:serialize(library,MODE,data[:n])
|
|
except ValueError:pass
|
|
else:raise AssertionError('Truncated appearance projection accepted')
|
|
# Item metadata and player flag lifetimes differ: allow an independently
|
|
# changed item appearance or a flag-only clear after object destruction.
|
|
full=expected(160297,4);item_block=full[11:39];player_block=full[39:]
|
|
flag_only=P('<HHQHBBB',1,70,4518,0,1,4,1)
|
|
assert serialize(library,MODE,flag_only)==P('<HIBI',1,1,128,len(player_block))+player_block
|
|
item_only=P('<HHQHQIB',1,70,4518,1,item,160297,0)
|
|
assert serialize(library,MODE,item_only)==P('<HIBI',1,1,128,len(item_block))+item_block
|
|
bad=[P('<HHQH',1,70,4518,0),P('<HHQH',1,70,4518,39),P('<HHQH',1,70,4518,2)+P('<QI',item,1)*2+b'\1\4\1',body(1)+b'\0']
|
|
for at,data in((2,b'\0\0'),(4,bytes(8)),(14,P('<Q',75)),(22,P('<I',0x80000000)),(26,b'\0'),(27,b'\x13'),(28,b'\2')):
|
|
v=bytearray(body(1));v[at:at+len(data)]=data;bad.append(bytes(v))
|
|
bad.append(body(1)[:-3]+b'\2\4\1\4\0')
|
|
for data in bad:
|
|
try:serialize(library,MODE,data)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Invalid owner/identity/count/duplicate/slot/flag/trailing data accepted')
|
|
print('12 original70334 item modifier + sparse player transmog-flag update/clear goldens and truncation/identity/ownership/duplicate bounds pass. No engine rendering claim.')
|