367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
31 lines
2.5 KiB
Python
31 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate inventory-error identity from authoritative enum names/UI labels."""
|
|
import argparse,hashlib,json,re
|
|
from pathlib import Path
|
|
from spell_result_profile import enum,ROOT
|
|
TURTLE=Path.home()/'Servers/tortoise-wow/src/game/Objects/Item.h'
|
|
FOREVER=Path.home()/'Projects/WoW-Hybrid/servers/trinity-forever/src/server/game/Entities/Item/ItemDefines.h'
|
|
def generate():
|
|
old,oh=enum(TURTLE,'InventoryResult');new,nh=enum(FOREVER,'InventoryResult')
|
|
text=TURTLE.read_text().split('enum InventoryResult',1)[1].split('{',1)[1].split('}',1)[0]
|
|
labels=dict(re.findall(r'(EQUIP_ERR_\w+)\s*=\s*\d+[^\n]*?//\s*(ERR_\w+)',text))
|
|
rows=[];unsupported=[]
|
|
for name,value in old.items():
|
|
# Turtle NONE means cannot disenchant; modern NONE is a different code.
|
|
target=name if name in new and name!='EQUIP_ERR_NONE' else 'EQUIP_'+labels.get(name,'')
|
|
if target not in new:unsupported.append({'name':name,'value':value});continue
|
|
rows.append({'turtle_name':name,'turtle':value,'forever_name':target,'forever':new[target]})
|
|
if unsupported:raise ValueError('Review unmatched inventory errors: '+str(unsupported))
|
|
header='// Generated by ops/inventory_result_profile.py; names/UI labels, no numeric offset.\n#pragma once\n#include <cstdint>\nnamespace gateway::inventory_results {\ninline int32_t forever(uint8_t old){switch(old){\n'
|
|
header+=''.join(f"case {r['turtle']}:return {r['forever']}; // {r['turtle_name']} -> {r['forever_name']}\n" for r in rows)+'default:return -1;}}\n}\n'
|
|
report=json.dumps({'turtle_source':'src/game/Objects/Item.h','turtle_sha256':oh,'forever_source':'src/server/game/Entities/Item/ItemDefines.h','forever_sha256':nh,'mappings':rows,'unsupported':unsupported,'limits':'Duplicate legacy UI labels can map to the same modern message identity. Packet optional fields and real-client behavior require separate verification.'},indent=2)+'\n'
|
|
return header,report
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser();parser.add_argument('--check',action='store_true');args=parser.parse_args()
|
|
header,report=generate()
|
|
for path,data in ((ROOT/'include/gateway/inventory_result_profile.hpp',header),(ROOT/'docs/evidence/data/inventory-result-profile.json',report)):
|
|
if args.check:
|
|
if path.read_text()!=data:raise ValueError('Inventory result profile drift; review regeneration')
|
|
else:path.write_text(data)
|
|
print('Inventory result semantic-name profile matches.' if args.check else 'Generated inventory result profile; authoritative sources unchanged.')
|