aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-01-13 17:29:40 -0500
committerPaul Gilbert2018-01-13 17:29:40 -0500
commit5eb03885729f9cc8e80e6312cf08a53a3f8a5709 (patch)
treeb5b144ae3e60b00ed41df1697c8a6509605393db
parent6a66fe907e063696a4bfdc5351dac73b621a5c31 (diff)
downloadscummvm-rg350-5eb03885729f9cc8e80e6312cf08a53a3f8a5709.tar.gz
scummvm-rg350-5eb03885729f9cc8e80e6312cf08a53a3f8a5709.tar.bz2
scummvm-rg350-5eb03885729f9cc8e80e6312cf08a53a3f8a5709.zip
XEEN: Saving fixes for party and roster
-rw-r--r--engines/xeen/files.cpp10
-rw-r--r--engines/xeen/files.h10
-rw-r--r--engines/xeen/saves.cpp17
3 files changed, 36 insertions, 1 deletions
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp
index 705a9406c3..164313ca4c 100644
--- a/engines/xeen/files.cpp
+++ b/engines/xeen/files.cpp
@@ -245,6 +245,14 @@ void FileManager::setGameCc(int ccMode) {
_isDarkCc = ccMode != 0;
}
+void FileManager::load(Common::SeekableReadStream &stream) {
+ setGameCc(stream.readByte());
+}
+
+void FileManager::save(Common::WriteStream &s) {
+ s.writeByte(_isDarkCc ? 1 : 0);
+}
+
/*------------------------------------------------------------------------*/
CCArchive *File::_xeenCc;
@@ -474,10 +482,12 @@ void SaveArchive::save(Common::WriteStream &s) {
OutFile chr("maze.chr", this);
XeenSerializer sChr(nullptr, &chr);
_party->_roster.synchronize(sChr);
+ chr.finalize();
OutFile pty("maze.pty", this);
Common::Serializer sPty(nullptr, &pty);
_party->synchronize(sPty);
+ pty.finalize();
// First caclculate file offsets for each resource, since replaced resources
// will shift file offsets for even the succeeding unchanged resources
diff --git a/engines/xeen/files.h b/engines/xeen/files.h
index b528658566..ff10db5228 100644
--- a/engines/xeen/files.h
+++ b/engines/xeen/files.h
@@ -93,6 +93,16 @@ public:
* @param ccMode 0=Clouds, 1=Dark Side
*/
void setGameCc(int ccMode);
+
+ /**
+ * Loads a save archive from a stream
+ */
+ void load(Common::SeekableReadStream &stream);
+
+ /**
+ * Saves a save archive to a savegame
+ */
+ void save(Common::WriteStream &s);
};
/**
diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp
index 2a6b7d6619..f84176c935 100644
--- a/engines/xeen/saves.cpp
+++ b/engines/xeen/saves.cpp
@@ -159,6 +159,10 @@ Common::Error SavesManager::saveGameState(int slot, const Common::String &desc)
}
}
+ // Write out miscellaneous
+ FileManager &files = *g_vm->_files;
+ files.save(*out);
+
out->finalize();
delete out;
@@ -166,6 +170,11 @@ Common::Error SavesManager::saveGameState(int slot, const Common::String &desc)
}
Common::Error SavesManager::loadGameState(int slot) {
+ EventsManager &events = *g_vm->_events;
+ FileManager &files = *g_vm->_files;
+ Map &map = *g_vm->_map;
+ Party &party = *g_vm->_party;
+
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
generateSaveName(slot));
if (!saveFile)
@@ -182,7 +191,7 @@ Common::Error SavesManager::loadGameState(int slot) {
}
// Set the total play time
- g_vm->_events->setPlayTime(header._totalFrames);
+ events.setPlayTime(header._totalFrames);
// Loop through loading the sides' save archives
SaveArchive *archives[2] = { File::_xeenSave, File::_darkSave };
@@ -198,6 +207,12 @@ Common::Error SavesManager::loadGameState(int slot) {
}
}
+ // Read in miscellaneous
+ files.load(*saveFile);
+
+ // Load the new map
+ map.load(party._mazeId);
+
return Common::kNoError;
}