From 6a1290a1d327c0d1f4a93bb8a143edcb5a514280 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 27 May 2007 04:33:19 +0000 Subject: Reworked game saving so that restored games don't fire off hotspot activation scripts, and conversation bugfix to keep characters in place svn-id: r26955 --- engines/lure/hotspots.cpp | 25 ++++++++++++++++++------- engines/lure/lure.cpp | 4 ++-- engines/lure/luredefs.h | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index f3b1c01d3d..bbeabe71aa 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -867,7 +867,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) { setDelayCtr(4); } - hotspot->talkGate = 0x2A; + hotspot->talkGate = GENERAL_MAGIC_ID; hotspot->talkDestCharacterId = _hotspotId; return PC_WAIT; } @@ -2024,6 +2024,7 @@ void Hotspot::startTalk(HotspotData *charHotspot, uint16 id) { // Signal the character that they're being talked to charHotspot->talkDestCharacterId = _hotspotId; + charHotspot->talkGate = 0; _data->talkDestCharacterId = charHotspot->hotspotId; _data->talkGate = 0; @@ -2067,6 +2068,7 @@ void Hotspot::saveToStream(Common::WriteStream *stream) { stream->writeUint16LE(_blockedOffset); stream->writeUint16LE(_exitCtr); stream->writeByte(_walkFlag); + stream->writeByte(_persistant); stream->writeUint16LE(_startRoomNumber); stream->writeUint16LE(_supportValue); } @@ -2103,6 +2105,7 @@ void Hotspot::loadFromStream(Common::ReadStream *stream) { _blockedOffset = stream->readUint16LE(); _exitCtr = stream->readUint16LE(); _walkFlag = stream->readByte() != 0; + _persistant = stream->readByte() != 0; _startRoomNumber = stream->readUint16LE(); _supportValue = stream->readUint16LE(); } @@ -2214,7 +2217,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { if (h.resource()->talkDestCharacterId != 0) { debugC(ERROR_DETAILED, kLureDebugAnimations, "Use Hotspot Id = %xh, talk_gate = %d", h.resource()->talkDestCharacterId, h.talkGate()); - if (h.talkGate() == 0x2A) { + if (h.talkGate() == GENERAL_MAGIC_ID) { fields.setField(ACTIVE_HOTSPOT_ID, h.talkGate()); fields.setField(USE_HOTSPOT_ID, h.resource()->talkDestCharacterId); Script::execute(h.talkScript()); @@ -3142,9 +3145,13 @@ void HotspotTickHandlers::talkAnimHandler(Hotspot &h) { if ((entry->preSequenceId & 0x8000) != 0) break; } - if (showSelections && (numLines > 1)) + if (showSelections && (numLines > 1)) { res.setTalkState(TALK_SELECT); - else { + + // Make sure the dest character holds still while an option is selected + HotspotData *destHotspot = res.getHotspot(talkDestCharacter); + destHotspot->talkDestCharacterId = h.hotspotId(); + } else { res.setTalkState(TALK_RESPOND); res.setTalkSelection(1); } @@ -4457,17 +4464,21 @@ void HotspotList::loadFromStream(ReadStream *stream) { Hotspot *destHotspot = res.getActiveHotspot(destHotspotId); assert(destHotspot); hotspot = new Hotspot(destHotspot, hotspotId); - res.addHotspot(hotspot); } else { - hotspot = res.activateHotspot(hotspotId); + HotspotData *hotspotData = res.getHotspot(hotspotId); + assert(hotspotData); + hotspot = new Hotspot(hotspotData); } - assert(hotspot); + res.addHotspot(hotspot); + assert(hotspot); hotspot->loadFromStream(stream); + debugC(ERROR_DETAILED, kLureDebugAnimations, "Loaded hotspot %xh", hotspotId); + // Get the next hotspot hotspotId = stream->readUint16LE(); } } diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index f28dc00954..a2d4a6f255 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -141,8 +141,8 @@ bool LureEngine::saveGame(uint8 slotNumber, Common::String &caption) { f->writeString(caption); f->writeByte(0); // End of string terminator - Room::getReference().saveToStream(f); Resources::getReference().saveToStream(f); + Room::getReference().saveToStream(f); delete f; return true; @@ -182,8 +182,8 @@ bool LureEngine::loadGame(uint8 slotNumber) { while (f->readByte() != 0) ; // Load in the data - Room::getReference().loadFromStream(f); Resources::getReference().loadFromStream(f); + Room::getReference().loadFromStream(f); delete f; return true; diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h index 1419c1b4cb..d854ed464c 100644 --- a/engines/lure/luredefs.h +++ b/engines/lure/luredefs.h @@ -259,6 +259,7 @@ enum Action { #define TALK_RESPONSE_MAGIC_ID 0x1092 // Misc constants +#define GENERAL_MAGIC_ID 42 #define VOICE_ANIM_ID 0x5810 #define PUZZLED_ANIM_ID 0x8001 #define EXCLAMATION_ANIM_ID 0x8002 -- cgit v1.2.3