aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/seg_manager.cpp5
-rw-r--r--engines/sci/engine/seg_manager.h2
-rw-r--r--engines/sci/graphics/animate.cpp6
3 files changed, 9 insertions, 4 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index ef2279e492..25cf1d069f 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -508,7 +508,7 @@ List *SegManager::lookupList(reg_t addr) {
return &(lt->_table[addr.offset]);
}
-Node *SegManager::lookupNode(reg_t addr) {
+Node *SegManager::lookupNode(reg_t addr, bool stopOnDiscarded) {
if (addr.isNull())
return NULL; // Non-error null
@@ -522,6 +522,9 @@ Node *SegManager::lookupNode(reg_t addr) {
NodeTable *nt = (NodeTable *)_heap[addr.segment];
if (!nt->isValidEntry(addr.offset)) {
+ if (!stopOnDiscarded)
+ return NULL;
+
error("Attempt to use invalid or discarded reference %04x:%04x as list node", PRINT_REG(addr));
return NULL;
}
diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h
index a7f5f8517f..e0808dbb1b 100644
--- a/engines/sci/engine/seg_manager.h
+++ b/engines/sci/engine/seg_manager.h
@@ -232,7 +232,7 @@ public:
* @param addr The address to resolve
* @return The list node referenced, or NULL on error
*/
- Node *lookupNode(reg_t addr);
+ Node *lookupNode(reg_t addr, bool stopOnDiscarded = true);
// 8. Hunk Memory
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index 6fb427500d..d95125e0a8 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -98,8 +98,10 @@ bool GfxAnimate::invoke(List *list, int argc, reg_t *argv) {
if (_s->abortScriptProcessing != kAbortNone || g_engine->shouldQuit())
return true; // Stop processing
- // Lookup node again, since the nodetable it was in may have been reallocated
- curNode = _s->_segMan->lookupNode(curAddress);
+ // Lookup node again, since the nodetable it was in may have been reallocated.
+ // The node might have been deallocated at this point (e.g. LSL2, room 42),
+ // in which case the node reference will be null and the loop will stop below.
+ curNode = _s->_segMan->lookupNode(curAddress, false);
}
if (curNode) {