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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Wed Oct 24 12:09:07 CEST 2007


Revision: 29254
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29254&view=rev
Author:   dreammaster
Date:     2007-10-24 03:09:06 -0700 (Wed, 24 Oct 2007)

Log Message:
-----------
Added a talkerId field to hotspots to better handle characters being talked to

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

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2007-10-24 10:07:38 UTC (rev 29253)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2007-10-24 10:09:06 UTC (rev 29254)
@@ -749,8 +749,8 @@
 		HotspotData *hotspot = Resources::getReference().getHotspot(destCharacterId);
 		_data->talkCountdown += hotspot->talkCountdown;
 		
-		_data->talkDestCharacterId = destCharacterId;
-		_data->talkGate = 0;
+		hotspot->talkerId = _hotspotId ;
+		hotspot->talkGate = 0;
 	}
 
 	if (standStill) {
@@ -811,6 +811,7 @@
 	assert(_data);
 	Resources &res = Resources::getReference();
 	ValueTableData &fields = res.fieldList();
+	Game &game = Game::getReference();
 	Room &room = Room::getReference();
 
 	// Return if no talk dialog is necessary
@@ -840,24 +841,37 @@
 					charHotspot->faceHotspot(resource());
 			}
 		}
-
-	} else if ((fields.flags() & GAMEFLAG_FAST_TEXTSPEED) != 0) {
+/*
+	} else if (game.fastTextFlag()) {
 		// Fast text speed
 		--_data->talkCountdown;
-	} else if ((fields.flags() & (GAMEFLAG_8 | GAMEFLAG_4)) != 0) {
-		fields.flags() |= GAMEFLAG_4;
+	} else if (fields.textCtr2() != 0) {
+		fields.textCtr2() = 1;
 		--_data->talkCountdown;
 	} else {
 		--_data->talkCountdown;
-		fields.flags() -= GAMEFLAG_4;
-	}
+		--fields.textCtr2();
+	}*/
 
-	if (_data->talkCountdown == 0) {
-		// Talking is finish - stop talking and free voice animation
-		debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk dialog close");
-		room.setTalkDialog(0, 0, 0, 0);
-		_data->talkDestCharacterId = 0;
-		_data->talkGate = 0;
+	} else if ((room.talkDialog() != NULL) && (room.talkDialog()->isBuilding())) {
+		return;
+
+	} else if (_data->talkCountdown > 0) {
+		--_data->talkCountdown;
+
+		if (_data->talkCountdown == 0) {
+			// Talking is finish - stop talking and free voice animation
+			debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk dialog close");
+			room.setTalkDialog(0, 0, 0, 0);
+
+			if (_data->talkDestCharacterId != 0) {
+				HotspotData *destChar = res.getHotspot(_data->talkDestCharacterId);
+				destChar->talkerId = 0;
+			}
+
+			_data->talkerId = 0;
+			_data->talkGate = 0;
+		}
 	}
 
 	debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk handler method end");
@@ -2314,16 +2328,15 @@
 	// Handle any active talk dialog
 	h.handleTalkDialog();
 
-	// Handle any active hotspot the character is using (for example, if the player is
-	// talking to a character, this stops them from moving for the duration)
-	if (h.resource()->talkDestCharacterId != 0) {
-		debugC(ERROR_DETAILED, kLureDebugAnimations, "Use Hotspot Id = %xh, talk_gate = %d",
+	// If someone is talking to the character, this stops them from moving for the duration)
+	if (h.resource()->talkerId != 0) {
+		debugC(ERROR_DETAILED, kLureDebugAnimations, "Talker Id = %xh, talk_gate = %d",
 			h.resource()->talkDestCharacterId, h.talkGate());
 		if (h.talkGate() == GENERAL_MAGIC_ID) {
 			fields.setField(ACTIVE_HOTSPOT_ID, h.talkGate());
-			fields.setField(USE_HOTSPOT_ID, h.resource()->talkDestCharacterId);
+			fields.setField(USE_HOTSPOT_ID, h.resource()->talkerId);
 			Script::execute(h.talkScript());
-			h.resource()->talkDestCharacterId = 0;
+			h.resource()->talkerId = 0;
 		} else {
 			h.updateMovement();
 			return;
@@ -3268,7 +3281,7 @@
 
 			// Make sure the dest character holds still while an option is selected
 			HotspotData *destHotspot = res.getHotspot(talkDestCharacter);
-			destHotspot->talkDestCharacterId = h.hotspotId();
+			destHotspot->talkerId = h.hotspotId();
 		} else {
 			res.setTalkState(TALK_RESPOND);
 			res.setTalkSelection(1);
@@ -3486,8 +3499,8 @@
 						h.setFrameCtr(barEntry.currentCustomer->serveFlags);
 						barEntry.currentCustomer->serveFlags &= 0xf8;
 
-					} else if (h.resource()->talkDestCharacterId == 0) {
-						// Player is not currently talking
+					} else if (h.resource()->talkerId == 0) {
+						// Barman is not currently being talked to
 						// Clear entry from list
 						barEntry.currentCustomer->hotspotId = 0;
 						barEntry.currentCustomer->serveFlags = 0;

Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp	2007-10-24 10:07:38 UTC (rev 29253)
+++ scummvm/trunk/engines/lure/res_struct.cpp	2007-10-24 10:09:06 UTC (rev 29254)
@@ -421,6 +421,7 @@
 	blockedFlag = false;
 	coveredFlag = VB_INITIAL;
 	talkMessageId = 0;
+	talkerId = 0;
 	talkDestCharacterId = 0;
 	talkCountdown = 0;
 	useHotspotId = 0;
@@ -462,6 +463,7 @@
 	stream->writeByte((byte)blockedFlag);
 	stream->writeByte((byte)coveredFlag);
 	stream->writeUint16LE(talkMessageId);
+	stream->writeUint16LE(talkerId);
 	stream->writeUint16LE(talkDestCharacterId);
 	stream->writeUint16LE(talkCountdown);
 	stream->writeUint16LE(pauseCtr);
@@ -503,6 +505,7 @@
 	blockedFlag = stream->readByte() != 0;
 	coveredFlag = (VariantBool)stream->readByte();
 	talkMessageId = stream->readUint16LE();
+	talkerId = stream->readUint16LE();
 	talkDestCharacterId = stream->readUint16LE();
 	talkCountdown = stream->readUint16LE();
 	pauseCtr = stream->readUint16LE();
@@ -1203,7 +1206,6 @@
 	_playerNewPos.roomNumber = 0;
 	_playerNewPos.position.x = 0;
 	_playerNewPos.position.y = 0;
-	_flags = GAMEFLAG_4 | GAMEFLAG_1;
 	_hdrFlagMask = 1;    
 
 	for (uint16 index = 0; index < NUM_VALUE_FIELDS; ++index)
@@ -1245,7 +1247,6 @@
 	stream->writeSint16LE(_playerNewPos.position.x);
 	stream->writeSint16LE(_playerNewPos.position.y);
 	stream->writeUint16LE(_playerNewPos.roomNumber);
-	stream->writeByte(_flags);
 	stream->writeByte(_hdrFlagMask);
 	
 	// Write out the special fields
@@ -1259,7 +1260,6 @@
 	_playerNewPos.position.x = stream->readSint16LE();
 	_playerNewPos.position.y = stream->readSint16LE();
 	_playerNewPos.roomNumber = stream->readUint16LE();
-	_flags = stream->readByte();
 	_hdrFlagMask = stream->readByte();
 	
 	// Read in the field list

Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h	2007-10-24 10:07:38 UTC (rev 29253)
+++ scummvm/trunk/engines/lure/res_struct.h	2007-10-24 10:09:06 UTC (rev 29254)
@@ -472,6 +472,7 @@
 	bool blockedFlag;
 	VariantBool coveredFlag;
 	uint16 talkMessageId;
+	uint16 talkerId;
 	uint16 talkDestCharacterId;
 	uint16 talkCountdown;
 	uint16 pauseCtr;
@@ -826,17 +827,6 @@
 	AREA_FLAG = 82
 };
 
-enum GameFlags {
-	GAMEFLAG_1 = 1,
-	GAMEFLAG_2 = 2,
-	GAMEFLAG_4 = 4,
-	GAMEFLAG_8 = 8,
-	GAMEFLAG_10 = 0x10,
-	GAMEFLAG_20 = 0x20,
-	GAMEFLAG_40 = 0x40,
-	GAMEFLAG_FAST_TEXTSPEED = 0x80
-};
-
 struct PlayerNewPosition {
 	Point position;
 	uint16 roomNumber;
@@ -846,7 +836,7 @@
 private:
 	uint16 _numGroats;
 	PlayerNewPosition _playerNewPos;
-	uint8 _flags;
+	uint8 _textCtr1, _textCtr2; // originally 2 2-bit counters
 	uint8 _hdrFlagMask;
 
 	uint16 _fieldList[NUM_VALUE_FIELDS];
@@ -862,7 +852,8 @@
 	int size() { return NUM_VALUE_FIELDS; }
 
 	uint16 &numGroats() { return _numGroats; }
-	uint8 &flags() { return _flags; }
+	uint8 &textCtr1() { return _textCtr1; }
+	uint8 &textCtr2() { return _textCtr2; }
 	uint8 &hdrFlagMask() { return _hdrFlagMask; }
 	PlayerNewPosition &playerNewPos() { return _playerNewPos; }
 

Modified: scummvm/trunk/engines/lure/room.cpp
===================================================================
--- scummvm/trunk/engines/lure/room.cpp	2007-10-24 10:07:38 UTC (rev 29253)
+++ scummvm/trunk/engines/lure/room.cpp	2007-10-24 10:09:06 UTC (rev 29254)
@@ -425,7 +425,7 @@
 		// Make sure the character is still active and in the viewing room
 		Hotspot *talkCharacter = res.getActiveHotspot(res.getTalkingCharacter());
 		if ((talkCharacter != NULL) && (talkCharacter->roomNumber() == _roomNumber)) 
-			_talkDialog->surface().copyTo(&s, _talkDialogX, _talkDialogY);
+			_talkDialog->copyTo(&s, _talkDialogX, _talkDialogY);
 	}
 
 	// Handle showing the status line
@@ -601,6 +601,7 @@
 }
 
 void Room::setTalkDialog(uint16 srcCharacterId, uint16 destCharacterId, uint16 usedId, uint16 stringId) {
+	Resources &res = Resources::getReference();
 	debugC(ERROR_DETAILED, kLureDebugAnimations, "Room::setTalkDialog - char=%xh string=%d",
 		srcCharacterId, stringId);
 
@@ -609,7 +610,16 @@
 		_talkDialog = NULL;
 	}
 
-	Resources &res = Resources::getReference();
+	if (res.getTalkingCharacter() != 0) {
+		// Signal to any talked to character that they're no longer being talked to
+		HotspotData *talkingChar = res.getHotspot(res.getTalkingCharacter());
+		if ((talkingChar->talkDestCharacterId != 0) &&
+			(talkingChar->talkDestCharacterId != NOONE_ID)) {
+			HotspotData *destChar = res.getHotspot(talkingChar->talkDestCharacterId);
+			destChar->talkerId = 0;
+		}
+	}
+
 	res.setTalkingCharacter(srcCharacterId);
 
 	if (srcCharacterId == 0)
@@ -635,6 +645,9 @@
 bool Room::checkInTalkDialog() {
 	// Make sure there is a talk dialog active
 	if (!_talkDialog) return false;
+	
+	// Don't allow dialog close if it's still in progress
+	if (_talkDialog->isBuilding()) return false;
 
 	// Check boundaries
 	Mouse &mouse = Mouse::getReference();

Modified: scummvm/trunk/engines/lure/room.h
===================================================================
--- scummvm/trunk/engines/lure/room.h	2007-10-24 10:07:38 UTC (rev 29253)
+++ scummvm/trunk/engines/lure/room.h	2007-10-24 10:09:06 UTC (rev 29254)
@@ -108,6 +108,7 @@
 	CursorState cursorState() { return _cursorState; }
 	void setShowInfo(bool value) { _showInfo = value; }
 	void setTalkDialog(uint16 srcCharacterId, uint16 destCharacterId, uint16 usedId, uint16 stringId);
+	TalkDialog *talkDialog() { return _talkDialog; }
 	void setCursorState(CursorState state) { _cursorState = state; }
 	bool isDialogActive() { return _talkDialog != NULL; }
 	bool checkInTalkDialog();


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