Files

37 lines
1.8 KiB
Python
Raw Permalink Normal View History

2026-10-28 18:54:43 +07:00
"""Export completed, identity-checked native SpecialAvatar rows for CW."""
import argparse
import hashlib
import json
from pathlib import Path
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument('--capture', type=Path, required=True)
p.add_argument('--catalog', type=Path, required=True)
p.add_argument('--output', type=Path, required=True)
a = p.parse_args()
raw = a.capture.read_bytes()
lines = raw.decode('utf-8-sig').splitlines()
if '[GAC_CW_TRIAL_ROW] END' not in lines or any('[GAC_CW_TRIAL_ROW] ERROR' in l for l in lines):
raise ValueError('native trial capture did not complete')
rows = [json.loads(l.split(' ROW ', 1)[1]) for l in lines if '[GAC_CW_TRIAL_ROW] ROW ' in l]
c = json.loads(a.catalog.read_text(encoding='utf-8-sig'))
roles = {r['Config']['SpecialAvatarID']: r['Config']['AvatarID'] for r in c['active_handbook_default_roles']}
seen = set()
for r in rows:
key = r['SpecialAvatarID'], r['WorldLevel']
if key in seen or roles.get(key[0]) != r['AvatarID'] or not r['Level']:
raise ValueError('native trial identity invalid/duplicate')
seen.add(key)
if not rows:
raise ValueError('trial capture empty')
result = dict(format_version=1, target_client_version=c['client_version'], target_assembly_sha256=c['provenance']['game_assembly_sha256'],
source_capture_sha256=hashlib.sha256(raw).hexdigest(),
scope='Current catalog fake-avatar trials at captured world levels. SpecialAvatarExcelTable.GetData, bounded flat-row access; no scene loader. Other trial profiles remain uncaptured.', entries=rows)
a.output.write_text(json.dumps(result, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
print(f'Exported {len(rows)} current trial rows')
if __name__ == '__main__':
main()