ENGINES: Autosave won't save over a custom save in it's slot

This commit is contained in:
Paul Gilbert 2020-02-09 19:08:23 -08:00 committed by Paul Gilbert
parent 91801a9c55
commit 4f26f2c7ef
2 changed files with 23 additions and 4 deletions

View File

@ -495,13 +495,23 @@ void Engine::handleAutoSave() {
void Engine::saveAutosaveIfEnabled() {
if (_autosaveInterval != 0) {
bool canSave = canSaveAutosaveCurrently();
bool saveFlag = canSaveAutosaveCurrently();
Common::String saveName = _("Autosave");
if (!canSave || saveGameState(getAutosaveSlot(), _("Autosave"), true).getCode() != Common::kNoError) {
if (saveFlag) {
// First check for an existing savegame in the slot, and if present, if it's an autosave
SaveStateDescriptor desc = getMetaEngine().querySaveMetaInfos(
_targetName.c_str(), getAutosaveSlot());
saveFlag = desc.getSaveSlot() == -1 || desc.getDescription() == saveName;
}
if (saveFlag && saveGameState(getAutosaveSlot(), saveName, true).getCode() != Common::kNoError) {
// Couldn't autosave at the designated time
if (!canSave)
g_system->displayMessageOnOSD(_("Error occurred making autosave"));
saveFlag = false;
}
if (!saveFlag) {
// Set the next autosave interval to be in 5 minutes, rather than whatever
// full autosave interval the user has selected
_lastAutosaveTime = _system->getMillis() + (5 * 60 * 1000) - _autosaveInterval;
@ -799,3 +809,9 @@ EnginePlugin *Engine::getMetaEnginePlugin() const {
}
*/
MetaEngine &Engine::getMetaEngine() {
const Plugin *plugin = EngineMan.findPlugin(ConfMan.get("engineid"));
assert(plugin);
return plugin->get<MetaEngine>();
}

View File

@ -31,6 +31,7 @@
#include "common/singleton.h"
class OSystem;
class MetaEngine;
namespace Audio {
class Mixer;
@ -323,6 +324,8 @@ public:
*/
static bool shouldQuit();
static MetaEngine &getMetaEngine();
/**
* Pause or resume the engine. This should stop/resume any audio playback
* and other stuff. Called right before the system runs a global dialog