[Scummvm-git-logs] scummvm master -> 3498965e66192b46ea1d8fc8fa8391b5f984f2ad
bgK
bastien.bouclet at gmail.com
Mon Feb 17 19:02:05 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3498965e66 MOHAWK: Remove the autosave overwrite check
Commit: 3498965e66192b46ea1d8fc8fa8391b5f984f2ad
https://github.com/scummvm/scummvm/commit/3498965e66192b46ea1d8fc8fa8391b5f984f2ad
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-02-17T20:01:44+01:00
Commit Message:
MOHAWK: Remove the autosave overwrite check
This check is now performed by the shared autosave code.
Changed paths:
engines/mohawk/myst.cpp
engines/mohawk/myst.h
engines/mohawk/myst_state.cpp
engines/mohawk/myst_state.h
engines/mohawk/riven.cpp
engines/mohawk/riven_saveload.cpp
engines/mohawk/riven_saveload.h
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index d6946e1..54426a0 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -970,10 +970,6 @@ Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &d
return _gameState->save(slot, desc, thumbnail, isAutosave) ? Common::kNoError : Common::kUnknownError;
}
-bool MohawkEngine_Myst::canSaveAutosaveCurrently() {
- return canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed();
-}
-
bool MohawkEngine_Myst::hasGameSaveSupport() const {
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
}
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 397c820..2785740 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -192,7 +192,6 @@ public:
Common::String getSaveStateName(int slot) const override {
return Common::String::format("myst-%03d.mys", slot);
}
- virtual bool canSaveAutosaveCurrently() override;
bool hasFeature(EngineFeature f) const override;
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp
index edf744c..c23d01c 100644
--- a/engines/mohawk/myst_state.cpp
+++ b/engines/mohawk/myst_state.cpp
@@ -271,41 +271,24 @@ bool MystGameState::saveMetadata(int slot, const Graphics::Surface *thumbnail) {
return true;
}
-bool MystGameState::isAutoSaveAllowed() {
- // Open autosave slot and see if it an autosave
- // Autosaving will be enabled if it is an autosave or if there is no save in that slot
-
- Common::String dataFilename = buildSaveFilename(kAutoSaveSlot);
- Common::ScopedPtr<Common::InSaveFile> dataFile(g_system->getSavefileManager()->openForLoading(dataFilename));
- if (!dataFile) { // Cannot load non-meta file, enable autosave
- return true;
- }
-
- Common::String metaFilename = buildMetadataFilename(kAutoSaveSlot);
- Common::ScopedPtr<Common::InSaveFile> metadataFile(g_system->getSavefileManager()->openForLoading(metaFilename));
- if (!metadataFile) { // Can load non-meta file, but not metafile, could be a save from the original, disable autosave
- return false;
- }
-
- Common::Serializer m(metadataFile.get(), nullptr);
+SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
+ SaveStateDescriptor desc;
+ desc.setWriteProtectedFlag(slot == kAutoSaveSlot);
- // Read the metadata file
- Mohawk::MystSaveMetadata metadata;
- if (!metadata.sync(m)) { // the save in the autosave slot is corrupted, enable autosave
- return true;
+ // Open the save file
+ Common::String filename = buildSaveFilename(slot);
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(filename);
+ if (!saveFile) {
+ return desc;
}
+ delete saveFile;
- return metadata.autoSave;
-}
+ // There is a save in the slot
+ desc.setSaveSlot(slot);
-SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
// Open the metadata file
- Common::String filename = buildMetadataFilename(slot);
+ filename = buildMetadataFilename(slot);
Common::InSaveFile *metadataFile = g_system->getSavefileManager()->openForLoading(filename);
-
- SaveStateDescriptor desc;
- desc.setWriteProtectedFlag(slot == kAutoSaveSlot);
-
if (!metadataFile) {
return desc;
}
@@ -320,7 +303,6 @@ SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
}
// Set the save description
- desc.setSaveSlot(slot);
desc.setDescription(metadata.saveDescription);
desc.setSaveDate(metadata.saveYear, metadata.saveMonth, metadata.saveDay);
desc.setSaveTime(metadata.saveHour, metadata.saveMinute);
diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h
index a3bb38b..e9f1860 100644
--- a/engines/mohawk/myst_state.h
+++ b/engines/mohawk/myst_state.h
@@ -111,7 +111,6 @@ public:
void reset();
bool load(int slot);
bool save(int slot, const Common::String &desc, const Graphics::Surface *thumbnail, bool autosave);
- bool isAutoSaveAllowed();
static void deleteSave(int slot);
void addZipDest(MystStack stack, uint16 view);
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index c6d66f1..d4a89c5 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -748,8 +748,7 @@ void MohawkEngine_Riven::saveGameStateAndDisplayError(int slot, const Common::St
}
bool MohawkEngine_Riven::canSaveAutosaveCurrently() {
- return canSaveGameStateCurrently() && !_gameEnded &&
- _saveLoad->isAutoSaveAllowed();
+ return canSaveGameStateCurrently() && !_gameEnded;
}
void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp
index a57ba9e..5937458 100644
--- a/engines/mohawk/riven_saveload.cpp
+++ b/engines/mohawk/riven_saveload.cpp
@@ -164,40 +164,6 @@ SaveStateDescriptor RivenSaveLoad::querySaveMetaInfos(const int slot) {
return descriptor;
}
-bool RivenSaveLoad::isAutoSaveAllowed() {
- // Open autosave slot and see if it an autosave
- // Autosaving will be enabled if it is an autosave or if there is no save in that slot
-
- Common::String filename = buildSaveFilename(_vm->getAutosaveSlot());
- Common::InSaveFile *loadFile = g_system->getSavefileManager()->openForLoading(filename);
- if (!loadFile) {
- return true; // There is no save in the autosave slot, enable autosave
- }
-
- MohawkArchive mhk;
- if (!mhk.openStream(loadFile)) {
- return true; // Corrupt save, enable autosave
- }
-
- if (!mhk.hasResource(ID_META, 1)) {
- return false; // don't autosave over saves that don't have a meta section (like saves from the original)
- }
-
- Common::ScopedPtr<Common::SeekableReadStream> metaStream(mhk.getResource(ID_META, 1));
- if (!metaStream) {
- return true; // corrupt save, enable autosave
- }
-
- Common::Serializer serializer = Common::Serializer(metaStream.get(), nullptr);
-
- RivenSaveMetadata metadata;
- if (!metadata.sync(serializer)) {
- return true; // corrupt save, enable autosave
- }
-
- return metadata.autoSave;
-}
-
Common::Error RivenSaveLoad::loadGame(const int slot) {
if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo
return Common::kNoError;
diff --git a/engines/mohawk/riven_saveload.h b/engines/mohawk/riven_saveload.h
index fba8f28..4cdbdd1 100644
--- a/engines/mohawk/riven_saveload.h
+++ b/engines/mohawk/riven_saveload.h
@@ -65,7 +65,6 @@ public:
Common::Error loadGame(const int slot);
Common::Error saveGame(const int slot, const Common::String &description,
const Graphics::Surface *thumbnail, bool autoSave);
- bool isAutoSaveAllowed();
static void deleteSave(const int slot);
static SaveStateDescriptor querySaveMetaInfos(const int slot);
More information about the Scummvm-git-logs
mailing list