[Scummvm-cvs-logs] SF.net SVN: scummvm:[36144] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Fri Jan 30 13:22:30 CET 2009


Revision: 36144
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36144&view=rev
Author:   dreammaster
Date:     2009-01-30 12:22:30 +0000 (Fri, 30 Jan 2009)

Log Message:
-----------
Bugfix to stop characters changing rooms if the entrance in the other room is blocked by another NPC

Modified Paths:
--------------
    scummvm/trunk/engines/lure/hotspots.cpp
    scummvm/trunk/engines/lure/hotspots.h

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2009-01-30 05:25:17 UTC (rev 36143)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2009-01-30 12:22:30 UTC (rev 36144)
@@ -3159,7 +3159,7 @@
 	}
 
 	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,24 +4511,31 @@
 // 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) {
 		Hotspot &hotspot = **i;
 
 		// 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 @@
 
 // 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 @@
 	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 @@
 			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 @@
 		} 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);
 

Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h	2009-01-30 05:25:17 UTC (rev 36143)
+++ scummvm/trunk/engines/lure/hotspots.h	2009-01-30 12:22:30 UTC (rev 36144)
@@ -41,8 +41,8 @@
 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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list