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

scemino noreply at scummvm.org
Sat May 4 11:38:39 UTC 2024


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:
aa07f2eac0 TWP: Fix issue when you choose a platform


Commit: aa07f2eac0f46fd0a7fe64b558d2db97de71c65c
    https://github.com/scummvm/scummvm/commit/aa07f2eac0f46fd0a7fe64b558d2db97de71c65c
Author: scemino (scemino74 at gmail.com)
Date: 2024-05-04T13:38:05+02:00

Commit Message:
TWP: Fix issue when you choose a platform

Changed paths:
    engines/twp/genlib.cpp
    engines/twp/syslib.cpp


diff --git a/engines/twp/genlib.cpp b/engines/twp/genlib.cpp
index 2c7f39eff58..29e03955f2d 100644
--- a/engines/twp/genlib.cpp
+++ b/engines/twp/genlib.cpp
@@ -343,11 +343,28 @@ static SQInteger frameCounter(HSQUIRRELVM v) {
 	return sqpush(v, g_twp->_frameCounter);
 }
 
+static Common::String toPlatform(const Common::String &value) {
+	const char *platformsSrc[] = {"xbox", "switch", "playstation", "playstation2"};
+	const char *platformsDst[] = {"XBOX", "SWITCH", "PS4", "PS4"};
+	for (int i = 0; i < ARRAYSIZE(platformsSrc); i++) {
+		if (value == platformsSrc[i]) {
+			return platformsDst[i];
+		}
+	}
+	return "0";
+}
+
 static SQInteger getUserPref(HSQUIRRELVM v) {
 	Common::String key;
 	if (SQ_FAILED(sqget(v, 2, key))) {
 		return sq_throwerror(v, _SC("failed to get key"));
 	}
+
+	if (key == "platform" && ConfMan.hasKey(key)) {
+		sqpush(v, toPlatform(ConfMan.get(key)));
+		return 1;
+	}
+
 	SQInteger numArgs = sq_gettop(v) - 1;
 	// is there a fault value as argument ?
 	if (numArgs > 1) {
diff --git a/engines/twp/syslib.cpp b/engines/twp/syslib.cpp
index 4d51797cd07..7f3310dd70d 100644
--- a/engines/twp/syslib.cpp
+++ b/engines/twp/syslib.cpp
@@ -19,6 +19,8 @@
  *
  */
 
+#include "common/config-manager.h"
+
 #include "twp/twp.h"
 #include "twp/callback.h"
 #include "twp/dialog.h"
@@ -1055,7 +1057,18 @@ void sqgame_register_constants(HSQUIRRELVM v) {
 	regConst(v, "BUTTON_MOUSE_LEFT", BUTTON_MOUSE_LEFT);
 	regConst(v, "BUTTON_MOUSE_RIGHT", BUTTON_MOUSE_RIGHT);
 	regConst(v, "WAITING_FOR_CHOICE", 2);
-	regConst(v, "PLATFORM", 1); // TODO: choose the right platform
+
+	// convert ScummVM platform to the one expected
+	SQInteger platform = MAC;
+	const char *platformsSrc[] = {"mac", "windows", "linux", "xbox", "ios", "android", "switch"};
+	const SQInteger platformsDst[] = {MAC, WIN, LINUX, XBOX, IOS, ANDROID, SWITCH};
+	Common::String platformName(ConfMan.get("platform"));
+	for (int i = 0; i < ARRAYSIZE(platformsSrc); i++) {
+		if (platformName == platformsSrc[i]) {
+			platform = platformsDst[i];
+		}
+	}
+	regConst(v, "PLATFORM", platform);
 }
 
 } // namespace Twp




More information about the Scummvm-git-logs mailing list