From 297542345f938e3c55f48cef967ec6dbc432f8ec Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 13 Oct 2009 18:54:20 +0000 Subject: SCI: Skip loading HunkTable segments. This fixes a silly bug that can lead to arbitrary numbers of HunkTable segments to be created by repeatedly saving and loading. svn-id: r45042 --- engines/sci/engine/savegame.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index af318dbe5d..4cd0f054d4 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -213,25 +213,30 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) { SegmentType type = (s.isSaving() && mobj) ? mobj->getType() : SEG_TYPE_INVALID; s.syncAsUint32LE(type); - // Handle the OBSOLETE type SEG_TYPE_STRING_FRAG -- just ignore it - if (s.isLoading() && type == SEG_TYPE_STRING_FRAG) { - s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be _segManagerId - continue; - } - // If we were saving and mobj == 0, or if we are loading and this is an // entry marked as empty -> skip to next if (type == SEG_TYPE_INVALID) { continue; } + s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be _segManagerId + + // Don't load HunkTable segments + if (s.isLoading() && type == SEG_TYPE_HUNK) { + continue; + } + + // Handle the OBSOLETE type SEG_TYPE_STRING_FRAG -- just ignore it + if (s.isLoading() && type == SEG_TYPE_STRING_FRAG) { + continue; + } + + if (s.isLoading()) { mobj = SegmentObj::createSegmentObj(type); } assert(mobj); - s.skip(4, VER(9), VER(9)); // OBSOLETE: Used to be _segManagerId - // Let the object sync custom data mobj->saveLoadWithSerializer(s); @@ -244,6 +249,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsSint32LE(Clones_seg_id); s.syncAsSint32LE(Lists_seg_id); s.syncAsSint32LE(Nodes_seg_id); +// FIXME: Hunks_seg_id ? } static void sync_SegManagerPtr(Common::Serializer &s, ResourceManager *&resMan, SegManager *&obj) { @@ -369,9 +375,7 @@ void ListTable::saveLoadWithSerializer(Common::Serializer &s) { } void HunkTable::saveLoadWithSerializer(Common::Serializer &s) { - if (s.isLoading()) { - initTable(); - } + // Do nothing, hunk tables are not actually saved nor loaded. } void Script::saveLoadWithSerializer(Common::Serializer &s) { @@ -550,6 +554,7 @@ static byte *find_unique_script_block(EngineState *s, byte *buf, int type) { } // FIXME: This should probably be turned into an EngineState method +// FIXME: Or maybe into a DataStack method... static void reconstruct_stack(EngineState *retval) { SegmentId stack_seg = retval->_segMan->findSegmentByType(SEG_TYPE_STACK); DataStack *stack = (DataStack *)(retval->_segMan->_heap[stack_seg]); -- cgit v1.2.3