aboutsummaryrefslogtreecommitdiff
path: root/engines/lure/res.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2008-01-24 08:14:48 +0000
committerPaul Gilbert2008-01-24 08:14:48 +0000
commit2195528ca0cdf8b83af38d94562b488f4f230b32 (patch)
treed96604c1e0e6ac25fd5f28ee2f0b46eef45cbb67 /engines/lure/res.cpp
parent5ca95f9d65d0269eb2a20cb076243c3c2fef15fa (diff)
downloadscummvm-rg350-2195528ca0cdf8b83af38d94562b488f4f230b32.tar.gz
scummvm-rg350-2195528ca0cdf8b83af38d94562b488f4f230b32.tar.bz2
scummvm-rg350-2195528ca0cdf8b83af38d94562b488f4f230b32.zip
Got rid of the experimental NPC Schedule store in favour of moving the NPC schedules from the active hotspot class back into the hotspot data class, similiar to how the original game implements them
svn-id: r30629
Diffstat (limited to 'engines/lure/res.cpp')
-rw-r--r--engines/lure/res.cpp85
1 files changed, 51 insertions, 34 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index 78ae7ec87f..a957fcf22f 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -98,7 +98,6 @@ void Resources::reset() {
_fieldList.reset();
_barmanLists.reset();
- _hotspotSchedules.clear();
_talkState = TALK_NONE;
_activeTalkData = NULL;
@@ -179,6 +178,35 @@ void Resources::reloadData() {
}
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);
+
+ // Next load up the list of random actions your follower can do in each room
+
+ ++offset;
+ while (READ_LE_UINT16(offset) != 0xffff) {
+ RandomActionSet *actionSet = new RandomActionSet(offset);
+ _randomActions.push_back(actionSet);
+ }
+
+ // 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 hotspot list
mb = d.getEntry(HOTSPOT_DATA_RESOURCE_ID);
HotspotResource *hsRec = (HotspotResource *) mb->data();
@@ -314,35 +342,6 @@ void Resources::reloadData() {
}
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);
-
- // Next load up the list of random actions your follower can do in each room
-
- ++offset;
- while (READ_LE_UINT16(offset) != 0xffff) {
- RandomActionSet *actionSet = new RandomActionSet(offset);
- _randomActions.push_back(actionSet);
- }
-
- // 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();
@@ -730,8 +729,21 @@ void Resources::saveToStream(Common::WriteStream *stream) {
// Save basic fields
stream->writeUint16LE(_talkingCharacter);
+ // Save out the schedule for any non-active NPCs
+ HotspotDataList::iterator i;
+ for (i = _hotspotData.begin(); i != _hotspotData.end(); ++i) {
+ HotspotData *rec = *i;
+ if (!rec->npcSchedule.isEmpty()) {
+ Hotspot *h = getActiveHotspot(rec->hotspotId);
+ if (h == NULL) {
+ stream->writeUint16LE(rec->hotspotId);
+ rec->npcSchedule.saveToStream(stream);
+ }
+ }
+ }
+ stream->writeUint16LE(0xffff);
+
// Save sublist data
- _hotspotSchedules.saveToStream(stream);
_hotspotData.saveToStream(stream);
_activeHotspots.saveToStream(stream);
_fieldList.saveToStream(stream);
@@ -756,10 +768,15 @@ void Resources::loadFromStream(Common::ReadStream *stream) {
_talkState = TALK_NONE;
_activeTalkData = NULL;
- _hotspotSchedules.clear();
if (saveVersion >= 31) {
- _hotspotSchedules.loadFromStream(stream);
- debugC(ERROR_DETAILED, kLureDebugScripts, "Loading hotspot schedules");
+ // Load in any schedules for non-active NPCS
+ debugC(ERROR_DETAILED, kLureDebugScripts, "Loading NPC schedules");
+ uint16 hotspotId;
+ while ((hotspotId = stream->readUint16LE()) != 0xffff) {
+ HotspotData *hotspot = getHotspot(hotspotId);
+ assert(hotspot);
+ hotspot->npcSchedule.loadFromStream(stream);
+ }
}
debugC(ERROR_DETAILED, kLureDebugScripts, "Loading hotspot data");