MOHAWK: MYST: Fix repeatedly trying to autosave when not allowed
Fixes trying to open the save on slot 0 on each frame when it is not an autosave.
This commit is contained in:
parent
98067b0fe6
commit
5ee24f3970
2 changed files with 18 additions and 13 deletions
|
@ -398,9 +398,8 @@ void MohawkEngine_Myst::doFrame() {
|
||||||
_waitingOnBlockingOperation = false;
|
_waitingOnBlockingOperation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldPerformAutoSave(_lastSaveTime) && canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
|
if (shouldPerformAutoSave(_lastSaveTime)) {
|
||||||
autoSave();
|
tryAutoSaving();
|
||||||
_lastSaveTime = _system->getMillis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Event event;
|
Common::Event event;
|
||||||
|
@ -455,10 +454,8 @@ void MohawkEngine_Myst::doFrame() {
|
||||||
|
|
||||||
if (_needsShowCredits) {
|
if (_needsShowCredits) {
|
||||||
if (isInteractive()) {
|
if (isInteractive()) {
|
||||||
if (canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
|
// Attempt to autosave before exiting
|
||||||
// Attempt to autosave before exiting
|
tryAutoSaving();
|
||||||
autoSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
_cursor->hideCursor();
|
_cursor->hideCursor();
|
||||||
changeToStack(kCreditsStack, 10000, 0, 0);
|
changeToStack(kCreditsStack, 10000, 0, 0);
|
||||||
|
@ -489,10 +486,8 @@ void MohawkEngine_Myst::doFrame() {
|
||||||
break;
|
break;
|
||||||
case Common::EVENT_QUIT:
|
case Common::EVENT_QUIT:
|
||||||
case Common::EVENT_RTL:
|
case Common::EVENT_RTL:
|
||||||
if (canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
|
// Attempt to autosave before exiting
|
||||||
// Attempt to autosave before exiting
|
tryAutoSaving();
|
||||||
autoSave();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1181,7 +1176,17 @@ Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &d
|
||||||
return _gameState->save(slot, desc, false) ? Common::kNoError : Common::kUnknownError;
|
return _gameState->save(slot, desc, false) ? Common::kNoError : Common::kUnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MohawkEngine_Myst::autoSave() {
|
void MohawkEngine_Myst::tryAutoSaving() {
|
||||||
|
if (!canSaveGameStateCurrently()) {
|
||||||
|
return; // Can't save right now, try again on the next frame
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastSaveTime = _system->getMillis();
|
||||||
|
|
||||||
|
if (!_gameState->isAutoSaveAllowed()) {
|
||||||
|
return; // Can't autosave ever, try again after the next autosave delay
|
||||||
|
}
|
||||||
|
|
||||||
if (!_gameState->save(MystGameState::kAutoSaveSlot, "Autosave", true))
|
if (!_gameState->save(MystGameState::kAutoSaveSlot, "Autosave", true))
|
||||||
warning("Attempt to autosave has failed.");
|
warning("Attempt to autosave has failed.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ public:
|
||||||
bool canSaveGameStateCurrently() override;
|
bool canSaveGameStateCurrently() override;
|
||||||
Common::Error loadGameState(int slot) override;
|
Common::Error loadGameState(int slot) override;
|
||||||
Common::Error saveGameState(int slot, const Common::String &desc) override;
|
Common::Error saveGameState(int slot, const Common::String &desc) override;
|
||||||
void autoSave();
|
void tryAutoSaving();
|
||||||
bool hasFeature(EngineFeature f) const override;
|
bool hasFeature(EngineFeature f) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue