Version 3.2.2: in-memory replacements fill their slots exactly (padded ones played as silence)

This commit is contained in:
2026-10-11 00:10:44 +02:00
parent cac52e7597
commit b6b96307ca
16 changed files with 223 additions and 52 deletions

View File

@@ -35,6 +35,7 @@ import numpy as np # noqa: E402
from ackit import banks, settings, subtitles # noqa: E402
from ackit.game import Game, default_game_dir # noqa: E402
from ackit.modpack import export_mod, import_mod, match_mod # noqa: E402
from ackit.wem import fill # noqa: E402
from ackit.workspace import Workspace, MODIFIED, ORIGINAL # noqa: E402
RESULTS = []
@@ -80,11 +81,12 @@ def sound_round_trip(ws, s, label):
before = snapshot(files)
ws.apply([(s, wem, {"source": "e2e"})])
ok = ws.state(s) == MODIFIED and ws.current_bytes(s) == wem
orig_size = ws.store.get(s.key)["orig_size"]
for l, b in copies_of(ws, s):
if l.kind == banks.MEMORY:
ok &= b == wem + bytes(l.size - len(wem))
else: # head or whole copy of a WAD line (zero-padded to its size)
full = wem + bytes(max(0, ws.store.get(s.key)["orig_size"] - len(wem)))
if l.kind == banks.MEMORY or l.size >= orig_size: # a whole WEM in memory: fills its slot exactly
ok &= b == fill(wem, l.size)
else: # prefetch head: the start of the WAD recording (zero-padded)
full = wem + bytes(max(0, orig_size - len(wem)))
ok &= b == (full + bytes(l.size))[:l.size]
ws.revert([s])
ok &= ws.state(s) == ORIGINAL and snapshot(files) == before and not ws.store.entries