aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mads/game.cpp')
-rw-r--r--engines/mads/game.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 8639f59418..dde2b405ab 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -64,6 +64,7 @@ Game::Game(MADSEngine *vm)
_loadGameSlot = -1;
_lastSave = -1;
_saveFile = nullptr;
+ _saveThumb = nullptr;
_statusFlag = 0;
_sectionHandler = nullptr;
_sectionNumber = 1;
@@ -93,6 +94,11 @@ Game::Game(MADSEngine *vm)
}
Game::~Game() {
+ if (_saveThumb) {
+ _saveThumb->free();
+ delete _saveThumb;
+ }
+
delete _saveFile;
delete _surface;
delete _sectionHandler;
@@ -548,16 +554,14 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
out->write(header._saveName.c_str(), header._saveName.size());
out->writeByte('\0');
- // Get the active palette
- uint8 thumbPalette[256 * 3];
- g_system->getPaletteManager()->grabPalette(thumbPalette, 0, 256);
-
- // Create a thumbnail and save it
- Graphics::Surface *thumb = new Graphics::Surface();
- ::createThumbnail(thumb, _vm->_screen.getData(), MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, thumbPalette);
- Graphics::saveThumbnail(*out, *thumb);
- thumb->free();
- delete thumb;
+ // Handle the thumbnail. If there's already one set by the game, create one
+ if (!_saveThumb)
+ createThumbnail();
+ Graphics::saveThumbnail(*out, *_saveThumb);
+
+ _saveThumb->free();
+ delete _saveThumb;
+ _saveThumb = nullptr;
// Write out the save date/time
TimeDate td;
@@ -570,4 +574,16 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
out->writeUint32LE(_vm->_events->getFrameCounter());
}
+void Game::createThumbnail() {
+ if (_saveThumb) {
+ _saveThumb->free();
+ delete _saveThumb;
+ }
+
+ uint8 thumbPalette[256 * 3];
+ _vm->_palette->grabPalette(thumbPalette, 0, 256);
+ _saveThumb = new Graphics::Surface();
+ ::createThumbnail(_saveThumb, _vm->_screen.getData(), MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, thumbPalette);
+}
+
} // End of namespace MADS