diff options
author | Paul Gilbert | 2006-05-23 12:39:39 +0000 |
---|---|---|
committer | Paul Gilbert | 2006-05-23 12:39:39 +0000 |
commit | dddaa015dfc5e5d95612f25cae295863f472fa9c (patch) | |
tree | e522b7488ef017ddb81ddfb10c8fe0758a1177f8 | |
parent | 0ebf2be4a4f490f1cf016245a37e325138d0f000 (diff) | |
download | scummvm-rg350-dddaa015dfc5e5d95612f25cae295863f472fa9c.tar.gz scummvm-rg350-dddaa015dfc5e5d95612f25cae295863f472fa9c.tar.bz2 scummvm-rg350-dddaa015dfc5e5d95612f25cae295863f472fa9c.zip |
Added the loading of NPC schedules
svn-id: r22580
-rw-r--r-- | engines/lure/res.cpp | 42 | ||||
-rw-r--r-- | engines/lure/res.h | 25 |
2 files changed, 60 insertions, 7 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index 8305dd28f8..109db12ef3 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -40,7 +40,7 @@ Resources::Resources() { } Resources::~Resources() { - // Delete any unremoved active hotspots + // Free up any loaded data freeData(); } @@ -52,6 +52,8 @@ void Resources::freeData() { _animData.clear(); _exitJoins.clear(); _delayList.clear(); + _charSchedules.clear(); + _indexedRoomExitHospots.clear(); delete _paletteSubset; delete _scriptData; @@ -59,6 +61,8 @@ void Resources::freeData() { free(_hotspotScriptData); delete _messagesData; delete _cursors; + delete _charOffsets; + delete _playerSupportRecord; } struct AnimRecordTemp { @@ -70,7 +74,7 @@ void Resources::reloadData() { 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 @@ 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); + + // 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 @@ void Resources::reloadData() { _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 @@ void Resources::activateHotspot(uint16 hotspotId) { 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); } } } diff --git a/engines/lure/res.h b/engines/lure/res.h index 79b766a06e..798844cc46 100644 --- a/engines/lure/res.h +++ b/engines/lure/res.h @@ -58,9 +58,17 @@ private: 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; @@ -107,6 +115,16 @@ public: 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 @@ public: 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); |