Files
AVA2/tools/audit_login_profile.py
T

21 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Preprocess AVA2 client/server macro headers; record the verified login dialect."""
import json, subprocess, sys
from pathlib import Path
root=Path(__file__).resolve().parents[1]
compiler=sys.argv[1]
def macros(path):
output=subprocess.check_output([compiler,'-E','-dM','-x','c++',str(root/path)],text=True)
return {line.split()[1] for line in output.splitlines() if line.startswith('#define ')}
client=macros('upstream/ava2-client/UserInterface/Locale_inc.h') | macros('upstream/ava2-client/EterBase/ServiceDefs.h')
server=macros('upstream/ava2-server/common/CommonDefines.h') | macros('upstream/ava2-server/common/service.h')
pairs=[('five_slots','ENABLE_PLAYER_PER_ACCOUNT5','ENABLE_PLAYER_PER_ACCOUNT5'),('sash','ENABLE_SASH_SYSTEM','__SASH_SYSTEM__'),('conqueror','ENABLE_CONQUEROR_LEVEL','ENABLE_CONQUEROR_LEVEL'),('improved_encryption','_IMPROVED_PACKET_ENCRYPTION_','_IMPROVED_PACKET_ENCRYPTION_'),('version_login_field','ENABLE_VERSION_SYSTEM','ENABLE_VERSION_SYSTEM'),('wolfman','ENABLE_WOLFMAN_CHARACTER','ENABLE_WOLFMAN_CHARACTER'),('bank','ENABLE_MANAGER_BANK_SYSTEM','ENABLE_MANAGER_BANK_SYSTEM'),('support','ENABLE_SUPPORT_SYSTEM','ENABLE_SUPPORT_SYSTEM')]
features={name:{'client':a in client,'server':b in server} for name,a,b in pairs}
for name in ('five_slots','sash','conqueror'):
assert features[name]=={'client':True,'server':True},name
for name in ('improved_encryption','version_login_field'):
assert features[name]=={'client':False,'server':False},name
report={'features':features,'dialect':{'auth_login_header':111,'auth_login_bytes':65,'game_login_header':109,'game_login_bytes':52,'character_success_header':32,'character_success_bytes':444,'player_bytes':70,'sequence_enabled':True,'sequence_bytes':1,'encryption_block_bytes':8},'unresolved_feature_mismatches':[name for name,v in features.items() if v['client']!=v['server']]}
out=Path(sys.argv[2]);out.parent.mkdir(parents=True,exist_ok=True);out.write_text(json.dumps(report,indent=2)+'\n')
print('Login macro profile verified; unresolved gameplay flags:',', '.join(report['unresolved_feature_mismatches']))