DRASCULA: Fix invalid memory access on inventory screen

When clicking outside of all inventory objects, the whichObject()
function would return 43, which is an invalid inventoryObjects[]
index. I think that's what caused it to crash for me. There are a
few other inventoryObjects[]-related changes as well.

svn-id: r52843
This commit is contained in:
Torbjörn Andersson 2010-09-21 17:18:32 +00:00
parent ca767d5913
commit 88e25e6f25
3 changed files with 12 additions and 12 deletions

View file

@ -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() {