diff options
author | Max Horn | 2005-05-09 00:09:01 +0000 |
---|---|---|
committer | Max Horn | 2005-05-09 00:09:01 +0000 |
commit | c33cc2ce85dea20cd0eb749a06276d12ff31956c (patch) | |
tree | 1526599eb4dd8c0e6a4479b3e19f77a53a6af0ab /scumm/saveload.cpp | |
parent | 20c8944189941dbf0286afc28b361f7bb4e09e74 (diff) | |
download | scummvm-rg350-c33cc2ce85dea20cd0eb749a06276d12ff31956c.tar.gz scummvm-rg350-c33cc2ce85dea20cd0eb749a06276d12ff31956c.tar.bz2 scummvm-rg350-c33cc2ce85dea20cd0eb749a06276d12ff31956c.zip |
Last part of patch #1163026 (Thumbnails for ScummEngine)
svn-id: r17982
Diffstat (limited to 'scumm/saveload.cpp')
-rw-r--r-- | scumm/saveload.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 406db2f37a..8dc0039969 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -83,6 +83,7 @@ bool ScummEngine::saveState(int slot, bool compat) { hdr.ver = TO_LE_32(CURRENT_VER); out->write(&hdr, sizeof(hdr)); + saveThumbnail(out); Serializer ser(0, out, CURRENT_VER); saveOrLoad(&ser, CURRENT_VER); @@ -126,6 +127,18 @@ bool ScummEngine::loadState(int slot, bool compat) { delete in; return false; } + + // Sine version 52 a thumbnail is saved directly after the header + if (hdr.ver >= VER(52)) { + uint32 type = in->readUint32BE(); + if (type != MKID('THMB')) { + warning("Can not load thumbnail"); + delete in; + return false; + } + uint32 size = in->readUint32BE(); + in->skip(size - 8); + } // Due to a bug in scummvm up to and including 0.3.0, save games could be saved // in the V8/V9 format but were tagged with a V7 mark. Ouch. So we just pretend V7 == V8 here @@ -387,6 +400,36 @@ bool ScummEngine::getSavegameName(int slot, char *desc) { return true; } +Graphics::Surface *ScummEngine::loadThumbnailFromSlot(int slot) { + char filename[256]; + InSaveFile *in; + SaveGameHeader hdr; + int len; + + makeSavegameName(filename, slot, false); + if (!(in = _saveFileMan->openForLoading(filename))) { + return 0; + } + len = in->read(&hdr, sizeof(hdr)); + + if (len != sizeof(hdr) || hdr.type != MKID('SCVM')) { + delete in; + return 0; + } + + if (hdr.ver > CURRENT_VER) + hdr.ver = TO_LE_32(hdr.ver); + if (hdr.ver < VER(52)) { + delete in; + return 0; + } + + Graphics::Surface *thumb = loadThumbnail(in); + + delete in; + return thumb; +} + void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { const SaveLoadEntry objectEntries[] = { MKLINE(ObjectData, OBIMoffset, sleUint32, VER(8)), |