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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Jul 8 10:27:24 CEST 2006


Revision: 23405
Author:   dreammaster
Date:     2006-07-08 01:27:19 -0700 (Sat, 08 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23405&view=rev

Log Message:
-----------
Added extra checking and debugging code, as well as partial rewrite/enhancement of talking and hotspot support methods

Modified Paths:
--------------
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/res.h
Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2006-07-08 08:25:27 UTC (rev 23404)
+++ scummvm/trunk/engines/lure/res.cpp	2006-07-08 08:27:19 UTC (rev 23405)
@@ -54,6 +54,7 @@
 	_delayList.clear();
 	_charSchedules.clear();
 	_indexedRoomExitHospots.clear();
+	_pausedList.clear();
 
 	delete _paletteSubset;
 	delete _scriptData;
@@ -91,7 +92,7 @@
 		if (offsetVal != 0) {
 			// Get room resource
 			RoomResource *rec = (RoomResource *) (mb->data() + offsetVal);
-			
+
 			RoomData *newEntry = new RoomData(rec, paths);
 			_roomData.push_back(newEntry);
 
@@ -313,6 +314,7 @@
 	_talkState = TALK_NONE;
 	_talkSelection = 0;
 	_talkStartEntry = 0;
+	_talkDetails.active = false;
 }
 
 RoomExitJoinData *Resources::getExitJoin(uint16 hotspotId) {
@@ -346,7 +348,6 @@
 bool Resources::checkHotspotExtent(HotspotData *hotspot) {
 	uint16 roomNum = hotspot->roomNumber;
 	RoomData *room = getRoom(roomNum);
-	
 	return (hotspot->startX >= room->clippingXStart) && ((room->clippingXEnd == 0) || 
 			(hotspot->startX + 32 < room->clippingXEnd));
 }
@@ -420,16 +421,21 @@
 	return _actionsList.getActions(actionsOffset);
 }
 
-void Resources::setTalkingCharacter(uint16 id) { 
-	if (_talkingCharacter != 0)
+void Resources::setTalkingCharacter(uint16 id) {
+	Resources &res = Resources::getReference();
+
+	if (_talkingCharacter != 0) {
 		deactivateHotspot(_talkingCharacter, true);
+		HotspotData *charHotspot = res.getHotspot(_talkingCharacter);
+		assert(charHotspot);
+		charHotspot->talkCountdown = 0;
+	}
 
 	_talkingCharacter = id; 
 	
 	if (_talkingCharacter != 0) {
 		Hotspot *character = getActiveHotspot(id);
-		if (!character)
-			error("Set talking character to non-active hotspot id");
+		assert(character);
 
 		// Add the special "voice" animation above the character
 		Hotspot *hotspot = new Hotspot(character, VOICE_ANIM_ID);
@@ -437,23 +443,18 @@
 	}
 }
 
-void Resources::activateHotspot(uint16 hotspotId) {
+Hotspot *Resources::activateHotspot(uint16 hotspotId) {
 	HotspotData *res = getHotspot(hotspotId);
-	if (!res) return;
+	if (!res) return NULL;
 	res->roomNumber &= 0x7fff; // clear any suppression bit in room #
 
 	// Make sure that the hotspot isn't already active
 	HotspotList::iterator i = _activeHotspots.begin();
-	bool found = false;
-
 	for (; i != _activeHotspots.end(); ++i) {
-		Hotspot &h = *i.operator*();
-		if (h.hotspotId() == res->hotspotId) {
-			found = true;
-			break;
-		}
+		Hotspot *h = *i;
+		if (h->hotspotId() == res->hotspotId) 
+			return h;
 	}
-	if (found) return;
 
 	// Check the script load flag
 	if (res->scriptLoadFlag) {
@@ -494,14 +495,21 @@
 
 		if (loadFlag) {
 			Hotspot *hotspot = addHotspot(hotspotId);
+			assert(hotspot);
 			if (res->loadOffset == 0x7167) hotspot->setPersistant(true);
+			return hotspot;
 		}
 	}
+
+	return NULL;
 }
 
 Hotspot *Resources::addHotspot(uint16 hotspotId) {
-	Hotspot *hotspot = new Hotspot(getHotspot(hotspotId));
+	HotspotData *hData = getHotspot(hotspotId);
+	assert(hData);
+	Hotspot *hotspot = new Hotspot(hData);
 	_activeHotspots.push_back(hotspot);
+
 	return hotspot;
 }
 
@@ -524,6 +532,20 @@
 	}
 }
 
+void Resources::deactivateHotspot(Hotspot *hotspot) {
+	HotspotList::iterator i = _activeHotspots.begin();
+
+	while (i != _activeHotspots.end()) {
+		Hotspot *h = *i;
+		if (h == hotspot) {
+			_activeHotspots.erase(i);
+			break;
+		}
+		
+		i++;
+	}
+}
+
 uint16 Resources::numInventoryItems() {
 	uint16 numItems = 0;
 	HotspotDataList &list = _hotspotData;

Modified: scummvm/trunk/engines/lure/res.h
===================================================================
--- scummvm/trunk/engines/lure/res.h	2006-07-08 08:25:27 UTC (rev 23404)
+++ scummvm/trunk/engines/lure/res.h	2006-07-08 08:27:19 UTC (rev 23405)
@@ -32,12 +32,17 @@
 
 namespace Lure {
 
-enum TalkState {TALK_NONE, TALK_SELECT, TALK_RESPOND, TALK_RESPONSE_WAIT,
+enum TalkState {TALK_NONE, TALK_START, TALK_SELECT, TALK_RESPOND, TALK_RESPONSE_WAIT,
 	TALK_RESPOND_2};
 
 #define MAX_TALK_SELECTIONS 4
 typedef TalkEntryData *TalkSelections[MAX_TALK_SELECTIONS];
 
+struct TalkDialogDetails {
+	Common::Rect bounds;
+	bool active;
+};
+
 class Resources {
 private:
 	Common::RandomSource _rnd;
@@ -58,13 +63,12 @@
 	TalkHeaderList _talkHeaders;
 	TalkDataList _talkData;
 	SequenceDelayList _delayList;
-public: //**DEBUG**
 	Action _currentAction;
-private:
 	MemoryBlock *_talkDialogData;
 	RoomExitCoordinatesList _coordinateList;
 	CharacterScheduleList _charSchedules;
 	RoomExitIndexedHotspotList _indexedRoomExitHospots;
+	PausedCharacterList _pausedList;
 
 	int numCharOffsets;
 	uint16 *_charOffsets;
@@ -73,6 +77,7 @@
 	TalkData *_activeTalkData;
 	TalkState _talkState;
 	TalkSelections _talkSelections;
+	TalkDialogDetails _talkDetails;
 	int _talkSelection;
 	int _talkStartEntry;
 	uint16 _talkingCharacter;
@@ -117,6 +122,7 @@
 	RoomExitCoordinatesList &coordinateList() { return _coordinateList; }
 	CharacterScheduleList &charSchedules() { return _charSchedules; }
 	RoomExitIndexedHotspotList &exitHotspots() { return _indexedRoomExitHospots; }
+	PausedCharacterList &pausedList() { return _pausedList; }
 	uint16 getCharOffset(int index) { 
 		if (index >= numCharOffsets) 
 			error("Invalid index %d passed to script engine support data offset list", index);
@@ -133,6 +139,7 @@
 	void setTalkState(TalkState state) { _talkState = state; }
 	TalkState getTalkState() { return _talkState; }
 	TalkSelections &getTalkSelections() { return _talkSelections; }	
+	TalkDialogDetails &getTalkDetails() { return _talkDetails; }
 	void setTalkSelection(int index) { _talkSelection = index; }
 	int getTalkSelection() { return _talkSelection; }
 	void setTalkStartEntry(int index) { _talkStartEntry = index; }
@@ -147,10 +154,11 @@
 			error("Invalid current action %d", _currentAction);
 		return actionList[_currentAction]; 
 	}
-	void activateHotspot(uint16 hotspotId);
+	Hotspot *activateHotspot(uint16 hotspotId);
 	Hotspot *addHotspot(uint16 hotspotId);
 	void addHotspot(Hotspot *hotspot);
 	void deactivateHotspot(uint16 hotspotId, bool isDestId = false);
+	void deactivateHotspot(Hotspot *hotspot);
 };
 
 } // End of namespace Lure


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