[Scummvm-cvs-logs] scummvm master -> aa26d5def4265d496c03ef81fb2aa128020b08d4

digitall digitall at scummvm.org
Tue Feb 21 23:35:26 CET 2012


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:
aa26d5def4 ENGINES: Add error handling for GMM Gamestate Load/Save Usage.


Commit: aa26d5def4265d496c03ef81fb2aa128020b08d4
    https://github.com/scummvm/scummvm/commit/aa26d5def4265d496c03ef81fb2aa128020b08d4
Author: D G Turner (digitall at scummvm.org)
Date: 2012-02-21T14:30:29-08:00

Commit Message:
ENGINES: Add error handling for GMM Gamestate Load/Save Usage.

As indicated by wjp, the Global Main Menu (GMM) did not check or report
on the returned error state from saveGameState() and loadGameState() usage.
This corrects this and adds a MessageDialog report of any failure.

Changed paths:
    engines/dialogs.cpp
    engines/engine.cpp



diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index 435576e..1b54c7e 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -227,19 +227,24 @@ void MainMenuDialog::save() {
 		Common::String result(_saveDialog->getResultString());
 		if (result.empty()) {
 			// If the user was lazy and entered no save name, come up with a default name.
-			Common::String buf;
 			#if defined(USE_SAVEGAME_TIMESTAMP)
 			TimeDate curTime;
 			g_system->getTimeAndDate(curTime);
 			curTime.tm_year += 1900; // fixup year
 			curTime.tm_mon++; // fixup month
-			buf = Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec);
+			result = Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec);
 			#else
-			buf = Common::String::format("Save %d", slot + 1);
+			result = Common::String::format("Save %d", slot + 1);
 			#endif
-			_engine->saveGameState(slot, buf);
-		} else {
-			_engine->saveGameState(slot, result);
+		}
+
+		Common::Error status = _engine->saveGameState(slot, result);
+		if (status.getCode() != Common::kNoError) {
+			Common::String failMessage = Common::String::format(_("Gamestate save failed (%s)! "
+				  "Please consult the README for basic information, and for "
+				  "instructions on how to obtain further assistance."), status.getDesc().c_str());
+			GUI::MessageDialog dialog(failMessage);
+			dialog.runModal();			
 		}
 
 		close();
@@ -256,7 +261,7 @@ void MainMenuDialog::load() {
 
 	_engine->setGameToLoadSlot(slot);
 
-	if (slot >= 0)		
+	if (slot >= 0)
 		close();
 }
 
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 4811ba6..2ef4eca 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -420,12 +420,16 @@ void Engine::openMainMenuDialog() {
 	// (not from inside the menu loop to avoid
 	// mouse cursor glitches and simliar bugs,
 	// e.g. #2822778).
-	// FIXME: For now we just ignore the return
-	// value, which is quite bad since it could
-	// be a fatal loading error, which renders
-	// the engine unusable.
-	if (_saveSlotToLoad >= 0)
-		loadGameState(_saveSlotToLoad);
+	if (_saveSlotToLoad >= 0) {
+		Common::Error status = loadGameState(_saveSlotToLoad);
+		if (status.getCode() != Common::kNoError) {
+			Common::String failMessage = Common::String::format(_("Gamestate load failed (%s)! "
+				  "Please consult the README for basic information, and for "
+				  "instructions on how to obtain further assistance."), status.getDesc().c_str());
+			GUI::MessageDialog dialog(failMessage);
+			dialog.runModal();
+		}
+	}
 
 	syncSoundSettings();
 }






More information about the Scummvm-git-logs mailing list