Version 3.2.1: whole bank copies of voice lines, unique names, docs figures checked by tools/check_docs.py
This commit is contained in:
@@ -37,7 +37,8 @@ def _offsets(wems):
|
||||
return out
|
||||
|
||||
|
||||
def make(root):
|
||||
def make(root, whole_copy=False):
|
||||
"""whole_copy: INT's bank also stores INT's recording of line A whole, in memory (same media ID)."""
|
||||
cooked = os.path.join(root, "BmGame", "CookedPCConsole")
|
||||
a = {"INT": synth.wem(0.6, 400), "ITA": synth.wem(0.7, 420)}
|
||||
b = {"INT": synth.wem(1.1, 600), "ITA": synth.wem(0.9, 640)}
|
||||
@@ -61,7 +62,8 @@ def make(root):
|
||||
bank_id = fnv1("Speech_Lines")
|
||||
for L in ("INT", "ITA"):
|
||||
blob += _table(ENTRY, rows[L])
|
||||
blob += synth.bank(bank_id, {}, name="Speech_Lines", events=[(EV_A, A[L]), (EV_B, B)]) + bytes(16)
|
||||
mem = {A[L]: a[L]} if whole_copy and L == "INT" else {}
|
||||
blob += synth.bank(bank_id, mem, name="Speech_Lines", events=[(EV_A, A[L]), (EV_B, B)]) + bytes(16)
|
||||
# the copy entry's table sits in a second localized export (INT and ITA; ITA has no such entry: no rows)
|
||||
blob2 = bytes(4) + struct.pack("<HHiiii", 9, 0x84, 0, 0, len(lst), 0) + lst
|
||||
blob2 += _table(COPY_ENTRY, [(A["INT"], a["INT"], 0)]) + bytes(32) + _table(COPY_ENTRY, [(0x999, b"x" * 8, 0)])
|
||||
@@ -122,3 +124,22 @@ def test_names_and_copies_through_the_workspace(tmp_path):
|
||||
assert ws.state(s) == ORIGINAL and ws.state(copy) == ORIGINAL and not ws.store.entries
|
||||
assert hashlib.sha1(open(wad, "rb").read()).hexdigest() == before
|
||||
assert ws.current_bytes(copy) == a["INT"]
|
||||
|
||||
|
||||
def test_whole_recording_in_a_bank_is_written_with_its_line(tmp_path):
|
||||
"""A streamed recording can also be stored whole in a bank (same media ID, e.g. the game-over taunts): like
|
||||
a prefetch head, that copy belongs to the WAD line and is written with it; it is not a sound of its own."""
|
||||
root = str(tmp_path / "game")
|
||||
a, _ = make(root, whole_copy=True)
|
||||
ws = Workspace(root, str(tmp_path / "store"), ["INT", "BANK"])
|
||||
assert "BANK:%08X" % A["INT"] not in ws.catalog.by_key
|
||||
s = ws.catalog.by_key["INT:%08X:0" % ENTRY]
|
||||
(l,) = ws.locations(s)
|
||||
assert l.kind == banks.PREFETCH_HEAD and l.size == len(a["INT"]) and l.file == "Lines.upk"
|
||||
pkg = os.path.join(ws.game.cooked, "Lines.upk")
|
||||
before = hashlib.sha1(open(pkg, "rb").read()).hexdigest()
|
||||
new = synth.wem(0.3, 900)
|
||||
ws.apply([(s, new, {})])
|
||||
assert banks.open_file(pkg).read(l.offset, l.size) == new + bytes(l.size - len(new))
|
||||
ws.revert([s])
|
||||
assert hashlib.sha1(open(pkg, "rb").read()).hexdigest() == before
|
||||
|
||||
Reference in New Issue
Block a user