73 lines
4.4 KiB
Python
73 lines
4.4 KiB
Python
"""#84 (2026-11-28): VolumeFog::MAX_INTERIOR_WMO_PARAMS assert (count 65-91) seen from Brill/Elwynn/BRM.
|
|
Content 4371a22a made 307 Turtle street groups EXTERIOR (0x8) so players could mount in Stormwind/Undercity. An exterior
|
|
group is drawn from anywhere without portal culling, so whole cities became visible fog volumes from outside
|
|
(Brill capture: 140 records at Undercity; parent 653662a8 cleared INTERIOR and still asserted, so 0x8 is the cause).
|
|
Native 70334 keeps city streets INTERIOR and marks them outdoor in WMOAreaTable (FORCE_OUTDOORS 0x4: Blizzard Undercity
|
|
WMOID 1150 has it on 805/861 rows; TrinityCore TerrainMgr applies the same rule). So:
|
|
- restore those groups (root MOGI + group MOGP) to their converted interior flags: +0x2000, -0x8;
|
|
- WMOAreaTable rows of the same groups (513 rows, 307 WMOID/group keys) get Flags |= 0x4 (outdoor_rows.py + Db2Bake setrows)."""
|
|
import json, hashlib, struct, sys, glob, os
|
|
from pathlib import Path
|
|
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
PREV = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/wmofog-1186-20261128/pins')
|
|
WHY = '#84: Turtle street groups back to interior (EXTERIOR made cities fog volumes from outside); outdoor via WMOAreaTable FORCE_OUTDOORS'
|
|
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
|
|
fids = {}
|
|
for pj in glob.glob(str(PREV / '*/pin.json')):
|
|
p = json.load(open(pj)); fids[p['fdid']] = (p['table'], (Path(pj).parent / 'after.bin').read_bytes())
|
|
fids[1355528] = ('WMOAreaTable', None)
|
|
want = {f: [] for f in fids}
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += d
|
|
if f in want: want[f].append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
|
|
|
|
def chunks(b):
|
|
o = 0
|
|
while o + 8 <= len(b):
|
|
n = struct.unpack_from('<I', b, o + 4)[0]
|
|
yield b[o:o + 4][::-1].decode('latin1'), o + 8, n
|
|
o += 8 + n
|
|
|
|
|
|
def restore(f):
|
|
assert f & 0x8 and not f & 0x2000, hex(f)
|
|
return (f | 0x2000) & ~0x8
|
|
|
|
|
|
patched = bytearray(root); pins = []; stats = {'group': 0, 'root-entries': 0, 'db2': 0}
|
|
for fid, (name, prev_after) in sorted(fids.items()):
|
|
en = [(g, at) for g, at in want[fid] if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, (fid, len(en))
|
|
g, at = en[0]; ck = root[at:at + 16].hex(); old = store.read(ck)[2]
|
|
if prev_after is None:
|
|
assert old == (H / 'in/WMOAreaTable.db2').read_bytes(), 'WMOAreaTable input differs from parent store'
|
|
new = (H / 'out/WMOAreaTable.db2').read_bytes(); stats['db2'] += 1
|
|
else:
|
|
assert old == prev_after, ('parent bytes differ from wmofog after', fid)
|
|
nb = bytearray(old); c = {t: (o, n) for t, o, n in chunks(old)}
|
|
if 'MOGP' in c:
|
|
o = c['MOGP'][0]; struct.pack_into('<I', nb, o + 8, restore(struct.unpack_from('<I', old, o + 8)[0])); stats['group'] += 1
|
|
else:
|
|
before = (PREV / str(fid) / 'before.bin').read_bytes(); mo, mn = c['MOGI']
|
|
for i in range(mn // 32):
|
|
f, fb = struct.unpack_from('<I', old, mo + i * 32)[0], struct.unpack_from('<I', before, mo + i * 32)[0]
|
|
if f != fb: struct.pack_into('<I', nb, mo + i * 32, restore(f)); stats['root-entries'] += 1
|
|
new = bytes(nb)
|
|
patched[at:at + 16] = bytes.fromhex(md5(new))
|
|
d = H / 'pins' / str(fid); d.mkdir(parents=True, exist_ok=True)
|
|
(d / 'before.bin').write_bytes(old); (d / 'after.bin').write_bytes(new)
|
|
pin = dict(fdid=fid, table=name, parent_root=fs.ROOT, selected_group={}, encrypted_original=False,
|
|
original_decoded=dict(file='before.bin', md5=ck, sha256=sha(old)),
|
|
after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
|
|
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
|
|
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type='wdc_enus'))
|
|
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
|
|
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT, decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
|
|
(H / 'prep-report.json').write_text(json.dumps(dict(stats=stats, pins=len(pins)), indent=1) + '\n')
|
|
print('pins', len(pins), stats)
|