aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/inventory.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2014-04-30 22:52:02 +0300
committerFilippos Karapetis2014-04-30 22:52:02 +0300
commit521e0394f68267b1ff466e2eb81c00540ff9ece1 (patch)
tree03969dd9c6a88dae972f97b3a58eee9215813f82 /engines/mads/inventory.cpp
parentc37c45370c888e608184cdb5f145fbc5d2048b54 (diff)
downloadscummvm-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
Diffstat (limited to 'engines/mads/inventory.cpp')
-rw-r--r--engines/mads/inventory.cpp4
1 files changed, 2 insertions, 2 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) {