aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2007-12-02 04:49:33 +0000
committerPaul Gilbert2007-12-02 04:49:33 +0000
commit804c821ab1079a7ab426d08773b08d50e382ffb3 (patch)
treea81a19e3f2294d409ba32702fa590ac0fbe0ecf8
parent3472e16a73a5d7e4813a8bc47029a44e79d0c7dd (diff)
downloadscummvm-rg350-804c821ab1079a7ab426d08773b08d50e382ffb3.tar.gz
scummvm-rg350-804c821ab1079a7ab426d08773b08d50e382ffb3.tar.bz2
scummvm-rg350-804c821ab1079a7ab426d08773b08d50e382ffb3.zip
Enhanced savegames to store any active dialog when the game was saved
svn-id: r29689
-rw-r--r--engines/lure/res.cpp11
-rw-r--r--engines/lure/room.cpp9
-rw-r--r--engines/lure/surface.cpp32
-rw-r--r--engines/lure/surface.h8
4 files changed, 60 insertions, 0 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index 0b926c5454..67a71a840f 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -596,6 +596,10 @@ Hotspot *Resources::addHotspot(uint16 hotspotId) {
Hotspot *hotspot = new Hotspot(hData);
_activeHotspots.push_back(hotspot);
+ if (hotspotId < FIRST_NONCHARACTER_ID)
+ // Default characters to facing upwards until they start moving
+ hotspot->setDirection(UP);
+
return hotspot;
}
@@ -677,6 +681,10 @@ void Resources::setTalkData(uint16 offset) {
}
void Resources::saveToStream(Common::WriteStream *stream) {
+ // Save basic fields
+ stream->writeUint16LE(_talkingCharacter);
+
+ // Save sublist data
_hotspotData.saveToStream(stream);
_activeHotspots.saveToStream(stream);
_fieldList.saveToStream(stream);
@@ -688,6 +696,9 @@ void Resources::saveToStream(Common::WriteStream *stream) {
}
void Resources::loadFromStream(Common::ReadStream *stream) {
+ debugC(ERROR_DETAILED, kLureDebugScripts, "Loading resource data");
+ _talkingCharacter = stream->readUint16LE();
+
debugC(ERROR_DETAILED, kLureDebugScripts, "Loading hotspot data");
_hotspotData.loadFromStream(stream);
debugC(ERROR_DETAILED, kLureDebugScripts, "Loading active hotspots");
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index 5b7ca082f8..63741c7896 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -727,6 +727,11 @@ bool Room::checkInTalkDialog() {
}
void Room::saveToStream(Common::WriteStream *stream) {
+ if (_talkDialog == NULL)
+ stream->writeUint16LE(0);
+ else
+ _talkDialog->saveToStream(stream);
+
stream->writeUint16LE(_roomNumber);
stream->writeUint16LE(_destRoomNumber);
stream->writeByte(_showInfo);
@@ -734,6 +739,10 @@ void Room::saveToStream(Common::WriteStream *stream) {
}
void Room::loadFromStream(Common::ReadStream *stream) {
+ if (_talkDialog)
+ delete _talkDialog;
+
+ _talkDialog = TalkDialog::loadFromStream(stream);
uint16 roomNum = stream->readUint16LE();
_roomNumber = 999; // Dummy room number so current room is faded out
setRoomNumber(roomNum, false);
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 1b43b3e3ae..bdce9f7d43 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -524,6 +524,11 @@ TalkDialog::TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 active
char itemName[MAX_DESC_SIZE];
int characterArticle, hotspotArticle = 3;
+ _characterId = characterId;
+ _destCharacterId = destCharacterId;
+ _activeItemId = activeItemId;
+ _descId = descId;
+
HotspotData *talkingChar = res.getHotspot(characterId);
HotspotData *destCharacter = (destCharacterId == 0) ? NULL :
res.getHotspot(destCharacterId);
@@ -652,6 +657,33 @@ void TalkDialog::copyTo(Surface *dest, uint16 x, uint16 y) {
_surface->copyTo(dest, x, y);
}
+void TalkDialog::saveToStream(Common::WriteStream *stream) {
+ stream->writeUint16LE(_characterId);
+ stream->writeUint16LE(_destCharacterId);
+ stream->writeUint16LE(_activeItemId);
+ stream->writeUint16LE(_descId);
+ stream->writeSint16LE(_endLine);
+ stream->writeSint16LE(_endIndex);
+ stream->writeSint16LE(_wordCountdown);
+
+}
+
+TalkDialog *TalkDialog::loadFromStream(Common::ReadStream *stream) {
+ uint16 characterId = stream->readUint16LE();
+ if (characterId == 0)
+ return NULL;
+
+ uint16 destCharacterId = stream->readUint16LE();
+ uint16 activeItemId = stream->readUint16LE();
+ uint16 descId = stream->readUint16LE();
+
+ TalkDialog *dialog = new TalkDialog(characterId, destCharacterId, activeItemId, descId);
+ dialog->_endLine = stream->readSint16LE();
+ dialog->_endIndex = stream->readSint16LE();
+ dialog->_wordCountdown = stream->readSint16LE();
+ return dialog;
+}
+
/*--------------------------------------------------------------------------*/
#define SR_SEPARATOR_Y 21
diff --git a/engines/lure/surface.h b/engines/lure/surface.h
index 07111a6625..5bbd21054a 100644
--- a/engines/lure/surface.h
+++ b/engines/lure/surface.h
@@ -93,6 +93,11 @@ private:
uint8 _numLines;
int _endLine, _endIndex;
int _wordCountdown;
+
+ uint16 _characterId;
+ uint16 _destCharacterId;
+ uint16 _activeItemId;
+ uint16 _descId;
public:
TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 activeItemId, uint16 descId);
~TalkDialog();
@@ -101,6 +106,9 @@ public:
Surface &surface() { return *_surface; }
void copyTo(Surface *dest, uint16 x, uint16 y);
bool isBuilding() { return _endLine < _numLines; }
+
+ void saveToStream(Common::WriteStream *stream);
+ static TalkDialog *loadFromStream(Common::ReadStream *stream);
};
class SaveRestoreDialog {