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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Fri Feb 9 11:56:32 CET 2007


Revision: 25440
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25440&view=rev
Author:   dreammaster
Date:     2007-02-09 02:56:31 -0800 (Fri, 09 Feb 2007)

Log Message:
-----------
Improved character blocked/bumped handling

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

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2007-02-09 10:54:55 UTC (rev 25439)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2007-02-09 10:56:31 UTC (rev 25440)
@@ -984,7 +984,12 @@
 
 void Hotspot::doNothing(HotspotData *hotspot) {
 	_currentActions.pop();
-	if (hotspotId() == PLAYER_ID) {
+	if (!_currentActions.isEmpty())
+	{
+		setBlockedFlag(false);
+		currentActions().top().setAction(DISPATCH_ACTION);
+	}
+	else if (hotspotId() == PLAYER_ID) {
 		Room::getReference().setCursorState(CS_NONE);
 	}
 }
@@ -1322,6 +1327,7 @@
 			CharacterScheduleEntry &cmdData = _currentActions.top().supportData();
 			character->setStartRoomNumber(character->roomNumber());
 			character->currentActions().clear();
+			character->setBlockedFlag(false);
 
 			for (int index = 1; index < cmdData.numParams(); index += 3) {
 				character->currentActions().addBack((Action) cmdData.param(index),
@@ -1969,6 +1975,8 @@
 		debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character p=(%d,%d,%d) bs=%d\n%s", 
 			h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer);
 	}
+	if (h.hotspotId() == 1005)
+		printf("XYZZY Woozy\n");
 
 	// Handle any active talk dialog
 	h.handleTalkDialog();
@@ -2091,13 +2099,13 @@
 		}
 		return;
 	}
-//loc_1040
+
 	debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6");
 	CurrentAction action = actions.action();
 
 	switch (action) {
 	case NO_ACTION:
-		// TODO: HS[44h]=2, update movement
+		h.setCharacterMode(CHARMODE_IDLE);
 		break;
 
 	case DISPATCH_ACTION:
@@ -2163,35 +2171,43 @@
 			h.currentActions().top().setAction(WALKING);
 			h.setPosition(h.x(), h.y() & 0xfff8);
 		} else if (h.blockedState() == BS_FINAL) {
-			debugC(ERROR_DETAILED, kLureDebugAnimations, "BS_FINAL result handling");
+			// If this point is reached, the character twice hasn't found a walking path
+			debugC(ERROR_DETAILED, kLureDebugAnimations, "Character is hopelessly blocked");
 
 			res.pausedList().reset(h.hotspotId());
 			h.updateMovement();
+
 			assert(!h.currentActions().isEmpty());
 			h.currentActions().pop();
 
-			// TODO: HS[4Dh] = 0
+			h.setBlockedFlag(false);
 			h.setBlockedState(BS_NONE);
 			h.setCharacterMode(CHARMODE_PAUSED);
 			h.setDelayCtr(2);
 
-			assert(!h.currentActions().isEmpty());
-			if (h.roomNumber() != h.currentActions().top().roomNumber())
+			if (h.currentActions().isEmpty() || 
+				(h.currentActions().top().roomNumber() != h.roomNumber()))
 				h.setDestHotspot(0xffff);
 
 			if (bumpedPlayer)
 				h.setCharacterMode(CHARMODE_6);
+
 		} else {
-			debugC(ERROR_DETAILED, kLureDebugAnimations, "Non-standard result handling");
+			debugC(ERROR_DETAILED, kLureDebugAnimations, "Character is blocked from moving");
 			CharacterScheduleEntry *newEntry = res.charSchedules().getEntry(RETURN_SUPPORT_ID);
 			assert(newEntry);
-
+			
+			// Increment the blocked state 
 			h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
+			if (!h.blockedFlag())
+			{
+				// Not already handling blocked, so add a new dummy action so that the new
+				// action set below will not replace the existing one
+				h.currentActions().addFront(DISPATCH_ACTION, 0);
+				h.setBlockedFlag(true);
+			}
 
-			// TODO: Figure out usage of HS[4Dh] == 0
-			if (1)
-				h.currentActions().addFront(DISPATCH_ACTION, h.roomNumber());
-
+			// Set the current action
 			CurrentActionEntry &entry = h.currentActions().top();
 			entry.setAction(DISPATCH_ACTION);
 			entry.setSupportData(newEntry);
@@ -2943,8 +2959,10 @@
 		if (HotspotScript::execute(&h)) {
 			h.setLayer(255);
 			res.deactivateHotspot(h.hotspotId());
+
+			HotspotData *ratpouchData = res.getHotspot(RATPOUCH_ID);
+			ratpouchData->roomNumber = 4;
 			Hotspot *newHotspot = res.activateHotspot(RATPOUCH_ID);
-			newHotspot->setRoomNumber(4);
 			newHotspot->converse(PLAYER_ID, 0x9C, true);
 		}
 		break;
@@ -3020,9 +3038,8 @@
 
 		if (joinRec->blocked) {
 			// The room exit is blocked - so add an opening action
-			CharacterScheduleEntry &entry = h.npcSupportData();
-			entry.setDetails(OPEN, h.destHotspotId());
-			h.currentActions().addFront(DISPATCH_ACTION, &entry, h.roomNumber());
+			h.currentActions().addFront(OPEN, h.roomNumber(), h.destHotspotId(), 0);
+			h.setBlockedFlag(false);
 			return;
 		}
 	}
@@ -3461,6 +3478,7 @@
 }
 
 CurrentActionEntry::CurrentActionEntry(CurrentAction newAction, CharacterScheduleEntry *data, uint16 roomNum) { 
+	assert(data->parent() != NULL);
 	_action = newAction; 
 	_supportData = data; 
 	_dynamicSupportData = false;
@@ -3469,6 +3487,7 @@
 
 CurrentActionEntry::CurrentActionEntry(Action newAction, uint16 roomNum, uint16 param1, uint16 param2) {
 	_action = DISPATCH_ACTION;
+	_dynamicSupportData = true;
 	_supportData = new CharacterScheduleEntry();
 	uint16 params[2] = {param1, param2};
 	_supportData->setDetails2(newAction, 2, params);
@@ -3704,6 +3723,7 @@
 	RoomExitData *exitRec = roomData->exits.checkExits(x, y);
 
 	if (exitRec) {
+		// End the current walking sequence
 		if (exitRec->sequenceOffset != 0xffff) {
 			Script::execute(exitRec->sequenceOffset);
 		} else {

Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h	2007-02-09 10:54:55 UTC (rev 25439)
+++ scummvm/trunk/engines/lure/hotspots.h	2007-02-09 10:56:31 UTC (rev 25440)
@@ -102,7 +102,10 @@
 	uint16 roomNumber() { return _roomNumber; }
 	void setAction(CurrentAction newAction) { _action = newAction; }
 	void setRoomNumber(uint16 roomNum) { _roomNumber = roomNum; }
-	void setSupportData(CharacterScheduleEntry *newRec) { _supportData = newRec; }
+	void setSupportData(CharacterScheduleEntry *newRec) { 
+		assert((newRec == NULL) || (newRec->parent() != NULL));
+		_supportData = newRec; 
+	}
 	void setSupportData(uint16 entryId);
 
 	void saveToStream(WriteStream *stream);
@@ -241,7 +244,6 @@
 	HotspotOverrideData *_override;
 	bool _skipFlag;
 	CurrentActionStack _currentActions;
-	CharacterScheduleEntry _npcSupportData;
 	PathFinder _pathFinder;
 	uint16 _frameWidth;
 	bool _frameStartsUsed;
@@ -367,6 +369,14 @@
 		assert(_data);
 		_data->blockedState = newState; 
 	}
+	bool blockedFlag() {
+		assert(_data);
+		return _data->blockedFlag;
+	}
+	void setBlockedFlag(bool newValue) {
+		assert(_data);
+		_data->blockedFlag = newValue;
+	}
 	void setWalkFlag(bool value) { _walkFlag = value; }
 	void setStartRoomNumber(uint16 value) { _startRoomNumber = value; }
 	void setSize(uint16 newWidth, uint16 newHeight);
@@ -454,7 +464,6 @@
 	void doAction();
 	void doAction(Action action, HotspotData *hotspot);
 	CurrentActionStack &currentActions() { return _currentActions; }
-	CharacterScheduleEntry &npcSupportData() { return _npcSupportData; }
 	PathFinder &pathFinder() { return _pathFinder; }
 	uint16 frameCtr() { return _frameCtr; }
 	void setFrameCtr(uint16 value) { _frameCtr = value; }

Modified: scummvm/trunk/engines/lure/scripts.cpp
===================================================================
--- scummvm/trunk/engines/lure/scripts.cpp	2007-02-09 10:54:55 UTC (rev 25439)
+++ scummvm/trunk/engines/lure/scripts.cpp	2007-02-09 10:56:31 UTC (rev 25440)
@@ -395,7 +395,9 @@
 	CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId);
 
 	Hotspot *h = res.getActiveHotspot(hotspotId);
+	h->setBlockedFlag(false);
 	h->currentActions().addFront(DISPATCH_ACTION, entry, h->roomNumber());
+	h->setActionCtr(0);
 }
 
 // Replaces the existing current action with a new dispatch data entry
@@ -553,8 +555,8 @@
 	"SET CHAR SPEAKING TO ITSELF",
 
 	"CHECK CELL DOOR", "PLAY MUSIC", "IS DOOR BLOCKED", "IS SKORL IN CELL",
-	NULL, NULL, NULL, "SET BLOCKING HOTSPOT SCRIPT", "DECREMENT # INVENTORY ITEMS",
-	"SET TALKING",
+	"PUSH BRICKS", "CHARACTER CHANGE ROOM", "PAUSE RATPOUCH", "SET BLOCKING HOTSPOT SCRIPT", 
+	"DECREMENT # INVENTORY ITEMS", "SET TALKING",
 
 	"SET ACTION CTR", "START SPEAKING", "DISABLE HOTSPOT", "CUT SACK",
 	"INCREASE # GROATS", "ENABLE HOTSPOT", NULL, "TRANSFORM PLAYER",


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