diff options
author | uruk | 2013-08-20 21:26:23 +0200 |
---|---|---|
committer | uruk | 2013-08-20 21:26:23 +0200 |
commit | f8796e720eea8122bf7ecef7f1dcd75c39b75a97 (patch) | |
tree | 639c0e3ac4ce4e4bd162adae241ce6a7ec0eca98 /engines | |
parent | aab393077942224a5f376846582f7cd987366f75 (diff) | |
download | scummvm-rg350-f8796e720eea8122bf7ecef7f1dcd75c39b75a97.tar.gz scummvm-rg350-f8796e720eea8122bf7ecef7f1dcd75c39b75a97.tar.bz2 scummvm-rg350-f8796e720eea8122bf7ecef7f1dcd75c39b75a97.zip |
AVALANCHE: Add thumbnail support and version tracking to the saving/loading system. Repair Trip::trippancy_link().
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/avalanche.cpp | 24 | ||||
-rw-r--r-- | engines/avalanche/detection.cpp | 73 | ||||
-rw-r--r-- | engines/avalanche/trip6.cpp | 2 |
3 files changed, 84 insertions, 15 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index e714f0b5f6..8c893176e8 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -39,6 +39,7 @@ #include "engines/util.h" #include "gui/saveload.h" +#include "graphics/thumbnail.h" namespace Avalanche { @@ -361,19 +362,20 @@ Common::Error AvalancheEngine::saveGameState(int slot, const Common::String &des bool AvalancheEngine::saveGame(const int16 slot, const Common::String &desc) { Common::String fileName = getSaveFileName(slot); Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(fileName); - if (!f) { warning("Can't create file '%s', game not saved.", fileName.c_str()); return false; } char *signature = "AVAL"; - f->write(signature, 4); - f->writeUint32LE(desc.size()); + // Write version. We can't restore from obsolete versions. + f->writeByte(kSavegameVersion); + f->writeUint32LE(desc.size()); f->write(desc.c_str(), desc.size()); + ::Graphics::saveThumbnail(*f); TimeDate t; _system->getTimeAndDate(t); @@ -413,10 +415,9 @@ Common::Error AvalancheEngine::loadGameState(int slot) { bool AvalancheEngine::loadGame(const int16 slot) { Common::String fileName = getSaveFileName(slot); Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); - if (!f) return false; - + // Check for our signature. Common::String signature; for (byte i = 0; i < 4; i++) @@ -424,6 +425,14 @@ bool AvalancheEngine::loadGame(const int16 slot) { if (signature != "AVAL") return false; + // Check version. We can't restore from obsolete versions. + byte saveVersion = f->readByte(); + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version!"); + delete f; + return false; + } + // Read the description. uint32 descSize = f->readUint32LE(); Common::String description; @@ -433,6 +442,9 @@ bool AvalancheEngine::loadGame(const int16 slot) { } description.toUppercase(); + ::Graphics::skipThumbnail(*f); + + // Read the time the game was saved. TimeDate t; t.tm_mday = f->readSint16LE(); t.tm_mon = f->readSint16LE(); @@ -478,7 +490,7 @@ bool AvalancheEngine::loadGame(const int16 slot) { + "saved on " + expandDate(t.tm_mday, t.tm_mon, t.tm_year) + '.'); if (_trip->tr[0].quick && _trip->tr[0].visible) - _trip->rwsp(0, _gyro->dna.rw); + _trip->rwsp(0, _gyro->dna.rw); // We push Avvy in the right direction is he was moving. return true; } diff --git a/engines/avalanche/detection.cpp b/engines/avalanche/detection.cpp index a81e9a3b5f..39c6f0836f 100644 --- a/engines/avalanche/detection.cpp +++ b/engines/avalanche/detection.cpp @@ -87,6 +87,7 @@ public: int getMaximumSaveSlot() const { return 99; } SaveStateList listSaves(const char *target) const; void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; }; bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { @@ -96,7 +97,12 @@ bool AvalancheMetaEngine::createInstance(OSystem *syst, Engine **engine, const A } bool AvalancheMetaEngine::hasFeature(MetaEngineFeature f) const { - return (f == kSupportsListSaves) || (f == kSupportsDeleteSave) || (f == kSupportsLoadingDuringStartup); + return + (f == kSupportsListSaves) || + (f == kSupportsDeleteSave) || + (f == kSupportsLoadingDuringStartup) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); } SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { @@ -121,16 +127,25 @@ SaveStateList AvalancheMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { Common::InSaveFile *file = saveFileMan->openForLoading(*filename); if (file) { - /*int saveVersion = file->readByte(); + // Check for our signature. + Common::String signature; + for (byte i = 0; i < 4; i++) + signature += file->readByte(); + if (signature != "AVAL") { + warning("Savegame of incompatible type!"); + delete file; + continue; + } + // Check version. + byte saveVersion = file->readByte(); if (saveVersion != kSavegameVersion) { - warning("Savegame of incompatible version"); - delete file; - continue; - }*/ + warning("Savegame of incompatible version!"); + delete file; + continue; + } - // Read name - file->seek(4); // We skip the "AVAL" signature. + // Read name. uint32 nameSize = file->readUint32LE(); if (nameSize >= 255) { delete file; @@ -155,6 +170,48 @@ void AvalancheMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(fileName); } +SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot); + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); + + if (f) { + // Check for our signature. + Common::String signature; + for (byte i = 0; i < 4; i++) + signature += f->readByte(); + if (signature != "AVAL") { + warning("Savegame of incompatible type!"); + delete f; + return SaveStateDescriptor(); + } + + // Check version. + byte saveVersion = f->readByte(); + if (saveVersion != kSavegameVersion) { + warning("Savegame of incompatible version!"); + delete f; + return SaveStateDescriptor(); + } + + // Read the description. + uint32 descSize = f->readUint32LE(); + Common::String description; + for (uint32 i = 0; i < descSize; i++) { + char actChar = f->readByte(); + description += actChar; + } + + SaveStateDescriptor desc(slot, description); + + ::Graphics::Surface *const thumbnail = ::Graphics::loadThumbnail(*f); + desc.setThumbnail(thumbnail); + + delete f; + return desc; + } + return SaveStateDescriptor(); +} + } // End of namespace Avalanche #if PLUGIN_ENABLED_DYNAMIC(AVALANCHE) diff --git a/engines/avalanche/trip6.cpp b/engines/avalanche/trip6.cpp index 54312ce773..0009477738 100644 --- a/engines/avalanche/trip6.cpp +++ b/engines/avalanche/trip6.cpp @@ -1415,7 +1415,7 @@ void Trip::trippancy_link() { if (_vm->_gyro->ddmnow | _vm->_gyro->ontoolbar | _vm->_gyro->seescroll) return; for (fv = 0; fv < numtr; fv++) { - if (tr[fv].quick) + if (tr[fv].quick && tr[fv].visible) tr[fv].walk(); } |