From 1bcb83961a76e5e5c00b7b2898094744811aae3b Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Mon, 9 Feb 2026 21:46:45 -0500 Subject: [PATCH] Guard against word-not-found in sread tokenization If text.find(word_str, offset) returns -1, use the offset as a fallback. --- src/mudlib/zmachine/zcpu.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mudlib/zmachine/zcpu.py b/src/mudlib/zmachine/zcpu.py index 44ca97c..3cc67fb 100644 --- a/src/mudlib/zmachine/zcpu.py +++ b/src/mudlib/zmachine/zcpu.py @@ -670,6 +670,8 @@ class ZCpu: word_str, dict_addr = tokens[i] # Find word position in text pos = text.find(word_str, offset) + if pos == -1: + pos = offset # fallback: best guess position word_len = len(word_str) base = parse_buffer_addr + 2 + (i * 4) self._memory.write_word(base, dict_addr)