aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/pegasus.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2012-09-22 21:03:22 -0400
committerMatthew Hoops2012-09-22 21:03:22 -0400
commit3a5b3a514559d952bc0bf6e0bccbf900aa291930 (patch)
tree714805a241fe51dc2f12934b58562837a0fd3991 /engines/pegasus/pegasus.cpp
parent50747429cdd7746202902254a84742f771da4cb9 (diff)
downloadscummvm-rg350-3a5b3a514559d952bc0bf6e0bccbf900aa291930.tar.gz
scummvm-rg350-3a5b3a514559d952bc0bf6e0bccbf900aa291930.tar.bz2
scummvm-rg350-3a5b3a514559d952bc0bf6e0bccbf900aa291930.zip
PEGASUS: Fix saving while in the space chase
Diffstat (limited to 'engines/pegasus/pegasus.cpp')
-rw-r--r--engines/pegasus/pegasus.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 4b1d7d73ae..29aa8a440b 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -527,6 +527,20 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
}
bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
+ // WORKAROUND: If we don't have the interface, we can't actually save.
+ // However, we should still have a continue point, so we will just dump that
+ // out. This is needed for saving a game while in the space chase.
+ if (!g_interface) {
+ // Saving a continue stream from a continue stream should
+ // never happen. In addition, we do need to have a continue
+ // stream for this to work.
+ if (saveType != kNormalSave || !_continuePoint)
+ return false;
+
+ writeContinueStream(stream);
+ return true;
+ }
+
if (g_neighborhood)
g_neighborhood->flushGameState();
@@ -602,10 +616,27 @@ void PegasusEngine::loadFromContinuePoint() {
if (!_continuePoint)
error("Attempting to load from non-existant continue point");
+ _continuePoint->seek(0);
+
if (!loadFromStream(_continuePoint))
error("Failed loading continue point");
}
+void PegasusEngine::writeContinueStream(Common::WriteStream *stream) {
+ // We're going to pretty much copy the stream, except for the save type
+ _continuePoint->seek(0);
+ stream->writeUint32BE(_continuePoint->readUint32BE());
+ _continuePoint->readUint32BE(); // skip the continue type
+ stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1);
+
+ // Now just copy over the rest
+ uint32 size = _continuePoint->size() - _continuePoint->pos();
+ byte *data = new byte[size];
+ _continuePoint->read(data, size);
+ stream->write(data, size);
+ delete[] data;
+}
+
Common::Error PegasusEngine::loadGameState(int slot) {
Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);