mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 05:01:43 +00:00
MOHAWK: Remove the autosave overwrite check
This check is now performed by the shared autosave code.
This commit is contained in:
parent
1b83be60a4
commit
3498965e66
@ -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;
|
return _gameState->save(slot, desc, thumbnail, isAutosave) ? Common::kNoError : Common::kUnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MohawkEngine_Myst::canSaveAutosaveCurrently() {
|
|
||||||
return canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MohawkEngine_Myst::hasGameSaveSupport() const {
|
bool MohawkEngine_Myst::hasGameSaveSupport() const {
|
||||||
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
|
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,6 @@ public:
|
|||||||
Common::String getSaveStateName(int slot) const override {
|
Common::String getSaveStateName(int slot) const override {
|
||||||
return Common::String::format("myst-%03d.mys", slot);
|
return Common::String::format("myst-%03d.mys", slot);
|
||||||
}
|
}
|
||||||
virtual bool canSaveAutosaveCurrently() override;
|
|
||||||
|
|
||||||
bool hasFeature(EngineFeature f) const override;
|
bool hasFeature(EngineFeature f) const override;
|
||||||
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
|
static Common::Array<Common::Keymap *> initKeymaps(const char *target);
|
||||||
|
@ -271,41 +271,24 @@ bool MystGameState::saveMetadata(int slot, const Graphics::Surface *thumbnail) {
|
|||||||
return true;
|
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);
|
|
||||||
|
|
||||||
// Read the metadata file
|
|
||||||
Mohawk::MystSaveMetadata metadata;
|
|
||||||
if (!metadata.sync(m)) { // the save in the autosave slot is corrupted, enable autosave
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return metadata.autoSave;
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
|
SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
|
||||||
// Open the metadata file
|
|
||||||
Common::String filename = buildMetadataFilename(slot);
|
|
||||||
Common::InSaveFile *metadataFile = g_system->getSavefileManager()->openForLoading(filename);
|
|
||||||
|
|
||||||
SaveStateDescriptor desc;
|
SaveStateDescriptor desc;
|
||||||
desc.setWriteProtectedFlag(slot == kAutoSaveSlot);
|
desc.setWriteProtectedFlag(slot == kAutoSaveSlot);
|
||||||
|
|
||||||
|
// Open the save file
|
||||||
|
Common::String filename = buildSaveFilename(slot);
|
||||||
|
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(filename);
|
||||||
|
if (!saveFile) {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
delete saveFile;
|
||||||
|
|
||||||
|
// There is a save in the slot
|
||||||
|
desc.setSaveSlot(slot);
|
||||||
|
|
||||||
|
// Open the metadata file
|
||||||
|
filename = buildMetadataFilename(slot);
|
||||||
|
Common::InSaveFile *metadataFile = g_system->getSavefileManager()->openForLoading(filename);
|
||||||
if (!metadataFile) {
|
if (!metadataFile) {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
@ -320,7 +303,6 @@ SaveStateDescriptor MystGameState::querySaveMetaInfos(int slot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the save description
|
// Set the save description
|
||||||
desc.setSaveSlot(slot);
|
|
||||||
desc.setDescription(metadata.saveDescription);
|
desc.setDescription(metadata.saveDescription);
|
||||||
desc.setSaveDate(metadata.saveYear, metadata.saveMonth, metadata.saveDay);
|
desc.setSaveDate(metadata.saveYear, metadata.saveMonth, metadata.saveDay);
|
||||||
desc.setSaveTime(metadata.saveHour, metadata.saveMinute);
|
desc.setSaveTime(metadata.saveHour, metadata.saveMinute);
|
||||||
|
@ -111,7 +111,6 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
bool load(int slot);
|
bool load(int slot);
|
||||||
bool save(int slot, const Common::String &desc, const Graphics::Surface *thumbnail, bool autosave);
|
bool save(int slot, const Common::String &desc, const Graphics::Surface *thumbnail, bool autosave);
|
||||||
bool isAutoSaveAllowed();
|
|
||||||
static void deleteSave(int slot);
|
static void deleteSave(int slot);
|
||||||
|
|
||||||
void addZipDest(MystStack stack, uint16 view);
|
void addZipDest(MystStack stack, uint16 view);
|
||||||
|
@ -748,8 +748,7 @@ void MohawkEngine_Riven::saveGameStateAndDisplayError(int slot, const Common::St
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MohawkEngine_Riven::canSaveAutosaveCurrently() {
|
bool MohawkEngine_Riven::canSaveAutosaveCurrently() {
|
||||||
return canSaveGameStateCurrently() && !_gameEnded &&
|
return canSaveGameStateCurrently() && !_gameEnded;
|
||||||
_saveLoad->isAutoSaveAllowed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
|
void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
|
||||||
|
@ -164,40 +164,6 @@ SaveStateDescriptor RivenSaveLoad::querySaveMetaInfos(const int slot) {
|
|||||||
return descriptor;
|
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) {
|
Common::Error RivenSaveLoad::loadGame(const int slot) {
|
||||||
if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo
|
if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
|
@ -65,7 +65,6 @@ public:
|
|||||||
Common::Error loadGame(const int slot);
|
Common::Error loadGame(const int slot);
|
||||||
Common::Error saveGame(const int slot, const Common::String &description,
|
Common::Error saveGame(const int slot, const Common::String &description,
|
||||||
const Graphics::Surface *thumbnail, bool autoSave);
|
const Graphics::Surface *thumbnail, bool autoSave);
|
||||||
bool isAutoSaveAllowed();
|
|
||||||
static void deleteSave(const int slot);
|
static void deleteSave(const int slot);
|
||||||
|
|
||||||
static SaveStateDescriptor querySaveMetaInfos(const int slot);
|
static SaveStateDescriptor querySaveMetaInfos(const int slot);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user