aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lure/hotspots.cpp47
-rw-r--r--engines/lure/hotspots.h4
2 files changed, 31 insertions, 20 deletions
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index 4d1f8662cc..969d8215fb 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -3159,7 +3159,7 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
}
if (scheduleId == 0) {
- // No special schedule to perform, so simply set a random action
+ // No special schedule to perform, so simply set a random destination
h.setRandomDest();
} else {
// Prepare the follower to standard the specified schedule
@@ -4511,16 +4511,23 @@ void PathFinder::loadFromStream(Common::ReadStream *stream) {
// finds a list of character animations whose base area are impinging
// that of the specified character (ie. are bumping into them)
-int Support::findIntersectingCharacters(Hotspot &h, uint16 *charList) {
+int Support::findIntersectingCharacters(Hotspot &h, uint16 *charList, int16 xp, int16 yp, int roomNumber) {
int numImpinging = 0;
Resources &res = Resources::getReference();
Rect r;
uint16 hotspotY;
- r.left = h.x();
- r.right = h.x() + h.widthCopy();
- r.top = h.y() + h.heightCopy() - h.yCorrection() - h.charRectY();
- r.bottom = h.y() + h.heightCopy() + h.charRectY();
+ // If a specific x/y/room isn't provided, use the specified hotspot's current location
+ if (roomNumber == -1) {
+ xp = h.x();
+ yp = h.y();
+ roomNumber = h.roomNumber();
+ }
+
+ r.left = xp;
+ r.right = xp + h.widthCopy();
+ r.top = yp + h.heightCopy() - h.yCorrection() - h.charRectY();
+ r.bottom = yp + h.heightCopy() + h.charRectY();
HotspotList::iterator i;
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
@@ -4528,7 +4535,7 @@ int Support::findIntersectingCharacters(Hotspot &h, uint16 *charList) {
// Check for basic reasons to skip checking the animation
if ((h.hotspotId() == hotspot.hotspotId()) || (hotspot.layer() == 0) ||
- (h.roomNumber() != hotspot.roomNumber()) ||
+ (roomNumber != hotspot.roomNumber()) ||
(hotspot.hotspotId() >= FIRST_NONCHARACTER_ID) ||
hotspot.skipFlag()) continue;
// TODO: See why si+ANIM_HOTSPOT_OFFSET compared aganst di+ANIM_VOICE_CTR
@@ -4551,9 +4558,9 @@ int Support::findIntersectingCharacters(Hotspot &h, uint16 *charList) {
// Returns true if any other characters are intersecting the specified one
-bool Support::checkForIntersectingCharacter(Hotspot &h) {
+bool Support::checkForIntersectingCharacter(Hotspot &h, int16 xp, int16 yp, int roomNumber) {
uint16 tempList[MAX_NUM_IMPINGING];
- return findIntersectingCharacters(h, tempList) != 0;
+ return findIntersectingCharacters(h, tempList, xp, yp, roomNumber) != 0;
}
// Check whether a character needs to change the room they're in
@@ -4587,15 +4594,11 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
if (h.hotspotId() == PLAYER_ID) {
// Room change code for the player
if (room.cursorState() != CS_NONE) return;
-
- h.setDirection(dir);
PlayerNewPosition &p = fields.playerNewPos();
- p.roomNumber = roomNumber;
- p.position.x = newX;
- p.position.y = newY - 48;
- // TODO: Double-check.. is it impinging in leaving room (right now) or entering room
- if (checkForIntersectingCharacter(h)) {
+ if (checkForIntersectingCharacter(h, newX, newY - 48, roomNumber)) {
+ // Another character is blocking the exit in the other room, so set the player to
+ // temporarily move to a random destination in the current room
h.tempDest().position.x = h.destX();
h.tempDest().position.y = h.destY();
h.tempDest().counter = 1;
@@ -4605,12 +4608,20 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
h.setDestHotspot(0);
h.setRandomDest();
p.roomNumber = 0;
+ } else {
+ // Flag the new location to move the player to (which will be handled by the outer game loop)
+ h.setDirection(dir);
+ p.roomNumber = roomNumber;
+ p.position.x = newX;
+ p.position.y = newY - 48;
}
} else {
// Any other character changing room
+ newX = (newX & 0xfff8) | 5;
+ newY = (newY - h.heightCopy()) & 0xfff8;
- if (checkForIntersectingCharacter(h)) {
+ if (checkForIntersectingCharacter(h, newX, newY, roomNumber)) {
// Character is blocked, so add a handler for handling it
uint16 dataId = res.getCharOffset(0);
CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId);
@@ -4618,7 +4629,7 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
} else {
// Handle character room change
h.setRoomNumber(roomNumber);
- h.setPosition((newX & 0xfff8) | 5, (newY - h.heightCopy()) & 0xfff8);
+ h.setPosition(newX, newY);
h.setSkipFlag(true);
h.setDirection(dir);
diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h
index c6bc56a94d..538f392138 100644
--- a/engines/lure/hotspots.h
+++ b/engines/lure/hotspots.h
@@ -41,8 +41,8 @@ class Support {
private:
static bool changeRoomCheckBumped(Hotspot &h);
public:
- static int findIntersectingCharacters(Hotspot &h, uint16 *charList);
- static bool checkForIntersectingCharacter(Hotspot &h);
+ static int findIntersectingCharacters(Hotspot &h, uint16 *charList, int16 xp = -1, int16 yp = -1, int roomNumber = -1);
+ static bool checkForIntersectingCharacter(Hotspot &h, int16 xp = -1, int16 yp = -1, int roomNumber = -1);
static bool checkRoomChange(Hotspot &h);
static void characterChangeRoom(Hotspot &h, uint16 roomNumber,
int16 newX, int16 newY, Direction dir);