Files
AVA2/tools/audit_ava2_packet_constants.py
T
shenleiandClaude Opus 5.5 9077aa389a AVA2 client Windows parity passes (gr2 BitKnit2/64-bit, GamePhase handlers, python modules)
- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves
- net: remaining GamePhase handlers, generated GC packet table
- python: event/chat/chr/minimap/guild/quest/messenger/shop-search and
  other native modules ported against the AVA2 Windows client
- render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain
  without baked shade; cape/NPC equipment attachment
- tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md

Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame,
camera bindings, main.cpp fake-content removal) is still in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:43:01 +09:00

34 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Compare port constants to preprocessed AVA2 Windows Packet.h, never another client."""
from pathlib import Path
import re,subprocess,json,sys
root=Path(__file__).resolve().parents[1]
compiler=sys.argv[1] if len(sys.argv)>1 else 'clang++'
original=root/'upstream/ava2-client/UserInterface'
packet=(original/'Packet.h').read_text(errors='replace')
packet=packet.replace('#pragma once','')
packet=re.sub(r'^\s*#\s*include[^\n]*','',packet,flags=re.M)
translation=f'#include "{original / "Locale_inc.h"}"\n#include "{root / "upstream/ava2-client/EterBase/ServiceDefs.h"}"\n'+packet
processed=subprocess.check_output([compiler,'-E','-P','-x','c++','-'],input=translation,text=True)
values={}
for body in re.findall(r'\benum\s*\w*\s*\{(.*?)\}',processed,re.S):
value=-1
for member in body.split(','):
match=re.fullmatch(r'\s*(\w+)\s*(?:=\s*(0x[0-9a-fA-F]+|\d+))?\s*',member)
if not match: continue
value=int(match[2],0) if match[2] else value+1
values[match[1]]=value
aliases={'HEADER_CG_CHARACTER_CREATE':'HEADER_CG_PLAYER_CREATE','HEADER_CG_CHARACTER_DELETE':'HEADER_CG_PLAYER_DESTROY','HEADER_CG_MOVE':'HEADER_CG_CHARACTER_MOVE','HEADER_CG_CHARACTER_SELECT':'HEADER_CG_PLAYER_SELECT','HEADER_GC_CHARACTER_CREATE_SUCCESS':'HEADER_GC_PLAYER_CREATE_SUCCESS','HEADER_GC_CHARACTER_CREATE_FAILURE':'HEADER_GC_PLAYER_CREATE_FAILURE','HEADER_GC_CHARACTER_DELETE_SUCCESS':'HEADER_GC_PLAYER_DELETE_SUCCESS','PHASE_OFFLINE':'PHASE_CLOSE'}
port=(root/'src/eter_net/Packet.h').read_text()
checked=[];mismatches=[];unmatched=[]
for name,value in re.findall(r'\b((?:HEADER_[CG][GC]_|PHASE_|EXCHANGE_SUBHEADER_|MESSENGER_SUBHEADER_CG_|GUILD_SUBHEADER_CG_)[A-Z0-9_]+)\s*=\s*(0x[0-9a-fA-F]+|\d+)',port):
reference=aliases.get(name,name)
if reference not in values: unmatched.append(name);continue
row={'name':name,'windows_name':reference,'windows':values[reference],'port':int(value,0)}
checked.append(row)
if row['windows']!=row['port']:mismatches.append(row)
report={'reference':'upstream/ava2-client/UserInterface/Packet.h preprocessed with AVA2 Windows feature headers','checked':len(checked),'mismatches':mismatches,'unmatched':unmatched}
(root/'docs/AVA2-PACKET-CONSTANTS.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(report,indent=2))
if mismatches or unmatched:sys.exit(1)