[Scummvm-git-logs] scummvm master -> c3bbae041aeee11bff358e421d472b5f60896c5a

bgK bastien.bouclet at gmail.com
Wed Jul 12 22:04:49 CEST 2017


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:
c3bbae041a MOHAWK: Riven: Improve save load error handling


Commit: c3bbae041aeee11bff358e421d472b5f60896c5a
    https://github.com/scummvm/scummvm/commit/c3bbae041aeee11bff358e421d472b5f60896c5a
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2017-07-12T22:00:33+02:00

Commit Message:
MOHAWK: Riven: Improve save load error handling

A GUI error message is now displayed if an error occurs when loading a
save.

Changed paths:
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_saveload.cpp


diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 03afafe..21cc701 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -27,6 +27,7 @@
 #include "common/translation.h"
 #include "common/system.h"
 #include "gui/saveload.h"
+#include "gui/message.h"
 
 #include "mohawk/cursors.h"
 #include "mohawk/installer_archive.h"
@@ -173,10 +174,10 @@ Common::Error MohawkEngine_Riven::run() {
 		// Load game from launcher/command line if requested
 		int gameToLoad = ConfMan.getInt("save_slot");
 
-		// Attempt to load the game. On failure, just send us to the main menu.
-		if (_saveLoad->loadGame(gameToLoad).getCode() != Common::kNoError) {
-			changeToStack(kStackAspit);
-			changeToCard(1);
+		// Attempt to load the game.
+		Common::Error loadError = _saveLoad->loadGame(gameToLoad);
+		if (loadError.getCode() != Common::kNoError) {
+			return loadError;
 		}
 	} else {
 		// Otherwise, start us off at aspit's card 1 (the main menu)
@@ -227,7 +228,7 @@ void MohawkEngine_Riven::doFrame() {
 			case Common::KEYCODE_F5:
 				runDialog(*_optionsDialog);
 				if (_optionsDialog->getLoadSlot() >= 0)
-					loadGameState(_optionsDialog->getLoadSlot());
+					loadGameStateAndDisplayError(_optionsDialog->getLoadSlot());
 				_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
 				_card->initializeZipMode();
 				break;
@@ -433,14 +434,26 @@ void MohawkEngine_Riven::runLoadDialog() {
 	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
 
 	int slot = slc.runModalWithCurrentTarget();
-	if (slot >= 0)
-		loadGameState(slot);
+	if (slot >= 0) {
+		loadGameStateAndDisplayError(slot);
+	}
 }
 
 Common::Error MohawkEngine_Riven::loadGameState(int slot) {
 	return _saveLoad->loadGame(slot);
 }
 
+void MohawkEngine_Riven::loadGameStateAndDisplayError(int slot) {
+	assert(slot >= 0);
+
+	Common::Error loadError = loadGameState(slot);
+
+	if (loadError.getCode() != Common::kNoError) {
+		GUI::MessageDialog dialog(loadError.getDesc());
+		dialog.runModal();
+	}
+}
+
 Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &desc) {
 	return _saveLoad->saveGame(slot, desc);
 }
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 908deb7..0bd6fc6 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -99,6 +99,7 @@ public:
 	bool canLoadGameStateCurrently();
 	bool canSaveGameStateCurrently();
 	Common::Error loadGameState(int slot);
+	void loadGameStateAndDisplayError(int slot);
 	Common::Error saveGameState(int slot, const Common::String &desc);
 	bool hasFeature(EngineFeature f) const;
 
diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp
index 0d70123..c83862d 100644
--- a/engines/mohawk/riven_saveload.cpp
+++ b/engines/mohawk/riven_saveload.cpp
@@ -180,9 +180,9 @@ Common::Error RivenSaveLoad::loadGame(const int slot) {
 	delete vers;
 	if ((saveGameVersion == kCDSaveGameVersion && (_vm->getFeatures() & GF_DVD))
 		|| (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) {
-		warning("Incompatible saved game versions. No support for this yet");
+		warning("Unable to load: Saved game created using an incompatible game version - CD vs DVD");
 		delete mhk;
-		return Common::Error(Common::kUnknownError, "Incompatible save version");
+		return Common::Error(Common::kUnknownError, "Saved game created using an incompatible game version - CD vs DVD");
 	}
 
 	// Now, we'll read in the variable values.





More information about the Scummvm-git-logs mailing list