[Scummvm-git-logs] scummvm master -> 5ee24f3970d7c2d5868e44dd1a2eece83e013cb7

bgK bastien.bouclet at gmail.com
Sun May 20 10:07:45 CEST 2018


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:
5ee24f3970 MOHAWK: MYST: Fix repeatedly trying to autosave when not allowed


Commit: 5ee24f3970d7c2d5868e44dd1a2eece83e013cb7
    https://github.com/scummvm/scummvm/commit/5ee24f3970d7c2d5868e44dd1a2eece83e013cb7
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2018-05-20T10:05:12+02:00

Commit Message:
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.

Changed paths:
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h


diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 1355b86..a01cfdd 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -398,9 +398,8 @@ void MohawkEngine_Myst::doFrame() {
 		_waitingOnBlockingOperation = false;
 	}
 
-	if (shouldPerformAutoSave(_lastSaveTime) && canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
-		autoSave();
-		_lastSaveTime = _system->getMillis();
+	if (shouldPerformAutoSave(_lastSaveTime)) {
+		tryAutoSaving();
 	}
 
 	Common::Event event;
@@ -455,10 +454,8 @@ void MohawkEngine_Myst::doFrame() {
 
 						if (_needsShowCredits) {
 							if (isInteractive()) {
-								if (canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
-									// Attempt to autosave before exiting
-									autoSave();
-								}
+								// Attempt to autosave before exiting
+								tryAutoSaving();
 
 								_cursor->hideCursor();
 								changeToStack(kCreditsStack, 10000, 0, 0);
@@ -489,10 +486,8 @@ void MohawkEngine_Myst::doFrame() {
 				break;
 			case Common::EVENT_QUIT:
 			case Common::EVENT_RTL:
-				if (canSaveGameStateCurrently() && _gameState->isAutoSaveAllowed()) {
-					// Attempt to autosave before exiting
-					autoSave();
-				}
+				// Attempt to autosave before exiting
+				tryAutoSaving();
 				break;
 			default:
 				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;
 }
 
-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))
 		warning("Attempt to autosave has failed.");
 }
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 5c23870..64fee10 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -245,7 +245,7 @@ public:
 	bool canSaveGameStateCurrently() override;
 	Common::Error loadGameState(int slot) override;
 	Common::Error saveGameState(int slot, const Common::String &desc) override;
-	void autoSave();
+	void tryAutoSaving();
 	bool hasFeature(EngineFeature f) const override;
 
 private:





More information about the Scummvm-git-logs mailing list