From 1f2290cd30602b9e6602b38bf85bfb6da1b2c164 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 2 Dec 2017 00:51:53 +0100 Subject: FULLPIPE: Fix bug #10317: Save game metadata is missing --- engines/fullpipe/detection.cpp | 16 ++++++++++++++-- engines/fullpipe/fullpipe.cpp | 2 +- engines/fullpipe/gameloader.h | 5 +++-- engines/fullpipe/messages.cpp | 2 +- engines/fullpipe/modal.cpp | 2 +- engines/fullpipe/stateloader.cpp | 15 ++++++++------- engines/fullpipe/statesaver.cpp | 7 ++++++- 7 files changed, 34 insertions(+), 15 deletions(-) (limited to 'engines/fullpipe') diff --git a/engines/fullpipe/detection.cpp b/engines/fullpipe/detection.cpp index 82c7954ced..9dd1d6beb4 100644 --- a/engines/fullpipe/detection.cpp +++ b/engines/fullpipe/detection.cpp @@ -156,6 +156,7 @@ bool FullpipeMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSavesSupportMetaInfo) || (f == kSavesSupportThumbnail) || (f == kSavesSupportCreationDate) || + (f == kSavesSupportPlayTime) || (f == kSupportsLoadingDuringStartup) || (f == kSimpleSavesNames); } @@ -184,7 +185,14 @@ SaveStateList FullpipeMetaEngine::listSaves(const char *target) const { if (in) { Fullpipe::FullpipeSavegameHeader header; Fullpipe::readSavegameHeader(in.get(), header); - saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); + + SaveStateDescriptor desc; + + parseSavegameHeader(header, desc); + + desc.setSaveSlot(slotNum); + + saveList.push_back(desc); } } } @@ -207,7 +215,11 @@ SaveStateDescriptor FullpipeMetaEngine::querySaveMetaInfos(const char *target, i Fullpipe::readSavegameHeader(f.get(), header); // Create the return descriptor - SaveStateDescriptor desc(slot, header.saveName); + SaveStateDescriptor desc; + + parseSavegameHeader(header, desc); + + desc.setSaveSlot(slot); desc.setThumbnail(header.thumbnail); return desc; diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index f50593cc3a..ec2b5aa71d 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -239,7 +239,7 @@ Common::Error FullpipeEngine::loadGameState(int slot) { } Common::Error FullpipeEngine::saveGameState(int slot, const Common::String &description) { - if (_gameLoader->writeSavegame(_currentScene, getSavegameFile(slot))) + if (_gameLoader->writeSavegame(_currentScene, getSavegameFile(slot), description)) return Common::kNoError; else return Common::kUnknownError; diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index f76a96f494..03c3093086 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -32,7 +32,7 @@ namespace Fullpipe { -#define FULLPIPE_SAVEGAME_VERSION 1 +#define FULLPIPE_SAVEGAME_VERSION 2 class SceneTag; class MctlCompound; @@ -80,6 +80,7 @@ struct FullpipeSavegameHeader { char id[6]; uint8 version; Common::String saveName; + Common::String description; uint32 date; uint16 time; uint32 playtime; @@ -115,7 +116,7 @@ class GameLoader : public CObject { PicAniInfoList savePicAniInfos(Scene *sc, int flag1, int flag2); bool readSavegame(const char *fname); - bool writeSavegame(Scene *sc, const char *fname); + bool writeSavegame(Scene *sc, const char *fname, const Common::String &description); void addVar(GameVar *var, GameVar *subvar); diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index bd8dff8009..f08397f2ee 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -353,7 +353,7 @@ void MessageQueue::messageQueueCallback1(int par) { } if (g_fp->_currentScene) - g_fp->_gameLoader->writeSavegame(g_fp->_currentScene, "savetmp.sav"); + g_fp->_gameLoader->writeSavegame(g_fp->_currentScene, "savetmp.sav", ""); } } diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index 316369c0b0..be1e73ff70 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -2285,7 +2285,7 @@ void ModalSaveGame::saveload() { } if (g_fp->_isSaveAllowed && allowed) - g_fp->_gameLoader->writeSavegame(g_fp->_currentScene, getSaveName()); + g_fp->_gameLoader->writeSavegame(g_fp->_currentScene, getSaveName(), ""); } } else { if (getSaveName()) { diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 231379cddc..703190be0b 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -178,7 +178,7 @@ void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDesc desc.setSaveTime(hour, minutes); desc.setPlayTime(header.playtime * 1000); - desc.setDescription(header.saveName); + desc.setDescription(header.description); } void fillDummyHeader(Fullpipe::FullpipeSavegameHeader &header) { @@ -214,22 +214,23 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) } header.version = in->readByte(); - if (header.version != FULLPIPE_SAVEGAME_VERSION) { - in->seek(oldPos, SEEK_SET); // Rewind the file - fillDummyHeader(header); - return false; - } - header.date = in->readUint32LE(); header.time = in->readUint16LE(); header.playtime = in->readUint32LE(); + if (header.version > 1) + header.description = in->readPascalString(); + // Generate savename SaveStateDescriptor desc; parseSavegameHeader(header, desc); + header.saveName = Common::String::format("%s %s", desc.getSaveDate().c_str(), desc.getSaveTime().c_str()); + if (header.description.empty()) + header.description = header.saveName; + // Get the thumbnail header.thumbnail = Common::SharedPtr(Graphics::loadThumbnail(*in), Graphics::SurfaceDeleter()); diff --git a/engines/fullpipe/statesaver.cpp b/engines/fullpipe/statesaver.cpp index d06bd9c593..942c07ae53 100644 --- a/engines/fullpipe/statesaver.cpp +++ b/engines/fullpipe/statesaver.cpp @@ -31,7 +31,7 @@ namespace Fullpipe { -bool GameLoader::writeSavegame(Scene *sc, const char *fname) { +bool GameLoader::writeSavegame(Scene *sc, const char *fname, const Common::String &description) { GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); if (!v) { @@ -146,6 +146,11 @@ bool GameLoader::writeSavegame(Scene *sc, const char *fname) { saveFile->writeUint16LE(header2.time); saveFile->writeUint32LE(header2.playtime); + // Added in save version 2 + Common::String desc(description.c_str(), MIN(255u, description.size())); // Restrict description size + saveFile->writeByte(desc.size()); + saveFile->writeString(desc); + g_fp->_currentScene->draw(); Graphics::saveThumbnail(*saveFile); // FIXME. Render proper screen -- cgit v1.2.3