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:
1 parent
962ec27869
commit
134ab40589
7 files changed
+2306
-2104
No files matched your search
+13
-3
@@ -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 ''))
|
||||
Reference in new issue
Block a user