diff options
author | Johannes Schickel | 2008-08-20 15:08:00 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-08-20 15:08:00 +0000 |
commit | f01a4a88456ce57db72e71b252d8d81d6ce04117 (patch) | |
tree | ee6c35f19c5a933888bb0f8dc7f0c9a7dda60992 | |
parent | b9e496adbd15f1b8d9cd9609b5d1e239804ce6c9 (diff) | |
download | scummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.tar.gz scummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.tar.bz2 scummvm-rg350-f01a4a88456ce57db72e71b252d8d81d6ce04117.zip |
Cleanup of thumbnail saving/loading code.
svn-id: r34060
-rw-r--r-- | engines/scumm/module.mk | 1 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 36 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 2 | ||||
-rw-r--r-- | engines/scumm/thumbnail.cpp | 59 |
4 files changed, 33 insertions, 65 deletions
diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk index 7d52a02116..b86ad8159b 100644 --- a/engines/scumm/module.mk +++ b/engines/scumm/module.mk @@ -53,7 +53,6 @@ MODULE_OBJS := \ scumm.o \ sound.o \ string.o \ - thumbnail.o \ usage_bits.o \ util.o \ vars.o \ 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. diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 9ac78e3b93..ebd7749606 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -636,8 +636,6 @@ public: protected: Graphics::Surface *loadThumbnail(Common::SeekableReadStream *file); - void saveThumbnail(Common::WriteStream *file); - void skipThumbnailHeader(Common::SeekableReadStream *file); void saveInfos(Common::WriteStream* file); bool loadInfos(Common::SeekableReadStream *file, InfoStuff *stuff); diff --git a/engines/scumm/thumbnail.cpp b/engines/scumm/thumbnail.cpp deleted file mode 100644 index 1f494b25a5..0000000000 --- a/engines/scumm/thumbnail.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed file the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - - -#include "common/system.h" -#include "common/savefile.h" -#include "graphics/scaler.h" -#include "graphics/thumbnail.h" -#include "scumm/scumm.h" - -namespace Scumm { - -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; -} - -void ScummEngine::saveThumbnail(Common::OutSaveFile *file) { -#if !defined(__DS__) - Graphics::saveThumbnail(*file); -#endif -} - -void ScummEngine::skipThumbnailHeader(Common::SeekableReadStream *file) { - Graphics::skipThumbnailHeader(*file); -} - -} // end of namespace Scumm |