From 42ca630f46f0991f58592c7b2195ff41bdd73b04 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Jun 2010 18:48:50 +0000 Subject: Fixed the LSL3 binoculars scene again, by fixing the invalid varselector reference svn-id: r50227 --- engines/sci/engine/vm.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 4c039d72a0..b7da805251 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -101,23 +101,29 @@ static reg_t &validate_property(Object *obj, int index) { // A static dummy reg_t, which we return if obj or index turn out to be // invalid. Note that we cannot just return NULL_REG, because client code // may modify the value of the returned reg_t. - static reg_t dummyReg = NULL_REG; + //static reg_t dummyReg = NULL_REG; // FIXME/TODO: Where does this occur? Returning a dummy reg here could lead // to all sorts of issues! Turned it into an error for now... // If this occurs, it means there's probably something wrong with the garbage // collector, so don't hide it with fake return values if (!obj) { - error("Sending to disposed object"); - return dummyReg; + error("validate_property: Sending to disposed object"); + //return dummyReg; } - // FIXME/TODO: Where does this occur? Returning a dummy reg here could lead - // to all sorts of issues! Turned it into an error for now... + // This occurs in LSL3, binoculars scene. This gets called from kDoBresen, so fix + // the relevant invalid selector index. TODO: Why does this occur? This looks like + // a script bug. + EngineState *s = g_sci->getEngineState(); + if (index == 633 && s->currentRoomNumber() == 206 && g_sci->getGameId() == "lsl3") + index = 37; + if (index < 0 || (uint)index >= obj->getVarCount()) { - error("Invalid object property #%d (out of [0..%d]) requested!", - index, obj->getVarCount()); - return dummyReg; + error("Invalid object property #%d (out of [0..%d]) requested! Object: %04x:%04x, %s", + index, obj->getVarCount(), PRINT_REG(obj->getPos()), + s->_segMan->getObjectName(obj->getPos())); + //return dummyReg; } return obj->getVariableRef(index); -- cgit v1.2.3