diff options
author | Filippos Karapetis | 2014-04-30 22:52:02 +0300 |
---|---|---|
committer | Filippos Karapetis | 2014-04-30 22:52:02 +0300 |
commit | 521e0394f68267b1ff466e2eb81c00540ff9ece1 (patch) | |
tree | 03969dd9c6a88dae972f97b3a58eee9215813f82 | |
parent | c37c45370c888e608184cdb5f145fbc5d2048b54 (diff) | |
download | scummvm-rg350-521e0394f68267b1ff466e2eb81c00540ff9ece1.tar.gz scummvm-rg350-521e0394f68267b1ff466e2eb81c00540ff9ece1.tar.bz2 scummvm-rg350-521e0394f68267b1ff466e2eb81c00540ff9ece1.zip |
MADS: Check for sane object IDs when checking for inventory objects
This avoids crashes in cases where the default excuse is shown, for
objects that can't be operated
-rw-r--r-- | engines/mads/inventory.cpp | 4 | ||||
-rw-r--r-- | engines/mads/nebular/game_nebular.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp index abd281dcc8..a6459c764b 100644 --- a/engines/mads/inventory.cpp +++ b/engines/mads/inventory.cpp @@ -108,11 +108,11 @@ void InventoryObjects::setRoom(int objectId, int sceneNumber) { } bool InventoryObjects::isInRoom(int objectId) const { - return (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId; + return objectId >= 0 && (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId; } bool InventoryObjects::isInInventory(int objectId) const { - return (*this)[objectId]._roomNumber == PLAYER_INVENTORY; + return objectId >= 0 && (*this)[objectId]._roomNumber == PLAYER_INVENTORY; } void InventoryObjects::addToInventory(int objectId) { diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp index b36de8f378..34eb6f140c 100644 --- a/engines/mads/nebular/game_nebular.cpp +++ b/engines/mads/nebular/game_nebular.cpp @@ -619,7 +619,7 @@ void GameNebular::unhandledAction() { _vm->_dialogs->show(0x15); } else if (action.isAction(VERB_TAKE)) { int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId); - if (objId >= 0 && _vm->_game->_objects.isInInventory(objId)) + if (_vm->_game->_objects.isInInventory(objId)) _vm->_dialogs->show(0x10); else if (randVal <= 333) _vm->_dialogs->show(0x8); |