Fields: 325 identified from the most-used unnamed offsets; bracketing is no longer evidence; '-' rows delete wrong fields

Entity _mass (0x2d4) and _depthOffset (0x2b0) were REPENTOGON fields kept by bracketing and both wrong
(Lua getters read 0x37c / 0x358). Bracketed fields now need direct confirmation; 155 are being re-verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-24 23:40:33 -04:00
1 parent 962ec27869
commit 134ab40589
7 files changed
+2306 -2104

No files matched your search

+13 -3
View File
@@ -2,20 +2,28 @@
# db/fields.tsv; later files win at the same offset), base-class fields flattened in, gaps as explicit padding, and a
# static_assert on every member offset. Only offsets this exe confirms are in these files, so the header is as trustworthy
# as the evidence behind them. Pointers are uint32_t (the game is 32-bit), so it compiles on any host.
# Usage: headers.py out.hpp zhl_fields.tsv lua_fields.tsv db/fields.tsv
# A db row with type "-" ("Entity<TAB>0x2d4<TAB>- _mass<TAB>why") deletes a wrong field from the earlier files.
# Usage: headers.py [--merged fields_out.tsv] out.hpp zhl_fields.tsv lua_fields.tsv db/fields.tsv
# --merged also writes the merged field list (what ApplyTypes.java gets)
import collections, re, sys
out, *srcs = sys.argv[1:]
args = sys.argv[1:]
merged = args.pop(args.index('--merged') + 1) if '--merged' in args else None
if merged: args.remove('--merged')
out, *srcs = args
SIZE = {'bool': 1, 'char': 1, 'int8_t': 1, 'uint8_t': 1, 'unsigned char': 1, 'short': 2, 'int16_t': 2, 'uint16_t': 2,
'unsigned short': 2, 'int': 4, 'int32_t': 4, 'uint32_t': 4, 'unsigned int': 4, 'unsigned long': 4, 'long': 4,
'float': 4, 'uint64_t': 8, 'int64_t': 8, 'unsigned long long': 8, 'long long': 8, 'double': 8, 'Vector': 8}
CTYPE = {'unsigned int': 'uint32_t', 'unsigned long': 'uint32_t', 'long': 'int32_t', 'unsigned short': 'uint16_t',
'unsigned char': 'uint8_t', 'unsigned long long': 'uint64_t', 'long long': 'int64_t', 'char': 'int8_t'}
fields, bases = collections.defaultdict(dict), {}
fields, bases, rows = collections.defaultdict(dict), {}, {}
for p in srcs:
for l in open(p):
if l.startswith('#') or not l.strip(): continue
c = l.rstrip('\n').split('\t')
if c[1] == 'base': bases[c[0]] = c[2]; continue
if c[2].startswith('- '):
fields[c[0]].pop(int(c[1], 16), None); rows.pop((c[0], int(c[1], 16)), None); continue
rows[(c[0], int(c[1], 16))] = l if l.endswith('\n') else l + '\n'
decl = c[2].replace('const ', '').strip()
count = re.search(r'\[(\w+)\]\s*$', decl) # "int _trinketsID[2]"
if count: decl = decl[:count.start()]
@@ -63,4 +71,6 @@ with open(out, 'w') as o:
'// add or fix fields in db/fields.tsv and regenerate. Offsets not confirmed in this exe are padding.\n'
'#pragma once\n#include <cstddef>\n#include <cstdint>\n\n#pragma pack(push, 1)\n'
'struct Vector { float x, y; };\n\n' + '\n'.join(o_ for o_ in order if not o_.startswith('struct Vector ')) + '#pragma pack(pop)\n')
if merged:
with open(merged, 'w') as o: o.writelines([f'{c}\tbase\t{b}\n' for c, b in bases.items()] + list(rows.values()))
print(f'headers: {len(done)} structs' + (f'; duplicate member names in {dupes}' if dupes else ''))
+3 -5
View File
@@ -1,8 +1,8 @@
# REPENTOGON's struct offsets target an older exe (1.9.7.12); fields drift as the game adds members, so they are only
# kept where THIS exe confirms them. Evidence ("anchors"): a trivial getter in the corpus ("Class::GetFoo" returning
# this+N anchors field "_foo" at N) or the game's Lua field table (lua_bindings.tsv: "EntityNPC State field+0xb64").
# A field is kept when it is anchored, or lies between two anchors of its class with the same shift; everything else
# is dropped (the decompiler then shows field_0xNNN) until db/fields.tsv confirms it. Base-class rows are always kept.
# A field is kept only when it is anchored; everything else is dropped (the decompiler then shows field_0xNNN) until
# db/fields.tsv confirms it. Base-class rows are always kept.
# Usage: zhl_fields.py all.c zhl_dir lua_bindings.tsv out.tsv [names.tsv: addr \t Class::Member, overrides corpus names]
# Prints per class: kept/total and the shifts seen.
import collections, glob, os, re, sys
@@ -49,9 +49,7 @@ with open(fout, 'w') as o:
shifts = sorted((off, anchor[(c, norm(d.split()[-1]))] - off) for off, d in fields if (c, norm(d.split()[-1])) in anchor)
kept = 0
for off, d in fields:
lo = [s for a, s in shifts if a <= off]; hi = [s for a, s in shifts if a >= off]
if (c, norm(d.split()[-1])) in anchor: new = anchor[(c, norm(d.split()[-1]))]
elif lo and hi and lo[-1] == hi[0]: new = off + lo[-1]
else: continue
else: continue # not confirmed: being between two anchors with the same shift is not proof (Entity _mass, _depthOffset)
o.write(f'{c}\t0x{new:x}\t{d}\n'); kept += 1
if shifts: print(f'{c}: kept {kept}/{len(fields)}, shifts ' + ' '.join(f'{a:x}{s:+#x}' for a, s in shifts if s))