diff --git a/engines/drascula/interface.cpp b/engines/drascula/interface.cpp index 1495694a1b9..1d17c77f83b 100644 --- a/engines/drascula/interface.cpp +++ b/engines/drascula/interface.cpp @@ -120,7 +120,7 @@ void DrasculaEngine::showMenu() { x = whichObject(); strcpy(textIcon, iconName[x]); - for (n = 1; n < 43; n++) { + for (n = 1; n < ARRAYSIZE(inventoryObjects); n++) { h = inventoryObjects[n]; if (h != 0) { @@ -194,11 +194,10 @@ void DrasculaEngine::enterName() { } bool DrasculaEngine::checkMenuFlags() { - for (int n = 0; n < 43; n++) { - if (whichObject() == n) { - if (inventoryObjects[n] != 0 && checkAction(inventoryObjects[n])) - return true; - } + int n = whichObject(); + if (n != 0) { + if (inventoryObjects[n] != 0 && checkAction(inventoryObjects[n])) + return true; } return false; diff --git a/engines/drascula/objects.cpp b/engines/drascula/objects.cpp index 73aea7b7f2d..2bd10140838 100644 --- a/engines/drascula/objects.cpp +++ b/engines/drascula/objects.cpp @@ -221,16 +221,17 @@ void DrasculaEngine::addObject(int obj) { * If no inventory slot is under the mouse cursor, return 0. */ int DrasculaEngine::whichObject() { - int n = 0; + int n; for (n = 1; n < ARRAYSIZE(inventoryObjects); n++) { if (mouseX > _itemLocations[n].x && mouseY > _itemLocations[n].y && mouseX < _itemLocations[n].x + OBJWIDTH && - mouseY < _itemLocations[n].y + OBJHEIGHT) - break; + mouseY < _itemLocations[n].y + OBJHEIGHT) { + return n; + } } - return n; + return 0; } void DrasculaEngine::updateVisible() { diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp index abf17d0e8e0..4aaec5ec0e9 100644 --- a/engines/drascula/saveload.cpp +++ b/engines/drascula/saveload.cpp @@ -210,7 +210,7 @@ bool DrasculaEngine::loadGame(const char *gameName) { curY = sav->readSint32LE(); trackProtagonist = sav->readSint32LE(); - for (l = 1; l < 43; l++) { + for (l = 1; l < ARRAYSIZE(inventoryObjects); l++) { inventoryObjects[l] = sav->readSint32LE(); } @@ -241,7 +241,7 @@ void DrasculaEngine::saveGame(char gameName[]) { out->writeSint32LE(curY); out->writeSint32LE(trackProtagonist); - for (l = 1; l < 43; l++) { + for (l = 1; l < ARRAYSIZE(inventoryObjects); l++) { out->writeSint32LE(inventoryObjects[l]); }