#!/usr/bin/env python """Decode a find-cell-list-capture.log into the golden fixture format. The cdb capture (tools/cdb/find-cell-list-capture.cdb) writes player world origin as raw IEEE-754 hex: [fcl] seed=0xHHHHHHHH px=0xHHHHHHHH py=0xHHHHHHHH pz=0xHHHHHHHH picked=0xHHHHHHHH This rewrites px/py/pz to decimals (RetailTrace.ParseFindCellList format): [fcl] seed=0xHHHHHHHH px= py= pz= picked=0xHHHHHHHH Usage: py tools/cdb/decode_fcl_capture.py """ import re import struct import sys LINE = re.compile( r"\[fcl\]\s+seed=0x([0-9a-fA-F]+)\s+px=0x([0-9a-fA-F]+)\s+py=0x([0-9a-fA-F]+)" r"\s+pz=0x([0-9a-fA-F]+)\s+picked=0x([0-9a-fA-F]+)") def hex_to_float(h: str) -> float: return struct.unpack(" int: src, dst = sys.argv[1], sys.argv[2] out = [] seen = set() with open(src, "r", encoding="utf-8", errors="ignore") as f: for line in f: m = LINE.search(line) if not m: continue seed, px, py, pz, picked = m.groups() # Dedupe identical (seed, picked, rounded-pos) rows to keep the golden tight. x, y, z = hex_to_float(px), hex_to_float(py), hex_to_float(pz) key = (seed.lower(), picked.lower(), round(x, 2), round(y, 2), round(z, 2)) if key in seen: continue seen.add(key) out.append( f"[fcl] seed=0x{int(seed,16):08X} " f"px={x:.4f} py={y:.4f} pz={z:.4f} " f"picked=0x{int(picked,16):08X}") with open(dst, "w", encoding="utf-8") as f: f.write("\n".join(out) + "\n") print("\n".join(out)) print(f"\n{len(out)} unique picks -> {dst}") return 0 if __name__ == "__main__": sys.exit(main())