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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Tue May 23 05:40:06 CEST 2006


Revision: 22580
Author:   dreammaster
Date:     2006-05-23 05:39:39 -0700 (Tue, 23 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22580&view=rev

Log Message:
-----------
Added the loading of NPC schedules

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-05-23 12:38:51 UTC (rev 22579)
+++ scummvm/trunk/engines/lure/res.cpp	2006-05-23 12:39:39 UTC (rev 22580)
@@ -40,7 +40,7 @@
 }
 
 Resources::~Resources() {
-	// Delete any unremoved active hotspots
+	// Free up any loaded data
 	freeData();
 }
 
@@ -52,6 +52,8 @@
 	_animData.clear();
 	_exitJoins.clear();
 	_delayList.clear();
+	_charSchedules.clear();
+	_indexedRoomExitHospots.clear();
 
 	delete _paletteSubset;
 	delete _scriptData;
@@ -59,6 +61,8 @@
 	free(_hotspotScriptData);
 	delete _messagesData;
 	delete _cursors;
+	delete _charOffsets;
+	delete _playerSupportRecord;
 }
 
 struct AnimRecordTemp {
@@ -70,7 +74,7 @@
 	Disk &d = Disk::getReference();
 	MemoryBlock *mb, *paths;
 	uint16 *offset, offsetVal;
-	uint16 recordId;
+	uint16 recordId, startOffset;
 	int ctr;
 
 	// Get the palette subset data
@@ -264,6 +268,35 @@
 	}
 	delete mb;
 
+	// Load the set of NPC schedules
+	mb = d.getEntry(NPC_SCHEDULES_RESOURCE_ID);
+
+	// Load the lookup list of support data indexes used in the script engine
+	numCharOffsets = 0;
+	offset = (uint16 *) mb->data();
+	while (READ_LE_UINT16(offset++) != 0xffff) ++numCharOffsets;
+	_charOffsets = new uint16[numCharOffsets];
+	offset = (uint16 *) mb->data();
+	for (ctr = 0; ctr < numCharOffsets; ++ctr, ++offset) 
+		_charOffsets[ctr] = READ_LE_UINT16(offset);
+
+	// Loop through loading the schedules
+	ctr = 0;
+	while ((startOffset = READ_LE_UINT16(++offset)) != 0xffff) {
+		CharacterScheduleResource *res = (CharacterScheduleResource *) (mb->data() + startOffset);
+		CharacterScheduleSet *newEntry = new CharacterScheduleSet(res, ++ctr);
+		_charSchedules.push_back(newEntry);
+	}
+	delete mb;
+
+	// Load the list of room exit hotspot Ids
+	mb = d.getEntry(EXIT_HOTSPOT_ID_LIST);
+	RoomExitIndexedHotspotResource *indexedRec = (RoomExitIndexedHotspotResource *) mb->data();
+	while (indexedRec->roomNumber != 0) {
+		_indexedRoomExitHospots.push_back(new RoomExitIndexedHotspotData(indexedRec));
+		indexedRec++;
+	}
+
 	// Initialise delay list
 	_delayList.clear();
 
@@ -274,6 +307,7 @@
 	_messagesData = d.getEntry(MESSAGES_LIST_RESOURCE_ID);
 	_talkDialogData = d.getEntry(TALK_DIALOG_RESOURCE_ID);
 
+	_playerSupportRecord = new CharacterScheduleEntry();
 	_activeTalkData = NULL;
 	_currentAction = NONE;
 	_talkState = TALK_NONE;
@@ -460,9 +494,7 @@
 
 		if (loadFlag) {
 			Hotspot *hotspot = addHotspot(hotspotId);
-//			if (res->loadOffset == 0x7167) hotspot->setPersistant(true);
-			// DEBUG - for now only keep certain hotspots active
-			hotspot->setPersistant((res->hotspotId >= 0x3e8) && (res->hotspotId <= 0x3ea));
+			if (res->loadOffset == 0x7167) hotspot->setPersistant(true);
 		}
 	}
 }

Modified: scummvm/trunk/engines/lure/res.h
===================================================================
--- scummvm/trunk/engines/lure/res.h	2006-05-23 12:38:51 UTC (rev 22579)
+++ scummvm/trunk/engines/lure/res.h	2006-05-23 12:39:39 UTC (rev 22580)
@@ -58,10 +58,18 @@
 	TalkHeaderList _talkHeaders;
 	TalkDataList _talkData;
 	SequenceDelayList _delayList;
+public: //**DEBUG**
 	Action _currentAction;
+private:
 	MemoryBlock *_talkDialogData;
 	RoomExitCoordinatesList _coordinateList;
+	CharacterScheduleList _charSchedules;
+	RoomExitIndexedHotspotList _indexedRoomExitHospots;
 
+	int numCharOffsets;
+	uint16 *_charOffsets;
+	CharacterScheduleEntry *_playerSupportRecord;
+
 	TalkData *_activeTalkData;
 	TalkState _talkState;
 	TalkSelections _talkSelections;
@@ -107,6 +115,16 @@
 	SequenceDelayList &delayList() { return _delayList; }
 	MemoryBlock &getTalkDialogData() { return *_talkDialogData; }
 	RoomExitCoordinatesList &coordinateList() { return _coordinateList; }
+	CharacterScheduleList &charSchedules() { return _charSchedules; }
+	RoomExitIndexedHotspotList &exitHotspots() { return _indexedRoomExitHospots; }
+	uint16 getCharOffset(int index) { 
+		if (index >= numCharOffsets) 
+			error("Invalid index %d passed to script engine support data offset list", index);
+		if (index == 1)
+			error("support data list index #1 was referenced - special handlng TODO");
+		return _charOffsets[index]; 
+	}
+	CharacterScheduleEntry *playerSupportRecord() { return _playerSupportRecord; }
 	void copyCursorTo(Surface *s, uint8 cursorNum, int16 x, int16 y);
 
 	uint16 numInventoryItems();
@@ -124,8 +142,11 @@
 
 	void setCurrentAction(Action action) { _currentAction = action; }
 	Action getCurrentAction() { return _currentAction; }
-	const char *getCurrentActionStr() { return actionList[_currentAction]; }
-
+	const char *getCurrentActionStr() { 
+		if (_currentAction > EXAMINE) 
+			error("Invalid current action %d", _currentAction);
+		return actionList[_currentAction]; 
+	}
 	void activateHotspot(uint16 hotspotId);
 	Hotspot *addHotspot(uint16 hotspotId);
 	void addHotspot(Hotspot *hotspot);


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