Files

58 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""What did Turtle change vs base 1.12? First step of EVERY Octo->Forever parity job (docs/PLAYBOOK.md P1).
Octo client archives: base 1.12 = everything that is not patch-*.mpq (Blizzard's own patch.MPQ is base);
Turtle = patch-*.mpq (highest first). For each path matching the glob(s) this prints one JSON line:
{"path", "turtle": <archive or null>, "base": <archive or null>, "status": "turtle-new"|"turtle-changed"|"same"}
Only "turtle-new"/"turtle-changed" need porting; "same" keeps the native 70334 asset (owner 2026-11-28).
turtle_changed.py 'Character\\*\\*\\*.m2' 'Sound\\Character\\*' 'DBFilesClient\\Emotes*.dbc'
turtle_changed.py --changed-only --names-from listfile.txt
Paths are matched case-insensitively against the MPQ listfiles (all archives)."""
import argparse, fnmatch, json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'maps14-20261122'))
import octo_mpq as O
def classify(path, arch):
turtle = base = None; tb = bb = None
for n, a in arch:
try:
if a.find(path) is None: continue
except Exception: continue
if n.lower().startswith('patch-'):
if turtle is None: turtle, tb = n, a.read(path)
elif base is None:
base, bb = n, a.read(path)
if turtle is None: status = 'same'
elif base is None: status = 'turtle-new'
else: status = 'same' if tb == bb else 'turtle-changed'
return dict(path=path, turtle=turtle, base=base, status=status)
def listed(arch):
names = set()
for _, a in arch:
try: names.update(l.strip() for l in a.read('(listfile)').decode('latin1').splitlines() if l.strip())
except Exception: pass
return names
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('globs', nargs='*'); ap.add_argument('--changed-only', action='store_true')
ap.add_argument('--names-from', help='file with one MPQ path per line (instead of / in addition to globs)')
a = ap.parse_args(); arch = O.archives()
paths = set()
if a.names_from: paths.update(l.strip() for l in open(a.names_from) if l.strip())
if a.globs:
pats = [g.lower() for g in a.globs]
paths.update(p for p in listed(arch) if any(fnmatch.fnmatch(p.lower(), g) for g in pats))
seen = {}
for p in sorted(paths): seen.setdefault(p.lower(), p) # MPQ lookups are case-insensitive; listfiles repeat names
for p in sorted(seen.values()):
r = classify(p, arch)
if a.changed_only and r['status'] == 'same': continue
print(json.dumps(r), flush=True)
if __name__ == '__main__':
main()