aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-05-19 00:02:44 +0000
committerMax Horn2009-05-19 00:02:44 +0000
commit091b347a7e8bfa2162cdade24a9386a92c2e475c (patch)
treec9781410550d86dfbcd6c5989550ff13318d993a
parent8add60bf8c3a524ba8bd1354ed31de6315c4dbc6 (diff)
downloadscummvm-rg350-091b347a7e8bfa2162cdade24a9386a92c2e475c.tar.gz
scummvm-rg350-091b347a7e8bfa2162cdade24a9386a92c2e475c.tar.bz2
scummvm-rg350-091b347a7e8bfa2162cdade24a9386a92c2e475c.zip
SCI: Init the diff .#&$ EngineState::flags field in the constructor and when loading -- fixes many weird crashes upon loading (lesson to be learned: if you add fields to a class, then (a) init it in the construtor and (b) if the class support serializing, make sure the new field is handled when saving/loading :-)
svn-id: r40712
-rw-r--r--engines/sci/engine/savegame.cpp5
-rw-r--r--engines/sci/engine/state.cpp9
-rw-r--r--engines/sci/engine/state.h2
3 files changed, 10 insertions, 6 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 0bd715719f..e099cb894a 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -251,7 +251,7 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(savegame_version);
syncCStr(s, &game_version);
- s.syncAsSint32LE(version);
+ s.skip(4); // Obsolete: Used to be version
// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
if (s.isLoading()) {
@@ -758,6 +758,9 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
retval = new EngineState();
+ retval->version = s->version;
+ retval->flags = s->flags;
+
retval->savegame_version = -1;
retval->gfx_state = s->gfx_state;
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index f60697d83c..1ff371cbd7 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -99,11 +99,12 @@ EngineState::EngineState() : _dirseeker(this) {
last_wait_time = 0;
version = 0;
-
- _fileHandles.resize(5);
+ flags = 0;
kernel_opt_flags = 0;
+ _fileHandles.resize(5);
+
execution_stack_base = 0;
_executionStackPosChanged = false;
@@ -119,14 +120,14 @@ EngineState::EngineState() : _dirseeker(this) {
parser_event = NULL_REG;
script_000 = 0;
- string_frag_segment = 0;
-
parser_lastmatch_word = 0;
bp_list = 0;
have_bp = 0;
debug_mode = 0;
sys_strings_segment = 0;
sys_strings = 0;
+ string_frag_segment = 0;
+
parser_rules = 0;
memset(parser_nodes, 0, sizeof(parser_nodes));
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index c178016a6e..f451ab96b0 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -195,7 +195,7 @@ public:
uint32 last_wait_time; /**< The last time the game invoked Wait() */
sci_version_t version; /**< The approximated patchlevel of the version to emulate */
- uint32 flags; /* Specific game flags */
+ uint32 flags; /**< Specific game flags */
unsigned int kernel_opt_flags; /**< Kernel optimization flags- used for performance tweaking */