aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/saveload.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-08-20 15:08:00 +0000
committerJohannes Schickel2008-08-20 15:08:00 +0000
commitf01a4a88456ce57db72e71b252d8d81d6ce04117 (patch)
treeee6c35f19c5a933888bb0f8dc7f0c9a7dda60992 /engines/scumm/saveload.cpp
parentb9e496adbd15f1b8d9cd9609b5d1e239804ce6c9 (diff)
downloadscummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.tar.gz
scummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.tar.bz2
scummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.zip
Cleanup of thumbnail saving/loading code.
svn-id: r34060
Diffstat (limited to 'engines/scumm/saveload.cpp')
-rw-r--r--engines/scumm/saveload.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index c7193a55f3..088133899c 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -46,6 +46,8 @@
#include "sound/audiocd.h"
#include "sound/mixer.h"
+#include "graphics/thumbnail.h"
+
namespace Scumm {
struct SaveGameHeader {
@@ -71,6 +73,22 @@ struct SaveInfoSection {
#define INFOSECTION_VERSION 2
+Graphics::Surface *ScummEngine::loadThumbnail(Common::SeekableReadStream *file) {
+ if (!Graphics::checkThumbnailHeader(*file))
+ return 0;
+
+ Graphics::Surface *thumb = new Graphics::Surface();
+ assert(thumb);
+ if (!Graphics::loadThumbnail(*file, *thumb)) {
+ delete thumb;
+ return 0;
+ }
+
+ return thumb;
+}
+
+#pragma mark -
+
void ScummEngine::requestSave(int slot, const char *name, bool temporary) {
_saveLoadSlot = slot;
_saveTemporaryState = temporary;
@@ -114,7 +132,9 @@ bool ScummEngine::saveState(int slot, bool compat) {
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
saveSaveGameHeader(out, hdr);
- saveThumbnail(out);
+#if !defined(__DS__)
+ Graphics::saveThumbnail(*out);
+#endif
saveInfos(out);
Serializer ser(0, out, CURRENT_VER);
@@ -184,8 +204,18 @@ bool ScummEngine::loadState(int slot, bool compat) {
}
// Since version 52 a thumbnail is saved directly after the header.
- if (hdr.ver >= VER(52))
- skipThumbnailHeader(in);
+ if (hdr.ver >= VER(52)) {
+ // Prior to version 75 we always required an thumbnail to be present
+ if (hdr.ver <= VER(74)) {
+ if (!Graphics::checkThumbnailHeader(*in)) {
+ warning("Can not load thumbnail");
+ delete in;
+ return false;
+ }
+ } else {
+ Graphics::skipThumbnailHeader(*in);
+ }
+ }
// Since version 56 we save additional information about the creation of
// the save game and the save time.