[Scummvm-git-logs] scummvm branch-2-7 -> 89470213337a11446a44caafbd1b36bd9759381b

somaen noreply at scummvm.org
Sun Feb 12 08:54:38 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4a36b04c2f BASE: Filter out old graphics modes when passed to -g
8947021333 BASE: Wrap -g setGraphicsMode in transactions.


Commit: 4a36b04c2ffc2d0453f906559a9940659ce90355
    https://github.com/scummvm/scummvm/commit/4a36b04c2ffc2d0453f906559a9940659ce90355
Author: Einar Johan Trøan Sømåen (somaen at scummvm.org)
Date: 2023-02-12T09:51:42+01:00

Commit Message:
BASE: Filter out old graphics modes when passed to -g

Fix #12775

Changed paths:
    base/main.cpp
    base/plugins.cpp
    graphics/scalerplugin.h


diff --git a/base/main.cpp b/base/main.cpp
index 3700cd0babe..07126784e76 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -84,6 +84,7 @@
 #if defined(__DC__)
 #include "backends/platform/dc/DCLauncherDialog.h"
 #else
+#include "graphics/scalerplugin.h"
 #include "gui/launcher.h"
 #endif
 
@@ -587,6 +588,19 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
 	}
 #endif
 
+	// If we received an old style graphics mode parameter via command line
+	// override it to default at this stage, so that the backend init won't
+	// pass it onto updateOldSettings(). If it happened to be a valid new
+	// graphics mode, we'll put it back after initBackend().
+	Common::String gfxModeSetting;
+	if (settings.contains("gfx-mode")) {
+		gfxModeSetting = settings["gfx-mode"];
+		if (ScalerMan.isOldGraphicsSetting(gfxModeSetting)) {
+			settings["gfx-mode"] = "default";
+			ConfMan.set("gfx_mode", settings["gfx-mode"], Common::ConfigManager::kSessionDomain);
+		}
+	}
+
 	// Init the backend. Must take place after all config data (including
 	// the command line params) was read.
 	system.initBackend();
@@ -595,19 +609,22 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
 	// we check this here. We can't do it until after the backend is inited,
 	// or there won't be a graphics manager to ask for the supported modes.
 
-	if (settings.contains("gfx-mode")) {
+	if (!gfxModeSetting.empty()) {
 		const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
-		Common::String option = settings["gfx-mode"];
 		bool isValid = false;
 
 		while (gm->name && !isValid) {
-			isValid = !scumm_stricmp(gm->name, option.c_str());
+			isValid = !scumm_stricmp(gm->name, gfxModeSetting.c_str());
 			gm++;
 		}
 		if (!isValid) {
-			warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
-			settings["gfx-mode"] = "default";
+			// We will actually already have switched to default, but couldn't be sure that it was right until now.
+			warning("Unrecognized graphics mode '%s'. Switching to default mode", gfxModeSetting.c_str());
+		} else {
+			settings["gfx-mode"] = gfxModeSetting;
+			system.setGraphicsMode(gfxModeSetting.c_str());
 		}
+		ConfMan.set("gfx_mode", gfxModeSetting, Common::ConfigManager::kSessionDomain);
 	}
 	if (settings.contains("disable-display")) {
 		ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
diff --git a/base/plugins.cpp b/base/plugins.cpp
index cefe7401168..ee807aac4b8 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -1081,6 +1081,15 @@ static const LegacyGraphicsMode s_legacyGraphicsModes[] = {
 	{ "tv2x", "tv", 2 }
 };
 
+bool ScalerManager::isOldGraphicsSetting(const Common::String &gfxMode) {
+	for (uint i = 0; i < ARRAYSIZE(s_legacyGraphicsModes); ++i) {
+		if (gfxMode == s_legacyGraphicsModes[i].oldName) {
+			return true;
+		}
+	}
+	return false;
+}
+
 void ScalerManager::updateOldSettings() {
 	// Search for legacy gfx_mode and replace it
 	if (ConfMan.hasKey("gfx_mode")) {
diff --git a/graphics/scalerplugin.h b/graphics/scalerplugin.h
index a268fd49673..bc1425322a2 100644
--- a/graphics/scalerplugin.h
+++ b/graphics/scalerplugin.h
@@ -234,6 +234,11 @@ public:
 	 * Update scaler settings from older versions of ScummVM.
 	 */
 	void updateOldSettings();
+
+	/**
+	 * Returns whether the supplied mode is one of the old gfx-modes.
+	 */
+	bool isOldGraphicsSetting(const Common::String &gfxMode);
 };
 
 /** Convenience shortcut for accessing singleton */


Commit: 89470213337a11446a44caafbd1b36bd9759381b
    https://github.com/scummvm/scummvm/commit/89470213337a11446a44caafbd1b36bd9759381b
Author: Einar Johan Trøan Sømåen (somaen at scummvm.org)
Date: 2023-02-12T09:51:53+01:00

Commit Message:
BASE: Wrap -g setGraphicsMode in transactions.

Without this -g will simply assert.

Changed paths:
    base/main.cpp


diff --git a/base/main.cpp b/base/main.cpp
index 07126784e76..a29d12012a9 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -622,7 +622,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
 			warning("Unrecognized graphics mode '%s'. Switching to default mode", gfxModeSetting.c_str());
 		} else {
 			settings["gfx-mode"] = gfxModeSetting;
+			system.beginGFXTransaction();
 			system.setGraphicsMode(gfxModeSetting.c_str());
+			system.endGFXTransaction();
 		}
 		ConfMan.set("gfx_mode", gfxModeSetting, Common::ConfigManager::kSessionDomain);
 	}




More information about the Scummvm-git-logs mailing list