Files

55 lines
4.3 KiB
Python

"""#84 (2026-11-26): the backend now sends server addon replies over 255 bytes as pieces ('\\1' + piece, last '\\2' + piece)
because the 70334 client asserts on longer addon text (owner crash n=496 N=257; OctoShop stuck on 'Loading catalogue').
The store's TW_SHOP receivers join the pieces before handing the message to the secure store. Earlier: #64 (2026-11-26): '/w H' switched to whisper mode before the name was typed and the first whisper never
arrived. OnChar autocomplete writes the cached 'Name ' (empty-surname form) into the edit box, so ParseText sees a
finished word. Trim the autocompleted name (OnChar + the custom tab-complete). Previously: #73 (2026-11-26): sent whispers missing from the partner's whisper tab. Turtle WHISPER_INFORM names reach Lua with a
trailing space (empty surname); the tab key was trimmed in #23 but ChatFrameOverrides' privateMessageList filter
compared strlower(arg2) untrimmed, so own lines were filtered out of the tab. Trim arg2 in the three filter lookups."""
import hashlib, json, struct, sys
from pathlib import Path
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
import frozen_store as fs
FILES = [(4692734, 'interface/addons/blizzard_storeui/blizzard_shared_storeuiinbound.lua')]
WHY = '#84: TW_SHOP receivers join split server addon replies'
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
patched = bytearray(root); pins = []
for FID, NAME in FILES:
cells = []
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 == FID: cells.append((g, g['ckeys_offset'] + i * 16))
f += 1
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, len(en)
g, at = en[0]; ck = root[at:at + 16].hex(); old = store.read(ck)[2]
A = b""" if event == "CHAT_MSG_ADDON" and prefix == "TW_SHOP" and distribution == "GUILD" and type(message)=="string" and #message<=4096 and StoreFrame then
StoreFrame:SetAttribute("sourceshopmessage",nil)"""
B = b""" if event == "CHAT_MSG_ADDON" and prefix == "TW_SHOP" and distribution == "GUILD" and type(message)=="string" then
-- Backend pieces for replies over 255 bytes: '\\1'..piece, last '\\2'..piece (#84).
local mark = message:byte(1)
if mark == 1 then sourceShopPieces[#sourceShopPieces+1] = message:sub(2); return end
if mark == 2 then sourceShopPieces[#sourceShopPieces+1] = message:sub(2); message = table.concat(sourceShopPieces); sourceShopPieces = {} end
if #message>4096 or not StoreFrame then return end
StoreFrame:SetAttribute("sourceshopmessage",nil)"""
A = A.replace(b'\n', b'\r\n'); B = B.replace(b'\n', b'\r\n')
assert old.count(A) == 2, old.count(A)
new = old.replace(A, B)
# Two identical receivers were registered; keep the first, so each reply reaches the store once.
C = b"""local sourceShopReceiver = CreateFrame("Frame")"""
first = new.index(C); second = new.index(C, first + 1)
new = new[:first] + b"local sourceShopPieces = {}\r\n" + new[first:second] + b"if false then\r\n" + new[second:].rstrip(b"\r\n") + b"\r\nend\r\n"
(H / 'inputs' / f'{FID}.before.lua').write_bytes(old); (H / 'inputs' / f'{FID}.after.lua').write_bytes(new)
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=ck, 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='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')
print('pins', len(pins), len(old), len(new))