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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Aug 5 04:56:51 CEST 2007


Revision: 28457
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28457&view=rev
Author:   dreammaster
Date:     2007-08-04 19:56:51 -0700 (Sat, 04 Aug 2007)

Log Message:
-----------
Added code for hotspot fields I didn't originally understand

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

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2007-08-05 01:42:38 UTC (rev 28456)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2007-08-05 02:56:51 UTC (rev 28457)
@@ -689,7 +689,6 @@
 	if (standStill) {
 		setDelayCtr(_data->talkCountdown);
 		_data->characterMode = CHARMODE_CONVERSING;
-		//TODO: HS[3Eh]=character_hotspot_id, HS[40h]=active_hotspot_id
 	}
 }
 
@@ -1332,7 +1331,10 @@
 	faceHotspot(hotspot);
 	endAction();
 
-	// TODO: If character=3E9h, HS[-1]=28h, HS[1Fh]=50h
+	if (hotspotId() == RATPOUCH_ID) {
+		_tempDest.position.x = 40;
+		setFrameCtr(80);
+	}
 
 	uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, USE);
 
@@ -1727,7 +1729,6 @@
 		++tempId;                      // Move over entry's sequence offset
 	}
 	
-	// TODO: call to talk_setup
 	faceHotspot(hotspot);
 	setActionCtr(0);
 	endAction();
@@ -1738,8 +1739,8 @@
 		if (sequenceOffset != 0) return;
 	}
 
-	// TODO: talk_record_index
-	showMessage(sequenceOffset);
+	uint16 talkIndex = res.fieldList().getField(TALK_INDEX);
+	showMessage((talkIndex == 6) ? 0x30 : 0x29);
 }
 
 void Hotspot::doExamine(HotspotData *hotspot) {
@@ -1811,7 +1812,7 @@
 		return;
 	}
 
-	// TODO: Check storage of hotspot Id in data_1090/data_1091=0
+	// TODO: Check storage of hotspot Id in talk_first=player/talk_second=0
 
 	// Get the npc to say "Hey Sir" to player
 	showMessage(0x22, PLAYER_ID);
@@ -2059,6 +2060,9 @@
 	stream->writeSint16LE(_destX);
 	stream->writeSint16LE(_destY);
 	stream->writeUint16LE(_destHotspotId);
+	stream->writeByte(_tempDest.counter);
+	stream->writeSint16LE(_tempDest.position.x);
+	stream->writeSint16LE(_tempDest.position.y);
 	stream->writeUint16LE(_frameWidth);
 	stream->writeUint16LE(_height);
 	stream->writeUint16LE(_width);
@@ -2096,6 +2100,9 @@
 	_destX = stream->readSint16LE();
 	_destY = stream->readSint16LE();
 	_destHotspotId = stream->readUint16LE();
+	_tempDest.counter = stream->readByte();
+	_tempDest.position.x = stream->readSint16LE();
+	_tempDest.position.y = stream->readSint16LE();
 	_frameWidth = stream->readUint16LE();
 	_height = stream->readUint16LE();
 	_width = stream->readUint16LE();
@@ -2227,6 +2234,7 @@
 	RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths;
 	PathFinder &pathFinder = h.pathFinder();
 	CurrentActionStack &actions = h.currentActions();
+	Hotspot *player = res.getActiveHotspot(PLAYER_ID);
 	uint16 impingingList[MAX_NUM_IMPINGING];
 	int numImpinging;
 	bool bumpedPlayer;
@@ -2276,8 +2284,6 @@
 
 		if (numImpinging > 0) {
 			// Scan to check if the character has bumped into player
-			Hotspot *player = res.getActiveHotspot(PLAYER_ID);
-
 			if (bumpedPlayer && (player->characterMode() == CHARMODE_IDLE)) {
 				// Signal the player to move out of the way automatically
 				player->setBlockedState(BS_INITIAL);
@@ -2300,8 +2306,12 @@
 		h.setSkipFlag(false);
 	}
 
-	// TODO: Handling of any set Tick Script Offset, as well as certain other
-	// as of yet unknown hotspot flags
+	if (h.resource()->scriptHotspotId != 0) {
+		// Character bumped against another
+		fields.setField(USE_HOTSPOT_ID, h.resource()->scriptHotspotId);
+		Script::execute(h.resource()->tickScriptOffset);
+		h.resource()->scriptHotspotId = 0;
+	}
 
 	debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 4");
 	if (h.pauseCtr() != 0) {
@@ -2332,13 +2342,14 @@
 			// All other character modes
 			if (h.delayCtr() > 0) {
 				// There is some countdown left to do
-				bool decrementFlag = true; 
+				h.updateMovement();
 
-				if (!decrementFlag) {
-					HotspotData *hotspot = res.getHotspot(0); // TODO: HS[50h]
-					decrementFlag = (hotspot->roomNumber != h.roomNumber()) ? false :
+				bool decrementFlag = (h.resource()->actionHotspotId != 0);
+				if (decrementFlag) {
+					HotspotData *hotspot = res.getHotspot(h.resource()->actionHotspotId);
+					decrementFlag = (hotspot->roomNumber != h.hotspotId()) ? false :
 						Support::charactersIntersecting(hotspot, h.resource());
-				}			
+				}
 
 				if (decrementFlag) {
 					h.setDelayCtr(h.delayCtr() - 1);
@@ -2353,12 +2364,20 @@
 		h.pathFinder().clear();
 
 		if ((currentMode == CHARMODE_WAIT_FOR_PLAYER) || (currentMode == CHARMODE_WAIT_FOR_INTERACT)) {
-			// TODO: HS[33h]=0
+			h.resource()->talkOverride = 0;
 			h.showMessage(1);
 		}
 		return;
 	}
 
+	/* interactHotspotId never seems to be set 
+	if ((h.resource()->interactHotspotId != 0) && !player->currentActions().isEmpty())  {
+		h.setActionCtr(99);
+		if (!actions.isEmpty()) 
+			actions.top().setAction(DISPATCH_ACTION);
+	}
+	*/
+
 	debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6");
 	CurrentAction action = actions.action();
 	PathFinderResult pfResult;
@@ -2567,7 +2586,9 @@
 }
 
 void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) {
-	RoomExitJoinData *rec = Resources::getReference().getExitJoin(h.hotspotId());
+	Resources &res = Resources::getReference();
+	ValueTableData &fields = res.fieldList();
+	RoomExitJoinData *rec = res.getExitJoin(h.hotspotId());
 	if (!rec) return;
 	byte *currentFrame, *destFrame;
 
@@ -2637,8 +2658,18 @@
 			return;
 		h.setSkipFlag(false);
 	}
-	// TODO: HS[58h] check
 
+	/* interactHotspotId never seems to be set 
+	if (h.resource()->interactHotspotId != 0) {
+		h.resource()->interactHotspotId = 0;
+		Hotspot *hotspot = res.getActiveHotspot(h.resource()->interactHotspotId);
+		assert(hotspot);
+		if ((hotspot->characterMode() != CHARMODE_WAIT_FOR_INTERACT) &&
+			!actions.isEmpty())
+			actions.top().setAction(ACTION_NONE);
+	}
+	*/
+
 	if (h.pauseCtr() > 0) {
 		debugC(ERROR_DETAILED, kLureDebugAnimations, "Pause countdown = %d", h.pauseCtr());
 		h.updateMovement();
@@ -2668,10 +2699,10 @@
 		debugC(ERROR_DETAILED, kLureDebugAnimations, "Character mode = %d", h.characterMode());
 		h.setOccupied(false);
 		h.setCharacterMode(CHARMODE_NONE);
-		if (fields.playerPendingPos().isSet) {
+		if (h.tempDest().counter != 0) {
 			// Start walking to the previously set destination
-			fields.playerPendingPos().isSet = false;
-			h.setDestPosition(fields.playerPendingPos().pos.x, fields.playerPendingPos().pos.y);
+			h.tempDest().counter = 0;
+			h.setDestPosition(h.tempDest().position.x, h.tempDest().position.y);
 			h.currentActions().addFront(START_WALKING, h.roomNumber());
 			h.setWalkFlag(false);
 		}
@@ -2753,9 +2784,9 @@
 				return;
 
 			} else if (h.blockedState() != BS_NONE) {
-				fields.playerPendingPos().pos.x = h.destX();
-				fields.playerPendingPos().pos.y = h.destY();
-				fields.playerPendingPos().isSet = true;
+				h.tempDest().position.x = h.destX();
+				h.tempDest().position.y = h.destY();
+				h.tempDest().counter = 1;
 				h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
 				h.setRandomDest();
 				return;
@@ -2795,7 +2826,7 @@
 				// Walking done
 				if (room.cursorState() == CS_BUMPED)
 					room.setCursorState(CS_NONE);
-				if (fields.playerPendingPos().isSet) {
+				if (h.tempDest().counter != 0) {
 					h.setCharacterMode(CHARMODE_PLAYER_WAIT);
 					h.setDelayCtr(IDLE_COUNTDOWN_SIZE);
 					return;
@@ -4474,9 +4505,9 @@
 
 		// TODO: Double-check.. is it impinging in leaving room (right now) or entering room
 		if (checkForIntersectingCharacter(h)) {
-			fields.playerPendingPos().pos.x = h.destX();
-			fields.playerPendingPos().pos.y = h.destY();
-			fields.playerPendingPos().isSet = true;
+			h.tempDest().position.x = h.destX();
+			h.tempDest().position.y = h.destY();
+			h.tempDest().counter = 1;
 			Room::getReference().setCursorState(CS_BUMPED);
 			h.setActionCtr(0);
 			h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));

Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h	2007-08-05 01:42:38 UTC (rev 28456)
+++ scummvm/trunk/engines/lure/hotspots.h	2007-08-05 02:56:51 UTC (rev 28457)
@@ -243,6 +243,11 @@
 
 enum BarPlaceResult {BP_KEEP_TRYING, BP_GOT_THERE, BP_FAIL};
 
+struct DestStructure {
+	uint8 counter;
+	Point position;
+};
+
 #define MAX_NUM_FRAMES 16
 
 class Hotspot {
@@ -277,6 +282,7 @@
 	bool _frameStartsUsed;
 	uint16 _frameStarts[MAX_NUM_FRAMES];
 	char _nameBuffer[MAX_HOTSPOT_NAME_SIZE];
+	DestStructure _tempDest;
 
 	// Runtime fields
 	uint16 _frameCtr;
@@ -516,6 +522,7 @@
 	void doAction(Action action, HotspotData *hotspot);
 	CurrentActionStack &currentActions() { return _currentActions; }
 	PathFinder &pathFinder() { return _pathFinder; }
+	DestStructure &tempDest() { return _tempDest; }
 	uint16 frameCtr() { return _frameCtr; }
 	void setFrameCtr(uint16 value) { _frameCtr = value; }
 	void decrFrameCtr() { if (_frameCtr > 0) --_frameCtr; }

Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp	2007-08-05 01:42:38 UTC (rev 28456)
+++ scummvm/trunk/engines/lure/res_struct.cpp	2007-08-05 02:56:51 UTC (rev 28457)
@@ -466,7 +466,7 @@
 	stream->writeUint16LE(talkCountdown);
 	stream->writeUint16LE(pauseCtr);
 	stream->writeUint16LE(useHotspotId);
-	stream->writeUint16LE(use2HotspotId);
+	stream->writeUint16LE(scriptHotspotId);
 	stream->writeUint16LE(talkGate);
 	stream->writeUint16LE(actionHotspotId);
 	stream->writeUint16LE(talkOverride);
@@ -507,7 +507,7 @@
 	talkCountdown = stream->readUint16LE();
 	pauseCtr = stream->readUint16LE();
 	useHotspotId = stream->readUint16LE();
-	use2HotspotId = stream->readUint16LE();
+	scriptHotspotId = stream->readUint16LE();
 	talkGate = stream->readUint16LE();
 	actionHotspotId = stream->readUint16LE();
 	talkOverride = stream->readUint16LE();
@@ -1119,7 +1119,7 @@
 			if ((charHotspot->characterMode() == CHARMODE_PAUSED) || 
 				((charHotspot->pauseCtr() == 0) && 
 				(charHotspot->characterMode() == CHARMODE_NONE))) {
-				hotspot->resource()->use2HotspotId = charId;
+				hotspot->resource()->scriptHotspotId = charId;
 			}
 
 			hotspot->setPauseCtr(IDLE_COUNTDOWN_SIZE);
@@ -1206,9 +1206,6 @@
 	_playerNewPos.roomNumber = 0;
 	_playerNewPos.position.x = 0;
 	_playerNewPos.position.y = 0;
-	_playerPendingPos.pos.x = 0;
-	_playerPendingPos.pos.y = 0;
-	_playerPendingPos.isSet = false;
 	_flags = GAMEFLAG_4 | GAMEFLAG_1;
 	_hdrFlagMask = 1;
 
@@ -1252,9 +1249,6 @@
 	stream->writeSint16LE(_playerNewPos.position.x);
 	stream->writeSint16LE(_playerNewPos.position.y);
 	stream->writeUint16LE(_playerNewPos.roomNumber);
-	stream->writeByte(_playerPendingPos.isSet);
-	stream->writeSint16LE(_playerPendingPos.pos.x);
-	stream->writeSint16LE(_playerPendingPos.pos.y);
 	stream->writeByte(_flags);
 	stream->writeByte(_hdrFlagMask);
 	
@@ -1270,9 +1264,6 @@
 	_playerNewPos.position.x = stream->readSint16LE();
 	_playerNewPos.position.y = stream->readSint16LE();
 	_playerNewPos.roomNumber = stream->readUint16LE();
-	_playerPendingPos.isSet = stream->readByte() != 0;
-	_playerPendingPos.pos.x = stream->readSint16LE();
-	_playerPendingPos.pos.y = stream->readSint16LE();
 	_flags = stream->readByte();
 	_hdrFlagMask = stream->readByte();
 	

Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h	2007-08-05 01:42:38 UTC (rev 28456)
+++ scummvm/trunk/engines/lure/res_struct.h	2007-08-05 02:56:51 UTC (rev 28457)
@@ -458,9 +458,8 @@
 	uint16 talkGate;
 	uint16 actionHotspotId;
 	uint16 talkOverride;
+	uint16 scriptHotspotId;
 
-	uint16 use2HotspotId;
-
 	void enable() { flags |= 0x80; }
 	void disable() { flags &= 0x7F; }
 	Direction nonVisualDirection() { return (Direction) scriptLoadFlag; }
@@ -817,16 +816,10 @@
 	uint16 roomNumber;
 };
 
-struct PlayerPendingPosition {
-	Point pos;
-	bool isSet;
-};
-
 class ValueTableData {
 private:
 	uint16 _numGroats;
 	PlayerNewPosition _playerNewPos;
-	PlayerPendingPosition _playerPendingPos;
 	uint8 _flags;
 	uint8 _hdrFlagMask;
 
@@ -845,7 +838,6 @@
 	uint8 &flags() { return _flags; }
 	uint8 &hdrFlagMask() { return _hdrFlagMask; }
 	PlayerNewPosition &playerNewPos() { return _playerNewPos; }
-	PlayerPendingPosition &playerPendingPos() { return _playerPendingPos; }
 
 	void saveToStream(Common::WriteStream *stream);
 	void loadFromStream(Common::ReadStream *stream);


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