diff options
-rw-r--r-- | engines/gnap/detection.cpp | 38 | ||||
-rw-r--r-- | engines/gnap/gnap.h | 2 | ||||
-rw-r--r-- | engines/gnap/menu.cpp | 11 |
3 files changed, 28 insertions, 23 deletions
diff --git a/engines/gnap/detection.cpp b/engines/gnap/detection.cpp index 616c26b04b..b68d64c4ed 100644 --- a/engines/gnap/detection.cpp +++ b/engines/gnap/detection.cpp @@ -88,10 +88,8 @@ bool GnapMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsLoadingDuringStartup) || (f == kSupportsDeleteSave) || (f == kSavesSupportMetaInfo) || - (f == kSavesSupportCreationDate); -#if 0 (f == kSavesSupportThumbnail) || -#endif + (f == kSavesSupportCreationDate); } bool Gnap::GnapEngine::hasFeature(EngineFeature f) const { @@ -147,35 +145,35 @@ SaveStateDescriptor GnapMetaEngine::querySaveMetaInfos(const char *target, int s Common::String fileName = Common::String::format("%s.%03d", target, slot); Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName); if (file) { + char saveIdentBuffer[5]; + file->read(saveIdentBuffer, 5); - int32 version = file->readSint32BE(); - if (version != GNAP_SAVEGAME_VERSION) { + int32 version = file->readByte(); + if (version > GNAP_SAVEGAME_VERSION) { delete file; return SaveStateDescriptor(); } - uint32 saveNameLength = file->readUint16BE(); char saveName[256]; - file->read(saveName, saveNameLength); - saveName[saveNameLength] = 0; + char ch; + int i = 0; + while ((ch = (char)file->readByte()) != '\0') + saveName[i++] = ch; SaveStateDescriptor desc(slot, saveName); - Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); - desc.setThumbnail(thumbnail); - - uint32 saveDate = file->readUint32BE(); - uint16 saveTime = file->readUint16BE(); + if (version != 1) { + Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file); + desc.setThumbnail(thumbnail); + } - int day = (saveDate >> 24) & 0xFF; - int month = (saveDate >> 16) & 0xFF; - int year = saveDate & 0xFFFF; + int year = file->readSint16LE(); + int month = file->readSint16LE(); + int day = file->readSint16LE(); + int hour = file->readSint16LE(); + int minutes = file->readSint16LE(); desc.setSaveDate(year, month, day); - - int hour = (saveTime >> 8) & 0xFF; - int minutes = saveTime & 0xFF; - desc.setSaveTime(hour, minutes); delete file; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index 7aa2221b1e..cb1c00d044 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -59,7 +59,7 @@ class GameSys; class SoundMan; class MusicPlayer; -#define GNAP_SAVEGAME_VERSION 1 +#define GNAP_SAVEGAME_VERSION 2 struct MouseButtonState { bool _left; diff --git a/engines/gnap/menu.cpp b/engines/gnap/menu.cpp index e2b28a6742..4381d2f1d3 100644 --- a/engines/gnap/menu.cpp +++ b/engines/gnap/menu.cpp @@ -25,6 +25,7 @@ #include "common/translation.h" #include "gui/saveload.h" +#include "graphics/thumbnail.h" #include "gnap/gnap.h" #include "gnap/datarchive.h" @@ -576,7 +577,7 @@ void GnapEngine::writeSavegameHeader(Common::OutSaveFile *out, GnapSavegameHeade out->writeString(header._saveName); out->writeByte('\0'); - // TODO: Add thumbnail + Graphics::saveThumbnail(*out); // Write out the save date/time TimeDate td; @@ -608,7 +609,13 @@ bool GnapEngine::readSavegameHeader(Common::InSaveFile *in, GnapSavegameHeader & header._saveName += ch; // TODO: Get the thumbnail - header._thumbnail = nullptr; + if (header._version == 1) + header._thumbnail = nullptr; + else { + header._thumbnail = Graphics::loadThumbnail(*in); + if (!header._thumbnail) + return false; + } // Read in save date/time header._year = in->readSint16LE(); |