Files
WoW-Hybrid-gateway/ops/native_loot_roll_cache.py

35 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Prepare the bounded roll retry inside the pinned native UI child; no install."""
import argparse
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
CHILD = 'interface/addons/blizzard_uipanels_game/mainline/grouplootframe.lua'
ORIGINAL_SHA256 = 'df21c8b53bd01596aa0c501cb7d3fd9238d9445368b866c15e06ca318851b208'
def adapt(original, helper):
if hashlib.sha256(original).hexdigest() != ORIGINAL_SHA256:
raise ValueError('Native GroupLootFrame preimage changed')
if b'if not issecure or not issecure() then return end' not in helper:
raise ValueError('Native-only recovery requires a secure execution guard')
return original + b'\r\n-- Bounded native item-cache retry.\r\ndo\r\n' + helper + b'\nend\n'
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('original', type=Path)
parser.add_argument('output', type=Path)
args = parser.parse_args()
data = adapt((args.original / CHILD).read_bytes(), (ROOT / 'ops/native_loot_roll_cache.lua').read_bytes())
target = args.output / CHILD
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
(args.output / 'manifest.private.json').write_text(json.dumps(dict(
state='PREPARED_NOT_INSTALLED', requires='native secure FrameXML child loading; addon entry removed',
children=[dict(path=CHILD, original_sha256=ORIGINAL_SHA256,
sha256=hashlib.sha256(data).hexdigest(), bytes=len(data))]), indent=2) + '\n')
print('Prepared native loot retry child; secure-load/combat acceptance still required.')
if __name__ == '__main__':
main()