diff options
-rw-r--r-- | engines/saga/interface.cpp | 4 | ||||
-rw-r--r-- | engines/saga/objectmap.h | 7 | ||||
-rw-r--r-- | engines/saga/saga.cpp | 4 | ||||
-rw-r--r-- | engines/saga/script.cpp | 4 | ||||
-rw-r--r-- | engines/saga/sfuncs.cpp | 18 |
5 files changed, 20 insertions, 17 deletions
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 0c59085c8d..7b69ac802c 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -1289,6 +1289,10 @@ void Interface::handleChapterSelectionClick(const Point& mousePoint) { switch (objectTypeId(obj)) { case kGameObjectHitZone: hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(obj)); + + if (hitZone == NULL) + return; + if (hitZone->getFlags() & kHitZoneExit) script = hitZone->getScriptNumber(); break; diff --git a/engines/saga/objectmap.h b/engines/saga/objectmap.h index 39c9f045e5..c3b50c7497 100644 --- a/engines/saga/objectmap.h +++ b/engines/saga/objectmap.h @@ -110,12 +110,7 @@ public: int hitTest(const Point& testPoint); HitZone *getHitZone(int16 index) { if ((index < 0) || (index >= _hitZoneListCount)) { - // HACK: If we get a wrong hitzone, return the last hitzone in the list - // Normally, we don't get wrong hitzones in ITE, however IHNM still seems - // to have problems with some, therefore just throw a warning for now and - // continue with a valid hitzone - warning("ObjectMap::getHitZone wrong index 0x%X, adjusting it to 0x%X", index, _hitZoneListCount - 1); - index = _hitZoneListCount - 1; + return NULL; } return _hitZoneList[index]; } diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 3ce0e08d9c..7573988a8d 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -352,6 +352,10 @@ const char *SagaEngine::getObjectName(uint16 objectId) { return _actor->_actorsStrings.getString(actor->_nameIndex); case kGameObjectHitZone: hitZone = _scene->_objectMap->getHitZone(objectIdToIndex(objectId)); + + if (hitZone == NULL) + return ""; + return _scene->_sceneStrings.getString(hitZone->getNameIndex()); } warning("SagaEngine::getObjectName name not found for 0x%X", objectId); diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 143bda6d5b..578a42c5c8 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -469,6 +469,10 @@ void Script::doVerb() { else if (objectType == kGameObjectHitZone) { scriptModuleNumber = _vm->_scene->getScriptModuleNumber(); hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(_pendingObject[0])); + + if (hitZone == NULL) + return; + if ((hitZone->getFlags() & kHitZoneExit) == 0) { scriptEntrypointNumber = hitZone->getScriptNumber(); } diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index e7fe746acc..16051b49af 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -386,13 +386,14 @@ void Script::sfScriptDoAction(SCRIPTFUNC_PARAMS) { break; case kGameObjectHitZone: case kGameObjectStepZone: - if (objectTypeId(objectId) == 0) - return; - else if (objectTypeId(objectId) == kGameObjectHitZone) + if (objectTypeId(objectId) == kGameObjectHitZone) hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId)); else hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId)); + if (hitZone == NULL) + return; + scriptEntryPointNumber = hitZone->getScriptNumber(); moduleNumber = _vm->_scene->getScriptModuleNumber(); break; @@ -731,14 +732,6 @@ void Script::sfEnableZone(SCRIPTFUNC_PARAMS) { int16 flag = thread->pop(); HitZone *hitZone; - // HACK: Don't disable the tear in scene 14, to keep the staircase functioning - // FIXME: Investigate why this hack is needed and remove it - if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 1 && - _vm->_scene->currentSceneNumber() == 14) { - warning("sfEnableZone: HACK: Prevent unusable staircase"); - return; // Do nothing - } - if (objectTypeId(objectId) == 0) return; else if (objectTypeId(objectId) == kGameObjectHitZone) @@ -746,6 +739,9 @@ void Script::sfEnableZone(SCRIPTFUNC_PARAMS) { else hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId)); + if (hitZone == NULL) + return; + if (flag) { hitZone->setFlag(kHitZoneEnabled); } else { |