Files

67 lines
3.4 KiB
Python

"""#56 Undead on 77ddf8d6 (2026-11-25). Earlier follow-up on bccb5019 (2026-11-25): anim 211 lookup entries moved onto the client's probe path (i += p*p) in
Tauren 968705, Gnome 900914 and the Undead skel 2140228 (inputs/fix.py). Troll and Blood Elf already sat on it.
Undead normal model 959310 (flags1 0 cell) gets the sequence + new .anim 8840138."""
import hashlib
import json
import struct
import sys
from pathlib import Path
H = Path(__file__).resolve().parent
sys.path.insert(0, str(H))
import frozen_store as fs
C = fs.casc
WHY = 'Octo /dancespecial (anim 211) added to the Undead male model the client loads (flags1 0 cell), retargeted from Octo (#56)'
PINS = {959310: ('character/scourge/male/scourgemale_hd.m2', '959310.m2')}
# Undead: the client loads 959310's flags1 0 ROOT cell (a0164fc9, self-contained v272 model with its own sequences; the
# skel-based cell bccb patched carries content flag 0x80 = LowViolence). It gets 211 like Tauren: new sequence + .anim.
NATFILE = {959310: '959310-normal.bin'}
NEW = [(8840138, 'character/scourge/male/scourgemale_hd0211-00-full.anim')]
md5 = lambda b: hashlib.md5(b).hexdigest()
sha = lambda b: hashlib.sha256(b).hexdigest()
root = (fs.PARENT / 'decoded/root.bin').read_bytes()
lay = C.root_groups(root)
assert lay['root_md5'] == fs.ROOT
cells = {f: [] for f in PINS}
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 cells:
cells[f].append((g, g['ckeys_offset'] + i * 16))
f += 1
patched = bytearray(root)
pins = []
for fid, (name, out) in sorted(PINS.items()):
old = (H / 'inputs/nat' / NATFILE.get(fid, f'{fid}.bin')).read_bytes()
new = (H / 'inputs/out' / out).read_bytes()
hits = [(g, at) for g, at in cells[fid] if root[at:at + 16].hex() == md5(old)]
assert len(hits) == 1, (fid, len(hits))
g, at = hits[0]
kind = 'wdc_enus' if g['locale'] & 2 and not g.get('flags1') else 'root_selector'
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={},
original_decoded=dict(file='before.bin', md5=md5(old), sha256=sha(old)), encrypted_original=False,
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=kind))
assert all(f > lay['max_file_data_id'] for f, _ in NEW)
assets = []
for fid, path in NEW:
src = H / 'inputs/out' / f'{fid}.anim'
raw = src.read_bytes()
assets.append(dict(file_data_id=fid, path=path, sha256=sha(raw), ckey=md5(raw), kind='M2', file=str(src)))
art = H / 'pins' / 'new-anims.json'
raw = (json.dumps(dict(type='art', parent_root=fs.ROOT, assets=assets), indent=1) + '\n').encode()
art.write_bytes(raw)
pins.append(dict(file=str(art), sha256=sha(raw), type='art'))
(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')
print('pins', len(pins), [p['type'] for p in pins])