AVA2 cross-platform client parity baseline
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/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_)[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)
|
||||
Reference in New Issue
Block a user