aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/detection.cpp
diff options
context:
space:
mode:
authoruruk2013-08-20 21:26:23 +0200
committeruruk2013-08-20 21:26:23 +0200
commitf8796e720eea8122bf7ecef7f1dcd75c39b75a97 (patch)
tree639c0e3ac4ce4e4bd162adae241ce6a7ec0eca98 /engines/avalanche/detection.cpp
parentaab393077942224a5f376846582f7cd987366f75 (diff)
downloadscummvm-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/avalanche/detection.cpp')
-rw-r--r--engines/avalanche/detection.cpp73
1 files changed, 65 insertions, 8 deletions
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)