diff options
Diffstat (limited to 'engines/sci/engine/savegame.cpp')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 31fb848a2c..d86af50f9a 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -158,6 +158,24 @@ void syncWithSerializer(Common::Serializer &s, SciString &obj) { obj.setValue(i, value); } } + +void syncWithSerializer(Common::Serializer &s, SciBitmap *&obj) { + bool hasEntry; + if (s.isSaving()) { + hasEntry = obj != nullptr; + } + s.syncAsByte(hasEntry); + + if (hasEntry) { + if (s.isLoading()) { + obj = new SciBitmap; + } + + obj->saveLoadWithSerializer(s); + } else { + obj = nullptr; + } +} #endif #pragma mark - @@ -273,6 +291,8 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) { } else if (type == SEG_TYPE_STRING) { // Set the correct segment for SCI32 strings _stringSegId = i; + } else if (s.getVersion() >= 36 && type == SEG_TYPE_BITMAP) { + _bitmapSegId = i; #endif } @@ -687,6 +707,31 @@ void StringTable::saveLoadWithSerializer(Common::Serializer &ser) { sync_Table<StringTable>(ser, *this); } + +void BitmapTable::saveLoadWithSerializer(Common::Serializer &ser) { + if (ser.getVersion() < 36) { + return; + } + + sync_Table(ser, *this); +} + +void SciBitmap::saveLoadWithSerializer(Common::Serializer &s) { + if (s.getVersion() < 36) { + return; + } + + s.syncAsByte(_gc); + s.syncAsUint32LE(_dataSize); + if (s.isLoading()) { + _data = (byte *)malloc(_dataSize); + } + s.syncBytes(_data, _dataSize); + + if (s.isLoading()) { + _buffer = Buffer(getWidth(), getHeight(), getPixels()); + } +} #endif void GfxPalette::palVarySaveLoadPalette(Common::Serializer &s, Palette *palette) { |