From e5329d6788d72b8cf868464d7a4648e0b4eed0bc Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Mon, 9 Feb 2026 21:45:54 -0500 Subject: [PATCH] Fix 7-bit truncation bug in write_global corrupting game state --- src/mudlib/zmachine/zmemory.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mudlib/zmachine/zmemory.py b/src/mudlib/zmachine/zmemory.py index ade9adf..6a19266 100644 --- a/src/mudlib/zmachine/zmemory.py +++ b/src/mudlib/zmachine/zmemory.py @@ -5,7 +5,6 @@ # root directory of this distribution. # -from . import bitfield from .zlogging import log # This class that represents the "main memory" of the z-machine. It's @@ -317,9 +316,8 @@ class ZMemory: raise ZMemoryIllegalWrite(value) log(f"Write {value} to global variable {varnum}") actual_address = self._global_variable_start + ((varnum - 0x10) * 2) - bf = bitfield.BitField(value) - self._memory[actual_address] = bf[8:15] - self._memory[actual_address + 1] = bf[0:7] + self._memory[actual_address] = (value >> 8) & 0xFF + self._memory[actual_address + 1] = value & 0xFF # The 'verify' opcode and the QueztalWriter class both need to have # a checksum of memory generated.