#!/usr/bin/env python3 """ census.py -- full inventory of a staged-run capture: create types, list_add tree, instance/geogroup/material flush refs. Establishes the shipped node-type ids and the object->lod->geogroup->geometry linkage the renderer walks. python census.py cap5.raw.bin """ import sys, struct from collections import defaultdict sys.path.insert(0, '.') from vrboard import Assembler, A from decode_anim import find_framed_start # shipped type ids (established cap3-cap5; 1994 ids differed from 7 up) TYPE = {2:'zone',3:'view',4:'instance',5:'dcs',6:'lmodel',7:'object',8:'lod', 9:'geogroup',0xa:'geometry',0xb:'material',0xc:'texmap',0xd:'texture', 0xe:'light',0xf:'ramp'} def main(): path = sys.argv[1] if len(sys.argv) > 1 else 'cap5.raw.bin' data = open(path, 'rb').read() asm = Assembler(); asm.feed(data[find_framed_start(data):]) types, flushes, edges = {}, defaultdict(list), [] extra = defaultdict(int) for m in asm: if m.iserver: continue a, p = m.action, m.payload if a == A.create and len(p) >= 8: t, h = struct.unpack_from(' 1e-6 and abs(f) < 1e6: out.append(f'[{i}]={f:.3f}') print(f' {t:9} {h:#04x} ({len(body)}B x{len(flushes[h])}): ' + ' '.join(out)) if __name__ == '__main__': main()