From 7522d4ea51201b8c234725adcb60e9348a0e9021 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 11 Jun 2007 01:22:45 +0000 Subject: Fix for stacked objects in IHNM. It is now possible to interact with the chalk in Ted's chapter svn-id: r27337 --- engines/saga/actor.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index f108820136..57cbcb77cc 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -1671,6 +1671,20 @@ uint16 Actor::hitTest(const Point &testPoint, bool skipProtagonist) { // fine to interact with. For example, the door entrance at the glass // makers's house in ITE's ferret village. + // Note that in IHNM, there are some items that overlap on other items + // Since we're checking the draw list from the FIRST item drawn to the + // LAST one, sometimes the object drawn first is incorrectly returned. + // An example is the chalk on the magic circle in Ted's chapter, which + // is drawn AFTER the circle, but HitTest incorrectly returns the circle + // id in this case, even though the chalk was drawn after the circle. + // Therefore, for IHNM, we iterate through the whole draw list and + // return the last match found, not the first one. + // Unfortunately, it is only possible to search items in the sorted draw + // list from start to end, not reverse, so it's necessary to search + // through the whole list to get the item drawn last + + uint16 result = ID_NOTHING; + if (!_vm->_scene->getSceneClip().contains(testPoint)) return ID_NOTHING; @@ -1690,10 +1704,12 @@ uint16 Actor::hitTest(const Point &testPoint, bool skipProtagonist) { continue; } if (_vm->_sprite->hitTest(*spriteList, frameNumber, drawObject->_screenPosition, drawObject->_screenScale, testPoint)) { - return drawObject->_id; + result = drawObject->_id; + if (_vm->getGameType() == GType_ITE) + return result; // in ITE, return the first result found (read above) } } - return ID_NOTHING; + return result; // in IHNM, return the last result found (read above) } void Actor::createDrawOrderList() { -- cgit v1.2.3