diff options
-rw-r--r-- | engines/sci/engine/savegame.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index d89170ab22..e0c2833572 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -728,9 +728,7 @@ void GfxPalette::saveLoadWithSerializer(Common::Serializer &s) { } void GfxPorts::saveLoadWithSerializer(Common::Serializer &s) { - if (s.isLoading()) - reset(); // remove all script generated windows - + // reset() is called directly way earlier in gamestate_restore() if (s.getVersion() >= 27) { uint windowCount = 0; uint id = PORTS_FIRSTSCRIPTWINDOWID; @@ -925,6 +923,13 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { // We don't need the thumbnail here, so just read it and discard it Graphics::skipThumbnail(*fh); + // reset ports as one of the first things we do, because that may free() some hunk memory + // and we don't want to do that after we read in the saved game hunk memory + if (ser.isLoading()) { + if (g_sci->_gfxPorts) + g_sci->_gfxPorts->reset(); + } + s->reset(true); s->saveLoadWithSerializer(ser); // FIXME: Error handling? |