diff options
Diffstat (limited to 'engines/gob/save')
-rw-r--r-- | engines/gob/save/saveload.h | 4 | ||||
-rw-r--r-- | engines/gob/save/saveload_v4.cpp | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index 700462f315..1a1a47178b 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -289,6 +289,8 @@ protected: GameHandler(GobEngine *vm, const char *target); ~GameHandler(); + int getLastSlot() const; + int32 getSize(); bool load(int16 dataVar, int32 size, int32 offset); bool save(int16 dataVar, int32 size, int32 offset); @@ -317,6 +319,8 @@ protected: File *_slotFile; + int _lastSlot; + SaveReader *_reader; SaveWriter *_writer; diff --git a/engines/gob/save/saveload_v4.cpp b/engines/gob/save/saveload_v4.cpp index 06280af2a6..16c87b9a64 100644 --- a/engines/gob/save/saveload_v4.cpp +++ b/engines/gob/save/saveload_v4.cpp @@ -84,6 +84,8 @@ SaveLoad_v4::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveH _slotFile = new File(vm, target); + _lastSlot = -1; + _writer = 0; _reader = 0; } @@ -94,6 +96,10 @@ SaveLoad_v4::GameHandler::~GameHandler() { delete _writer; } +int SaveLoad_v4::GameHandler::getLastSlot() const { + return _lastSlot; +} + int32 SaveLoad_v4::GameHandler::getSize() { // Fake an empty save file for the very first query, to get clear properties if (_firstSize) { @@ -178,6 +184,7 @@ bool SaveLoad_v4::GameHandler::load(int16 dataVar, int32 size, int32 offset) { if (!vars.writeInto(0, 0, varSize)) return false; + _lastSlot = slot; } return true; @@ -261,6 +268,7 @@ bool SaveLoad_v4::GameHandler::save(int16 dataVar, int32 size, int32 offset) { if (!_writer->writePart(1, &vars)) return false; + _lastSlot = slot; } return true; @@ -465,7 +473,11 @@ bool SaveLoad_v4::ScreenPropsHandler::load(int16 dataVar, int32 size, int32 offs return false; } - return _gameHandler->loadScreenProps(_file->getSlot(offset), _curProps->_props); + int slot = _gameHandler->getLastSlot(); + if (slot == -1) + slot = _file->getSlot(offset); + + return _gameHandler->loadScreenProps(slot, _curProps->_props); } bool SaveLoad_v4::ScreenPropsHandler::save(int16 dataVar, int32 size, int32 offset) { @@ -474,7 +486,11 @@ bool SaveLoad_v4::ScreenPropsHandler::save(int16 dataVar, int32 size, int32 offs return false; } - return _gameHandler->saveScreenProps(_file->getSlot(offset), _curProps->_props); + int slot = _gameHandler->getLastSlot(); + if (slot == -1) + slot = _file->getSlot(offset); + + return _gameHandler->saveScreenProps(slot, _curProps->_props); } |