aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/console.cpp15
-rw-r--r--engines/sci/detection.cpp10
-rw-r--r--engines/sci/engine/kfile.cpp10
-rw-r--r--engines/sci/engine/savegame.cpp25
-rw-r--r--engines/sci/engine/savegame.h3
5 files changed, 18 insertions, 45 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 9d12d4386f..ab4d13e630 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -893,26 +893,17 @@ bool Console::cmdRestoreGame(int argc, const char **argv) {
return true;
}
- EngineState *newstate = NULL;
-
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SeekableReadStream *in = saveFileMan->openForLoading(argv[1]);
if (in) {
// found a savegame file
- newstate = gamestate_restore(_vm->_gamestate, in);
+ gamestate_restore(_vm->_gamestate, in);
delete in;
}
- if (newstate) {
- _vm->_gamestate->successor = newstate; // Set successor
-
- script_abort_flag = 2; // Abort current game with replay
-
- shrink_execution_stack(_vm->_gamestate, _vm->_gamestate->execution_stack_base + 1);
- return 0;
- } else {
+ if (_vm->_gamestate->r_acc == make_reg(0, 1)) {
DebugPrintf("Restoring gamestate '%s' failed.\n", argv[1]);
- return 1;
+ return true;
}
return false;
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 30b5f00964..cfa81ed6e1 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -475,23 +475,17 @@ void SciMetaEngine::removeSaveState(const char *target, int slot) const {
}
Common::Error SciEngine::loadGameState(int slot) {
- EngineState *newstate = NULL;
Common::String fileName = Common::String::printf("%s.%03d", _targetName.c_str(), slot);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::SeekableReadStream *in = saveFileMan->openForLoading(fileName);
if (in) {
// found a savegame file
- newstate = gamestate_restore(_gamestate, in);
+ gamestate_restore(_gamestate, in);
delete in;
}
- if (newstate) {
- _gamestate->successor = newstate; // Set successor
-
- script_abort_flag = 2; // Abort current game with replay
-
- shrink_execution_stack(_gamestate, _gamestate->execution_stack_base + 1);
+ if (_gamestate->r_acc != make_reg(0, 1)) {
return Common::kNoError;
} else {
warning("Restoring gamestate '%s' failed", fileName.c_str());
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 0860466d32..216a543aa8 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -618,17 +618,9 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
if ((in = saveFileMan->openForLoading(filename))) {
// found a savegame file
- EngineState *newstate = gamestate_restore(s, in);
+ gamestate_restore(s, in);
delete in;
- if (newstate) {
- s->successor = newstate;
- script_abort_flag = 2; // Abort current game with replay
- shrink_execution_stack(s, s->execution_stack_base + 1);
- } else {
- s->r_acc = make_reg(0, 1);
- warning("Restoring failed (game_id = '%s')", game_id.c_str());
- }
return s->r_acc;
}
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index f8eddcdaa2..bf0f11c3a6 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -903,28 +903,21 @@ static void reconstruct_sounds(EngineState *s) {
}
#endif
-EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
+void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
EngineState *retval;
#ifdef USE_OLD_MUSIC_FUNCTIONS
SongLibrary temp;
#endif
-/*
- if (s->sound_server) {
- if ((s->sound_server->restore)(s, dirname)) {
- warning("Restoring failed for the sound subsystem");
- return NULL;
- }
- }
-*/
-
SavegameMetadata meta;
Common::Serializer ser(fh, 0);
sync_SavegameMetadata(ser, meta);
- if (fh->eos())
- return false;
+ if (fh->eos()) {
+ s->r_acc = make_reg(0, 1); // signal failure
+ return;
+ }
if ((meta.savegame_version < MINIMUM_SAVEGAME_VERSION) ||
(meta.savegame_version > CURRENT_SAVEGAME_VERSION)) {
@@ -933,7 +926,8 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
else
warning("Savegame version is %d- maximum supported is %0d", meta.savegame_version, CURRENT_SAVEGAME_VERSION);
- return NULL;
+ s->r_acc = make_reg(0, 1); // signal failure
+ return;
}
if (meta.savegame_version >= 12) {
@@ -1027,7 +1021,10 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
}
#endif
- return retval;
+
+ s->successor = retval; // Set successor
+ script_abort_flag = 2; // Abort current game with replay
+ shrink_execution_stack(s, s->execution_stack_base + 1);
}
bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata *meta) {
diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h
index a5828bbd8e..2df7c7836d 100644
--- a/engines/sci/engine/savegame.h
+++ b/engines/sci/engine/savegame.h
@@ -63,9 +63,8 @@ int gamestate_save(EngineState *s, Common::WriteStream *save, const char *savena
* Restores a game state from a directory.
* @param s An older state from the same game
* @param dirname The subdirectory to restore from
- * @return NULL on failure, a pointer to a valid EngineState otherwise
*/
-EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *save);
+void gamestate_restore(EngineState *s, Common::SeekableReadStream *save);
/**
* Read the header from a savegame.