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
This commit is contained in:
Max Horn 2009-05-19 00:02:44 +00:00
parent 8add60bf8c
commit 091b347a7e
3 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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));

View File

@ -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 */