diff options
author | Paul Gilbert | 2007-08-05 02:56:51 +0000 |
---|---|---|
committer | Paul Gilbert | 2007-08-05 02:56:51 +0000 |
commit | d03e3e9c870a7d0d28c6e43ee3f0fe0af2a4847d (patch) | |
tree | 38ce2911b264007a0abfca6b95775104b3bfd0bb | |
parent | d31d50ac3dbf5c12b126b4d26ba2cd15e7057dcc (diff) | |
download | scummvm-rg350-d03e3e9c870a7d0d28c6e43ee3f0fe0af2a4847d.tar.gz scummvm-rg350-d03e3e9c870a7d0d28c6e43ee3f0fe0af2a4847d.tar.bz2 scummvm-rg350-d03e3e9c870a7d0d28c6e43ee3f0fe0af2a4847d.zip |
Added code for hotspot fields I didn't originally understand
svn-id: r28457
-rw-r--r-- | engines/lure/hotspots.cpp | 87 | ||||
-rw-r--r-- | engines/lure/hotspots.h | 7 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 15 | ||||
-rw-r--r-- | engines/lure/res_struct.h | 10 |
4 files changed, 70 insertions, 49 deletions
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 82b4725a70..b4ade06bd4 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -689,7 +689,6 @@ void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool standStill if (standStill) { setDelayCtr(_data->talkCountdown); _data->characterMode = CHARMODE_CONVERSING; - //TODO: HS[3Eh]=character_hotspot_id, HS[40h]=active_hotspot_id } } @@ -1332,7 +1331,10 @@ void Hotspot::doUse(HotspotData *hotspot) { faceHotspot(hotspot); endAction(); - // TODO: If character=3E9h, HS[-1]=28h, HS[1Fh]=50h + if (hotspotId() == RATPOUCH_ID) { + _tempDest.position.x = 40; + setFrameCtr(80); + } uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, USE); @@ -1727,7 +1729,6 @@ void Hotspot::doBribe(HotspotData *hotspot) { ++tempId; // Move over entry's sequence offset } - // TODO: call to talk_setup faceHotspot(hotspot); setActionCtr(0); endAction(); @@ -1738,8 +1739,8 @@ void Hotspot::doBribe(HotspotData *hotspot) { if (sequenceOffset != 0) return; } - // TODO: talk_record_index - showMessage(sequenceOffset); + uint16 talkIndex = res.fieldList().getField(TALK_INDEX); + showMessage((talkIndex == 6) ? 0x30 : 0x29); } void Hotspot::doExamine(HotspotData *hotspot) { @@ -1811,7 +1812,7 @@ void Hotspot::npcHeySir(HotspotData *hotspot) { return; } - // TODO: Check storage of hotspot Id in data_1090/data_1091=0 + // TODO: Check storage of hotspot Id in talk_first=player/talk_second=0 // Get the npc to say "Hey Sir" to player showMessage(0x22, PLAYER_ID); @@ -2059,6 +2060,9 @@ void Hotspot::saveToStream(Common::WriteStream *stream) { stream->writeSint16LE(_destX); stream->writeSint16LE(_destY); stream->writeUint16LE(_destHotspotId); + stream->writeByte(_tempDest.counter); + stream->writeSint16LE(_tempDest.position.x); + stream->writeSint16LE(_tempDest.position.y); stream->writeUint16LE(_frameWidth); stream->writeUint16LE(_height); stream->writeUint16LE(_width); @@ -2096,6 +2100,9 @@ void Hotspot::loadFromStream(Common::ReadStream *stream) { _destX = stream->readSint16LE(); _destY = stream->readSint16LE(); _destHotspotId = stream->readUint16LE(); + _tempDest.counter = stream->readByte(); + _tempDest.position.x = stream->readSint16LE(); + _tempDest.position.y = stream->readSint16LE(); _frameWidth = stream->readUint16LE(); _height = stream->readUint16LE(); _width = stream->readUint16LE(); @@ -2227,6 +2234,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths; PathFinder &pathFinder = h.pathFinder(); CurrentActionStack &actions = h.currentActions(); + Hotspot *player = res.getActiveHotspot(PLAYER_ID); uint16 impingingList[MAX_NUM_IMPINGING]; int numImpinging; bool bumpedPlayer; @@ -2276,8 +2284,6 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { if (numImpinging > 0) { // Scan to check if the character has bumped into player - Hotspot *player = res.getActiveHotspot(PLAYER_ID); - if (bumpedPlayer && (player->characterMode() == CHARMODE_IDLE)) { // Signal the player to move out of the way automatically player->setBlockedState(BS_INITIAL); @@ -2300,8 +2306,12 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { h.setSkipFlag(false); } - // TODO: Handling of any set Tick Script Offset, as well as certain other - // as of yet unknown hotspot flags + if (h.resource()->scriptHotspotId != 0) { + // Character bumped against another + fields.setField(USE_HOTSPOT_ID, h.resource()->scriptHotspotId); + Script::execute(h.resource()->tickScriptOffset); + h.resource()->scriptHotspotId = 0; + } debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 4"); if (h.pauseCtr() != 0) { @@ -2332,13 +2342,14 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { // All other character modes if (h.delayCtr() > 0) { // There is some countdown left to do - bool decrementFlag = true; + h.updateMovement(); - if (!decrementFlag) { - HotspotData *hotspot = res.getHotspot(0); // TODO: HS[50h] - decrementFlag = (hotspot->roomNumber != h.roomNumber()) ? false : + bool decrementFlag = (h.resource()->actionHotspotId != 0); + if (decrementFlag) { + HotspotData *hotspot = res.getHotspot(h.resource()->actionHotspotId); + decrementFlag = (hotspot->roomNumber != h.hotspotId()) ? false : Support::charactersIntersecting(hotspot, h.resource()); - } + } if (decrementFlag) { h.setDelayCtr(h.delayCtr() - 1); @@ -2353,12 +2364,20 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { h.pathFinder().clear(); if ((currentMode == CHARMODE_WAIT_FOR_PLAYER) || (currentMode == CHARMODE_WAIT_FOR_INTERACT)) { - // TODO: HS[33h]=0 + h.resource()->talkOverride = 0; h.showMessage(1); } return; } + /* interactHotspotId never seems to be set + if ((h.resource()->interactHotspotId != 0) && !player->currentActions().isEmpty()) { + h.setActionCtr(99); + if (!actions.isEmpty()) + actions.top().setAction(DISPATCH_ACTION); + } + */ + debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6"); CurrentAction action = actions.action(); PathFinderResult pfResult; @@ -2567,7 +2586,9 @@ void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) { } void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) { - RoomExitJoinData *rec = Resources::getReference().getExitJoin(h.hotspotId()); + Resources &res = Resources::getReference(); + ValueTableData &fields = res.fieldList(); + RoomExitJoinData *rec = res.getExitJoin(h.hotspotId()); if (!rec) return; byte *currentFrame, *destFrame; @@ -2637,7 +2658,17 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { return; h.setSkipFlag(false); } - // TODO: HS[58h] check + + /* interactHotspotId never seems to be set + if (h.resource()->interactHotspotId != 0) { + h.resource()->interactHotspotId = 0; + Hotspot *hotspot = res.getActiveHotspot(h.resource()->interactHotspotId); + assert(hotspot); + if ((hotspot->characterMode() != CHARMODE_WAIT_FOR_INTERACT) && + !actions.isEmpty()) + actions.top().setAction(ACTION_NONE); + } + */ if (h.pauseCtr() > 0) { debugC(ERROR_DETAILED, kLureDebugAnimations, "Pause countdown = %d", h.pauseCtr()); @@ -2668,10 +2699,10 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { debugC(ERROR_DETAILED, kLureDebugAnimations, "Character mode = %d", h.characterMode()); h.setOccupied(false); h.setCharacterMode(CHARMODE_NONE); - if (fields.playerPendingPos().isSet) { + if (h.tempDest().counter != 0) { // Start walking to the previously set destination - fields.playerPendingPos().isSet = false; - h.setDestPosition(fields.playerPendingPos().pos.x, fields.playerPendingPos().pos.y); + h.tempDest().counter = 0; + h.setDestPosition(h.tempDest().position.x, h.tempDest().position.y); h.currentActions().addFront(START_WALKING, h.roomNumber()); h.setWalkFlag(false); } @@ -2753,9 +2784,9 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { return; } else if (h.blockedState() != BS_NONE) { - fields.playerPendingPos().pos.x = h.destX(); - fields.playerPendingPos().pos.y = h.destY(); - fields.playerPendingPos().isSet = true; + h.tempDest().position.x = h.destX(); + h.tempDest().position.y = h.destY(); + h.tempDest().counter = 1; h.setBlockedState((BlockedState) ((int) h.blockedState() + 1)); h.setRandomDest(); return; @@ -2795,7 +2826,7 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { // Walking done if (room.cursorState() == CS_BUMPED) room.setCursorState(CS_NONE); - if (fields.playerPendingPos().isSet) { + if (h.tempDest().counter != 0) { h.setCharacterMode(CHARMODE_PLAYER_WAIT); h.setDelayCtr(IDLE_COUNTDOWN_SIZE); return; @@ -4474,9 +4505,9 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber, // TODO: Double-check.. is it impinging in leaving room (right now) or entering room if (checkForIntersectingCharacter(h)) { - fields.playerPendingPos().pos.x = h.destX(); - fields.playerPendingPos().pos.y = h.destY(); - fields.playerPendingPos().isSet = true; + h.tempDest().position.x = h.destX(); + h.tempDest().position.y = h.destY(); + h.tempDest().counter = 1; Room::getReference().setCursorState(CS_BUMPED); h.setActionCtr(0); h.setBlockedState((BlockedState) ((int) h.blockedState() + 1)); diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index 3f8bc544f6..fb3bb1478b 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -243,6 +243,11 @@ enum HotspotPrecheckResult {PC_EXECUTE, PC_NOT_IN_ROOM, PC_FAILED, PC_WAIT, PC_E enum BarPlaceResult {BP_KEEP_TRYING, BP_GOT_THERE, BP_FAIL}; +struct DestStructure { + uint8 counter; + Point position; +}; + #define MAX_NUM_FRAMES 16 class Hotspot { @@ -277,6 +282,7 @@ private: bool _frameStartsUsed; uint16 _frameStarts[MAX_NUM_FRAMES]; char _nameBuffer[MAX_HOTSPOT_NAME_SIZE]; + DestStructure _tempDest; // Runtime fields uint16 _frameCtr; @@ -516,6 +522,7 @@ public: void doAction(Action action, HotspotData *hotspot); CurrentActionStack ¤tActions() { return _currentActions; } PathFinder &pathFinder() { return _pathFinder; } + DestStructure &tempDest() { return _tempDest; } uint16 frameCtr() { return _frameCtr; } void setFrameCtr(uint16 value) { _frameCtr = value; } void decrFrameCtr() { if (_frameCtr > 0) --_frameCtr; } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 79bf0dfe6e..12cf61a58a 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -466,7 +466,7 @@ void HotspotData::saveToStream(WriteStream *stream) { stream->writeUint16LE(talkCountdown); stream->writeUint16LE(pauseCtr); stream->writeUint16LE(useHotspotId); - stream->writeUint16LE(use2HotspotId); + stream->writeUint16LE(scriptHotspotId); stream->writeUint16LE(talkGate); stream->writeUint16LE(actionHotspotId); stream->writeUint16LE(talkOverride); @@ -507,7 +507,7 @@ void HotspotData::loadFromStream(ReadStream *stream) { talkCountdown = stream->readUint16LE(); pauseCtr = stream->readUint16LE(); useHotspotId = stream->readUint16LE(); - use2HotspotId = stream->readUint16LE(); + scriptHotspotId = stream->readUint16LE(); talkGate = stream->readUint16LE(); actionHotspotId = stream->readUint16LE(); talkOverride = stream->readUint16LE(); @@ -1119,7 +1119,7 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin if ((charHotspot->characterMode() == CHARMODE_PAUSED) || ((charHotspot->pauseCtr() == 0) && (charHotspot->characterMode() == CHARMODE_NONE))) { - hotspot->resource()->use2HotspotId = charId; + hotspot->resource()->scriptHotspotId = charId; } hotspot->setPauseCtr(IDLE_COUNTDOWN_SIZE); @@ -1206,9 +1206,6 @@ ValueTableData::ValueTableData() { _playerNewPos.roomNumber = 0; _playerNewPos.position.x = 0; _playerNewPos.position.y = 0; - _playerPendingPos.pos.x = 0; - _playerPendingPos.pos.y = 0; - _playerPendingPos.isSet = false; _flags = GAMEFLAG_4 | GAMEFLAG_1; _hdrFlagMask = 1; @@ -1252,9 +1249,6 @@ void ValueTableData::saveToStream(Common::WriteStream *stream) stream->writeSint16LE(_playerNewPos.position.x); stream->writeSint16LE(_playerNewPos.position.y); stream->writeUint16LE(_playerNewPos.roomNumber); - stream->writeByte(_playerPendingPos.isSet); - stream->writeSint16LE(_playerPendingPos.pos.x); - stream->writeSint16LE(_playerPendingPos.pos.y); stream->writeByte(_flags); stream->writeByte(_hdrFlagMask); @@ -1270,9 +1264,6 @@ void ValueTableData::loadFromStream(Common::ReadStream *stream) _playerNewPos.position.x = stream->readSint16LE(); _playerNewPos.position.y = stream->readSint16LE(); _playerNewPos.roomNumber = stream->readUint16LE(); - _playerPendingPos.isSet = stream->readByte() != 0; - _playerPendingPos.pos.x = stream->readSint16LE(); - _playerPendingPos.pos.y = stream->readSint16LE(); _flags = stream->readByte(); _hdrFlagMask = stream->readByte(); diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index b5e4aef724..4d2c55e6b1 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -458,8 +458,7 @@ public: uint16 talkGate; uint16 actionHotspotId; uint16 talkOverride; - - uint16 use2HotspotId; + uint16 scriptHotspotId; void enable() { flags |= 0x80; } void disable() { flags &= 0x7F; } @@ -817,16 +816,10 @@ struct PlayerNewPosition { uint16 roomNumber; }; -struct PlayerPendingPosition { - Point pos; - bool isSet; -}; - class ValueTableData { private: uint16 _numGroats; PlayerNewPosition _playerNewPos; - PlayerPendingPosition _playerPendingPos; uint8 _flags; uint8 _hdrFlagMask; @@ -845,7 +838,6 @@ public: uint8 &flags() { return _flags; } uint8 &hdrFlagMask() { return _hdrFlagMask; } PlayerNewPosition &playerNewPos() { return _playerNewPos; } - PlayerPendingPosition &playerPendingPos() { return _playerPendingPos; } void saveToStream(Common::WriteStream *stream); void loadFromStream(Common::ReadStream *stream); |