From 2f033e7a4c844bc8747ca5c7f6789a94277a48a6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 5 Jun 2007 15:04:25 +0000 Subject: Check if a zone type is NULL for both ITE and IHNM, as it's done in the original. This fixes the crash in IHNM when entering the second floor of the zeppelin and the crash in ITE when interacting with the bowl in the tunnel, outside the prison. Removed the two relevant hacks svn-id: r27108 --- engines/saga/script.cpp | 35 ++++++++++++++++++----------------- engines/saga/sfuncs.cpp | 24 +++++++++--------------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 2df5c4da14..a7d4392795 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -464,7 +464,9 @@ void Script::doVerb() { } } - if (objectType == kGameObjectHitZone) { + if (objectType == NULL) + return; + else if (objectType == kGameObjectHitZone) { scriptModuleNumber = _vm->_scene->getScriptModuleNumber(); hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(_pendingObject[0])); if ((hitZone->getFlags() & kHitZoneExit) == 0) { @@ -485,21 +487,18 @@ void Script::doVerb() { if (scriptEntrypointNumber > 0) { - // WORKAROUND: Fixes bug #1690045 "ITE: Item description missing / ScummVM crash" - if (!(_vm->_scene->currentSceneNumber() == 278 && (_pendingObject[0] == 16419 || _pendingObject[1] == 16419) && _vm->getGameType() == GType_ITE)) { - event.type = kEvTOneshot; - event.code = kScriptEvent; - event.op = kEventExecNonBlocking; - event.time = 0; - event.param = scriptModuleNumber; - event.param2 = scriptEntrypointNumber; - event.param3 = _pendingVerb; // Action - event.param4 = _pendingObject[0]; // Object - event.param5 = _pendingObject[1]; // With Object - event.param6 = (objectType == kGameObjectActor) ? _pendingObject[0] : ID_PROTAG; // Actor - - _vm->_events->queue(&event); - } + event.type = kEvTOneshot; + event.code = kScriptEvent; + event.op = kEventExecNonBlocking; + event.time = 0; + event.param = scriptModuleNumber; + event.param2 = scriptEntrypointNumber; + event.param3 = _pendingVerb; // Action + event.param4 = _pendingObject[0]; // Object + event.param5 = _pendingObject[1]; // With Object + event.param6 = (objectType == kGameObjectActor) ? _pendingObject[0] : ID_PROTAG; // Actor + + _vm->_events->queue(&event); } else { _vm->getExcuseInfo(_pendingVerb, excuseText, excuseSampleResourceId); @@ -620,7 +619,9 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) { hitZone = NULL; - if (objectTypeId(_pendingObject[0]) == kGameObjectHitZone) { + if (objectTypeId(_pendingObject[0]) == NULL) + return; + else if (objectTypeId(_pendingObject[0]) == kGameObjectHitZone) { hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(_pendingObject[0])); } else { if ((_pendingVerb == getVerbType(kVerbUse)) && (objectTypeId(_pendingObject[1]) == kGameObjectHitZone)) { diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index bebacc39d3..fad2a26247 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -386,11 +386,13 @@ void Script::sfScriptDoAction(SCRIPTFUNC_PARAMS) { break; case kGameObjectHitZone: case kGameObjectStepZone: - if (objectTypeId(objectId) == kGameObjectHitZone) { + if (objectTypeId(objectId) == NULL) + return; + else if (objectTypeId(objectId) == kGameObjectHitZone) hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId)); - } else { + else hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId)); - } + scriptEntryPointNumber = hitZone->getScriptNumber(); moduleNumber = _vm->_scene->getScriptModuleNumber(); break; @@ -729,20 +731,12 @@ void Script::sfEnableZone(SCRIPTFUNC_PARAMS) { int16 flag = thread->pop(); HitZone *hitZone; - if (objectTypeId(objectId) == kGameObjectHitZone) { - hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId)); - } else if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 1 && - _vm->_scene->currentSceneNumber() == 14) { - // HACK: Don't disable the requested hitzone in room 14 in chapter 1 (Gorrister) of IHNM - // Apparently, this is used in that room to disable the tear at the very end of the - // corridor. This fixes the staircase in scenes 4 and 14 - // FIXME: Remove this hack - warning("HACK: Prevent crash at staircase with Gorrister"); - // Do nothing + if (objectTypeId(objectId) == NULL) return; - } else { + else if (objectTypeId(objectId) == kGameObjectHitZone) + hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId)); + else hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId)); - } if (flag) { hitZone->setFlag(kHitZoneEnabled); -- cgit v1.2.3