Permalink
Browse files

FULLPIPE: Fix bug #10317: Save game metadata is missing

  • Loading branch information...
sev- committed Dec 1, 2017
1 parent c0afab5 commit 7d482d78cf882132b4d7cc3f558552a04c2b1bc7
@@ -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;
@@ -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;
@@ -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);
@@ -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", "");
}
}
@@ -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()) {
@@ -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::Surface>(Graphics::loadThumbnail(*in), Graphics::SurfaceDeleter());
@@ -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

0 comments on commit 7d482d7

Please sign in to comment.