[Scummvm-git-logs] scummvm master -> 7b2e3fb4407cb16948880522595c0dfb9e53f225
sev-
sev at scummvm.org
Tue May 5 19:51:29 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ff80043457 WINTERMUTE: Move external DLL implementations to /ext/ folder
b783f984f1 WINTERMUTE: Move wme-plugins implementations to /ext/ folder
14c54b0395 WINTERMUTE: Add stub for wme_3fstatistics.dll data collecting plugin
7b2e3fb440 WINTERMUTE: Remove "#if 1" marks
Commit: ff800434576a098a02e12e35ca43d632e2a8c8e7
https://github.com/scummvm/scummvm/commit/ff800434576a098a02e12e35ca43d632e2a8c8e7
Author: lolbot-iichan (lolbot_iichan at mail.ru)
Date: 2020-05-05T21:51:22+02:00
Commit Message:
WINTERMUTE: Move external DLL implementations to /ext/ folder
Changed paths:
A engines/wintermute/ext/dll_dlltest.cpp
A engines/wintermute/ext/dll_geturl.cpp
A engines/wintermute/ext/dll_httpconnect.cpp
A engines/wintermute/ext/dll_img.cpp
A engines/wintermute/ext/dll_installutil.cpp
A engines/wintermute/ext/dll_kernel32.cpp
A engines/wintermute/ext/dll_shell32.cpp
A engines/wintermute/ext/dll_tools.cpp
A engines/wintermute/ext/externals.h
engines/wintermute/base/scriptables/script.cpp
engines/wintermute/module.mk
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index dc8a76b91c..889e691d71 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -33,6 +33,7 @@
#include "engines/wintermute/base/scriptables/script_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/gfx/base_renderer.h"
+#include "engines/wintermute/ext/externals.h"
#include "common/memstream.h"
#if EXTENDED_DEBUGGER_ENABLED
#include "engines/wintermute/base/scriptables/debuggable/debuggable_script.h"
@@ -1419,407 +1420,14 @@ ScScript::TExternalFunction *ScScript::getExternal(char *name) {
//////////////////////////////////////////////////////////////////////////
bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
-
- //////////////////////////////////////////////////////////////////////////
- // getURLContent
- // Used to download news headlines at Demo 2012 of James Peris
- // HTTP GET result is stored in 3rd param of the call as a plain string
- // Specification: external "geturl.dll" cdecl getURLContent(string, string, string)
- // Known usage: getURLContent("http://www.lacosaweb.com", <DirURL>, <Buffer>)
- // Sets 3rd param to "Request Error." on error
- //////////////////////////////////////////////////////////////////////////
- if (strcmp(function->name, "getURLContent") == 0 && strcmp(function->dll_name, "geturl.dll") == 0) {
- stack->correctParams(3);
- const char *domain = stack->pop()->getString();
- const char *dirurl = stack->pop()->getString();
- ScValue *buf = stack->pop();
-
- if (strcmp(dirurl, "jpnews/demo-es1.txt") == 0) {
- buf->setString("Ya disponible el juego completo en jamesperis.com");
- } else if (strcmp(dirurl, "jpnews/demo-es2.txt") == 0) {
- buf->setString("Cons\355guelo por solo 3,95 euros");
- } else if (strcmp(dirurl, "jpnews/demo-en1.txt") == 0) {
- buf->setString("You can get the full game in jamesperis.com");
- } else if (strcmp(dirurl, "jpnews/demo-en2.txt") == 0) {
- buf->setString("Get it for 3.95 euros");
- } else {
- warning("getURLContent(\"%s\",\"%s\",buf) is not implemented", domain, dirurl);
- buf->setString("Request Error.");
- }
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // SetValueToReg
- // Used to switch game's windowed/fullscreen mode at games by HeroCraft
- // Specification: external "tools.dll" cdecl SetValueToReg(string, string, long)
- // Known usage: SetValueToReg("Software\HeroCraft\<GameID>\Video", "Windowed", 1)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "SetValueToReg") == 0 && strcmp(function->dll_name, "tools.dll") == 0) {
- stack->correctParams(3);
- const char *regpath = stack->pop()->getString();
- const char *key = stack->pop()->getString();
- int value = stack->pop()->getInt();
-
- if (strcmp(key, "Windowed") == 0) {
- _gameRef->_renderer->setWindowed(value);
- } else {
- warning("SetValueToReg(\"%s\",\"%s\",%d) is not implemented", regpath, key, value);
- }
-
- stack->pushNULL();
+#if 1
+ if (!DID_FAIL(EmulateExternalCall(_gameRef, stack, thisStack, function))) {
return STATUS_OK;
}
-
- //////////////////////////////////////////////////////////////////////////
- // changeWindowCaption
- // Used to change game's window caption at games by HeroCraft
- // Specification: external "img.dll" cdecl changeWindowCaption(long, string)
- // Known usage: changeWindowCaption(Game.Hwnd, <Title>)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "changeWindowCaption") == 0 && strcmp(function->dll_name, "img.dll") == 0) {
- stack->correctParams(2);
- /*int hwnd =*/ stack->pop()->getInt();
- /*const char *title =*/ stack->pop()->getString();
-
- // do nothing
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // maximizedWindow
- // Used to change game's window size at games by HeroCraft
- // Specification: external "img.dll" cdecl maximizedWindow(long, long, long)
- // Known usage: maximizedWindow(Game.Hwnd, 1024, 768)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "maximizedWindow") == 0 && strcmp(function->dll_name, "img.dll") == 0) {
- stack->correctParams(3);
- /*int hwnd =*/ stack->pop()->getInt();
- /*int width =*/ stack->pop()->getInt();
- /*int height =*/ stack->pop()->getInt();
-
- // do nothing
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // ShellExecuteA
- // Used to open URL in browser at Wilma Tetris
- // Specification: external "shell32.dll" stdcall long ShellExecuteA(long, string, string, string, string, long)
- // Known usage: ShellExecuteA(0, "open", <URL>, "", "", 3)
- // Returns value >32 on success
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "ShellExecuteA") == 0 && strcmp(function->dll_name, "shell32.dll") == 0) {
- stack->correctParams(6);
- int hwnd = stack->pop()->getInt();
- const char *operation = stack->pop()->getString();
- const char *file = stack->pop()->getString();
- const char *params = stack->pop()->getString();
- const char *directory = stack->pop()->getString();
- int cmd = stack->pop()->getInt();
-
- if (strcmp(operation, "open") == 0 && !strlen(params) && !strlen(directory)) {
- g_system->openUrl(file);
- } else {
- warning("ShellExecuteA(%d,\"%s\",\"%s\",\"%s\",\"%s\",%d) is not implemented", hwnd, operation, file, params, directory, cmd);
- }
-
- stack->pushInt(42);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // _InstallUtilAnsi at 0
- // Used to check if DVD is inserted at Art of Murder: FBI Confidential
- // Specification: external "installutil.dll" stdcall long _InstallUtilAnsi at 0()
- // Known usage: _InstallUtilAnsi at 0()
- // Returns 1 on success, other value on fail (which leads to Game.QuitGame() in non-Debug mode)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "_InstallUtilAnsi at 0") == 0 && strcmp(function->dll_name, "installutil.dll") == 0) {
- stack->correctParams(0);
- stack->pushInt(1);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // IRC_init
- // Used to connect to debug IRC server at games by Corbomite Games
- // Specification: external "dlltest.dll" cdecl long IRC_init(string)
- // Known usage: IRC_init(<PlayerName>)
- // Known actions:
- // 1. Connect to irc.starchat.net
- // 2. Send "NICK ZU_<PlayerName>/"
- // 3. Send "USER Blah ZbengHost ZbengServer ZbengRealname"
- // 4. Send "Join #Zbeng"
- // Returns 0 on success, other value on error
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "IRC_init") == 0 && strcmp(function->dll_name, "dlltest.dll") == 0) {
- stack->correctParams(1);
- /*const char *name =*/ stack->pop()->getString();
-
- // do nothing
-
- stack->pushInt(0);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // ChangeNick
- // Used to update nick at debug IRC server at games by Corbomite Games
- // Specification: external "dlltest.dll" cdecl long ChangeNick(string)
- // Known usage: ChangeNick(<PlayerName>)
- // Return value is never used
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "ChangeNick") == 0 && strcmp(function->dll_name, "dlltest.dll") == 0) {
- stack->correctParams(1);
- /*const char *name =*/ stack->pop()->getString();
-
- // do nothing
-
- stack->pushInt(0);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // IRC_SendString
- // Used to send debug and chat lines to an IRC server at games by Corbomite Games
- // Specification: external "dlltest.dll" cdecl IRC_SendString(string, string)
- // Known usage: IRC_SendString(<Message>, <Channel>)
- // Known Channel values are: "#Zbeng" and "#ZbengDebug"
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "IRC_SendString") == 0 && strcmp(function->dll_name, "dlltest.dll") == 0) {
- stack->correctParams(2);
- const char *message = stack->pop()->getString();
- const char *channel = stack->pop()->getString();
-
- _gameRef->LOG(0, "IRC logging: [%s] %s", channel, message);
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // IRC_GetChatStrings
- // Used to get chat lines from an IRC server at games by Corbomite Games
- // Specification: external "dlltest.dll" cdecl IRC_GetChatStrings(string, long)
- // Known usage: IRC_GetChatStrings(<Buffer>, 65535)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "IRC_GetChatStrings") == 0 && strcmp(function->dll_name, "dlltest.dll") == 0) {
- stack->correctParams(2);
- /*const char *buffer =*/ stack->pop()->getString();
- /*int bufferMaxSize =*/ stack->pop()->getInt();
-
- // do nothing
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // IRC_quit
- // Used to disconnect from debug IRC server at games by Corbomite Games
- // Specification: external "dlltest.dll" cdecl IRC_quit()
- // Known usage: IRC_quit()
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "IRC_quit") == 0 && strcmp(function->dll_name, "dlltest.dll") == 0) {
- stack->correctParams(0);
-
- // do nothing
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // LoadLibraryA
- // Used for checking library availability at games by Corbomite Games
- // Specification: external "kernel32.dll" stdcall long LoadLibraryA(string)
- // Known usage: LoadLibraryA("httpconnect.dll"), LoadLibraryA("dlltest.dll")
- // Return values are only compared with zero and are never used in other APIs
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "LoadLibraryA") == 0 && strcmp(function->dll_name, "kernel32.dll") == 0) {
- stack->correctParams(1);
- const char *dllName = stack->pop()->getString();
- int result = 0;
-
- if (strcmp(dllName, "httpconnect.dll") == 0) {
- result = 1; // some non-zero value
- } else if (strcmp(dllName, "dlltest.dll") == 0) {
- result = 2; // some other non-zero value
- } else {
- warning("LoadLibraryA(\"%s\") is not implemented", dllName);
- }
-
- stack->pushInt(result);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // FreeLibrary
- // Declared at games by Corbomite Games
- // Seems to be unused, probably was used for unloading IRC & HTTP libraries
- // Specification: external "kernel32.dll" stdcall FreeLibrary(long)
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "FreeLibrary") == 0 && strcmp(function->dll_name, "kernel32.dll") == 0) {
- stack->correctParams(1);
- /*int dllId =*/ stack->pop()->getInt();
-
- // do nothing
-
- stack->pushNULL();
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // GetEnvironmentVariableA
- // Used for getting environment variables at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
- // Specification: external "kernel32.dll" stdcall long GetEnvironmentVariableA(string, string, long)
- // Known usage: GetEnvironmentVariableA(<EnvName>, <buffer>, 65535)
- // Known EnvName values used in debug code: "USERKEY", "ALTUSERNAME", "ENHFINGERPRINT", "EXTRAINFO", "FINGERPRINT", "KEYSTRING", "STOLENKEY", "TRIAL"
- // Known EnvName values used in licensing code: "FULLGAME"
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "GetEnvironmentVariableA") == 0 && strcmp(function->dll_name, "kernel32.dll") == 0) {
- stack->correctParams(3);
- const char *name = stack->pop()->getString();
- /*ScValue *buf =*/ stack->pop();
- /*int bufMaxLen =*/ stack->pop()->getInt();
-
- warning("Assuming variable \"%s\" is not set", name);
-
- stack->pushInt(0);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Register
- // Used to register license key online at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
- // Specification: external "httpconnect.dll" cdecl long Register(string, long, string, long)
- // Known usage: Register(<productId>, 65535, <productKey>, 65535)
- // Known product ID values are: "357868", "353058" and "353006"
- // Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=REGISTER&productId=productId&key=productKey
- // Returns 1 on success
- // Returns 0 on firewall error
- // Returns -1 on invalid product key
- // Returns -2 on invalid product ID
- // Returns -3 on expired product key
- // Returns -4 on invalid machine ID
- // Returns -5 on number of installations exceeded
- // Returns -6 on socket error
- // Returns -7 on no internet connection
- // Returns -8 on connection reset
- // Returns -11 on validation temporary unavaliable
- // Returns -12 on validation error
- // For some reason always returns -7 for me in a test game
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "Register") == 0 && strcmp(function->dll_name, "httpconnect.dll") == 0) {
- stack->correctParams(4);
- const char *productId = stack->pop()->getString();
- int productIdMaxLen = stack->pop()->getInt();
- const char *productKey = stack->pop()->getString();
- int productKeyMaxLen = stack->pop()->getInt();
-
- warning("Register(\"%s\",%d,\"%s\",%d) is not implemented", productId , productIdMaxLen, productKey, productKeyMaxLen);
-
- stack->pushInt(-7); // "no internet connection" error
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Validate
- // Used to validate something at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
- // Specification: external "httpconnect.dll" cdecl long Validate()
- // Known usage: Validate()
- // Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=VALIDATE&productId=Ar&key=Ar
- // Used only when Debug mode is active or game is started with "INVALID" cmdline parameter
- // For some reason always returns 1 for me in a test game
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "Validate") == 0 && strcmp(function->dll_name, "httpconnect.dll") == 0) {
- stack->correctParams(0);
-
- // do nothing
-
- stack->pushInt(1);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // SendHTTPAsync
- // Used to send game progress events to server at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
- // Specification: external "httpconnect.dll" cdecl long SendHTTPAsync(string, long, string, long, string, long)
- // Known usage: SendHTTPAsync("backend.pizzamorgana.com", 65535, <FullURL>, 65535, <Buffer?!>, 65535)
- // FullURL is formed as "http://backend.pizzamorgana.com/event.php?Event=<EventName>&player=<PlayerName>&extraParams=<ExtraParams>&SN=<ProductKey>&Episode=1&GameTime=<CurrentTime>&UniqueID=<UniqueId>"
- // Known EventName values are: "GameStart", "ChangeGoal", "EndGame" and "QuitGame"
- // Known ExtraParams values are: "ACT0", "ACT1", "ACT2", "ACT3", "ACT4", "Ep0FindFood", "Ep0FindCellMenu", "Ep0BroRoom", "Ep0FindKey", "Ep0FindCellMenuKey", "Ep0FindMenuKey", "Ep0FindCell", "Ep0FindMenu", "Ep0OrderPizza", "Ep0GetRidOfVamp", "Ep0GetVampAttention", "Ep0License"
- // Return value is never used
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "SendHTTPAsync") == 0 && strcmp(function->dll_name, "httpconnect.dll") == 0) {
- stack->correctParams(6);
- const char *server = stack->pop()->getString();
- int serverMaxLen = stack->pop()->getInt();
- const char *fullUrl = stack->pop()->getString();
- int fullUrlMaxLen = stack->pop()->getInt();
- const char *param5 = stack->pop()->getString();
- int param5MaxLen = stack->pop()->getInt();
-
- // TODO: Maybe parse URL and call some Achievements API using ExtraParams values in some late future
- warning("SendHTTPAsync(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
-
- stack->pushInt(0);
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // SendRecvHTTP (6 params variant)
- // Declared at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
- // Seems to be unused, probably SendRecvHTTP was initially used instead of SendHTTPAsync
- // Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long, string, long)
- // Always returns -7 for me in a test game, probably returns the same network errors as Register()
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "SendRecvHTTP") == 0 && strcmp(function->dll_name, "httpconnect.dll") == 0 && function->nu_params == 6) {
- stack->correctParams(6);
- const char *server = stack->pop()->getString();
- int serverMaxLen = stack->pop()->getInt();
- const char *fullUrl = stack->pop()->getString();
- int fullUrlMaxLen = stack->pop()->getInt();
- const char *param5 = stack->pop()->getString();
- int param5MaxLen = stack->pop()->getInt();
-
- warning("SendRecvHTTP(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
-
- stack->pushInt(-7); // "no internet connection" error
- return STATUS_OK;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // SendRecvHTTP (4 params variant)
- // Used to call HTTP methods at Zbang! The Game
- // Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long)
- // Known usage: SendRecvHTTP("scoresshort.php?player=<PlayerName>", 65535, <Buffer>, 65535)
- // Known usage: SendRecvHTTP("/update.php?player=<PlayerName>&difficulty=<Difficulty>&items=<CommaSeparatedItemList>", 65535, <Buffer>, 65535)
- // My Zbang demo does not have this dll, so there is no way to actually test it with a test game
- // Return value is never used in Zbang scripts
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(function->name, "SendRecvHTTP") == 0 && strcmp(function->dll_name, "httpconnect.dll") == 0 && function->nu_params == 4) {
- stack->correctParams(4);
- const char *dirUrl = stack->pop()->getString();
- int dirUrlMaxLen = stack->pop()->getInt();
- /*ScValue *buf =*/ stack->pop();
- int bufMaxLen = stack->pop()->getInt();
-
- //TODO: Count items and give scores, persist those values
- warning("SendRecvHTTP(\"%s\",%d,buf,%d) is not implemented", dirUrl, dirUrlMaxLen, bufMaxLen);
-
- stack->pushInt(0);
- return STATUS_OK;
- }
-
+#else
_gameRef->LOG(0, "External functions are not supported on this platform.");
+#endif
+
stack->correctParams(0);
stack->pushNULL();
return STATUS_FAILED;
diff --git a/engines/wintermute/ext/dll_dlltest.cpp b/engines/wintermute/ext/dll_dlltest.cpp
new file mode 100644
index 0000000000..22dc9293fa
--- /dev/null
+++ b/engines/wintermute/ext/dll_dlltest.cpp
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateDLLTestExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // IRC_init
+ // Used to connect to debug IRC server at games by Corbomite Games
+ // Specification: external "dlltest.dll" cdecl long IRC_init(string)
+ // Known usage: IRC_init(<PlayerName>)
+ // Known actions:
+ // 1. Connect to irc.starchat.net
+ // 2. Send "NICK ZU_<PlayerName>/"
+ // 3. Send "USER Blah ZbengHost ZbengServer ZbengRealname"
+ // 4. Send "Join #Zbeng"
+ // Returns 0 on success, other value on error
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "IRC_init") == 0) {
+ stack->correctParams(1);
+ /*const char *name =*/ stack->pop()->getString();
+
+ // do nothing
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // ChangeNick
+ // Used to update nick at debug IRC server at games by Corbomite Games
+ // Specification: external "dlltest.dll" cdecl long ChangeNick(string)
+ // Known usage: ChangeNick(<PlayerName>)
+ // Return value is never used
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "ChangeNick") == 0) {
+ stack->correctParams(1);
+ /*const char *name =*/ stack->pop()->getString();
+
+ // do nothing
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // IRC_SendString
+ // Used to send debug and chat lines to an IRC server at games by Corbomite Games
+ // Specification: external "dlltest.dll" cdecl IRC_SendString(string, string)
+ // Known usage: IRC_SendString(<Message>, <Channel>)
+ // Known Channel values are: "#Zbeng" and "#ZbengDebug"
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "IRC_SendString") == 0) {
+ stack->correctParams(2);
+ const char *message = stack->pop()->getString();
+ const char *channel = stack->pop()->getString();
+
+ inGame->LOG(0, "IRC logging: [%s] %s", channel, message);
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // IRC_GetChatStrings
+ // Used to get chat lines from an IRC server at games by Corbomite Games
+ // Specification: external "dlltest.dll" cdecl IRC_GetChatStrings(string, long)
+ // Known usage: IRC_GetChatStrings(<Buffer>, 65535)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "IRC_GetChatStrings") == 0) {
+ stack->correctParams(2);
+ /*const char *buffer =*/ stack->pop()->getString();
+ /*int bufferMaxSize =*/ stack->pop()->getInt();
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // IRC_quit
+ // Used to disconnect from debug IRC server at games by Corbomite Games
+ // Specification: external "dlltest.dll" cdecl IRC_quit()
+ // Known usage: IRC_quit()
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "IRC_quit") == 0) {
+ stack->correctParams(0);
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_geturl.cpp b/engines/wintermute/ext/dll_geturl.cpp
new file mode 100644
index 0000000000..1384a37fc0
--- /dev/null
+++ b/engines/wintermute/ext/dll_geturl.cpp
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+// Implemented in their respective .cpp-files
+bool EmulateGetURLExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // getURLContent
+ // Used to download news headlines at Demo 2012 of James Peris
+ // HTTP GET result is stored in 3rd param of the call as a plain string
+ // Specification: external "geturl.dll" cdecl getURLContent(string, string, string)
+ // Known usage: getURLContent("http://www.lacosaweb.com", <DirURL>, <Buffer>)
+ // Sets 3rd param to "Request Error." on error
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "getURLContent") == 0) {
+ stack->correctParams(3);
+ const char *domain = stack->pop()->getString();
+ const char *dirurl = stack->pop()->getString();
+ ScValue *buf = stack->pop();
+
+ if (strcmp(dirurl, "jpnews/demo-es1.txt") == 0) {
+ buf->setString("Ya disponible el juego completo en jamesperis.com");
+ } else if (strcmp(dirurl, "jpnews/demo-es2.txt") == 0) {
+ buf->setString("Cons\355guelo por solo 3,95 euros");
+ } else if (strcmp(dirurl, "jpnews/demo-en1.txt") == 0) {
+ buf->setString("You can get the full game in jamesperis.com");
+ } else if (strcmp(dirurl, "jpnews/demo-en2.txt") == 0) {
+ buf->setString("Get it for 3.95 euros");
+ } else {
+ warning("getURLContent(\"%s\",\"%s\",buf) is not implemented", domain, dirurl);
+ buf->setString("Request Error.");
+ }
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_httpconnect.cpp b/engines/wintermute/ext/dll_httpconnect.cpp
new file mode 100644
index 0000000000..bd3dededc6
--- /dev/null
+++ b/engines/wintermute/ext/dll_httpconnect.cpp
@@ -0,0 +1,164 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateHTTPConnectExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // Register
+ // Used to register license key online at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
+ // Specification: external "httpconnect.dll" cdecl long Register(string, long, string, long)
+ // Known usage: Register(<productId>, 65535, <productKey>, 65535)
+ // Known product ID values are: "357868", "353058" and "353006"
+ // Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=REGISTER&productId=productId&key=productKey
+ // Returns 1 on success
+ // Returns 0 on firewall error
+ // Returns -1 on invalid product key
+ // Returns -2 on invalid product ID
+ // Returns -3 on expired product key
+ // Returns -4 on invalid machine ID
+ // Returns -5 on number of installations exceeded
+ // Returns -6 on socket error
+ // Returns -7 on no internet connection
+ // Returns -8 on connection reset
+ // Returns -11 on validation temporary unavaliable
+ // Returns -12 on validation error
+ // For some reason always returns -7 for me in a test game
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "Register") == 0) {
+ stack->correctParams(4);
+ const char *productId = stack->pop()->getString();
+ int productIdMaxLen = stack->pop()->getInt();
+ const char *productKey = stack->pop()->getString();
+ int productKeyMaxLen = stack->pop()->getInt();
+
+ warning("Register(\"%s\",%d,\"%s\",%d) is not implemented", productId , productIdMaxLen, productKey, productKeyMaxLen);
+
+ stack->pushInt(-7); // "no internet connection" error
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Validate
+ // Used to validate something at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
+ // Specification: external "httpconnect.dll" cdecl long Validate()
+ // Known usage: Validate()
+ // Known action: HTTP GET http://keygen.corbomitegames.com/keygen/validateKey.php?action=VALIDATE&productId=Ar&key=Ar
+ // Used only when Debug mode is active or game is started with "INVALID" cmdline parameter
+ // For some reason always returns 1 for me in a test game
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "Validate") == 0) {
+ stack->correctParams(0);
+
+ // do nothing
+
+ stack->pushInt(1);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // SendHTTPAsync
+ // Used to send game progress events to server at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
+ // Specification: external "httpconnect.dll" cdecl long SendHTTPAsync(string, long, string, long, string, long)
+ // Known usage: SendHTTPAsync("backend.pizzamorgana.com", 65535, <FullURL>, 65535, <Buffer?!>, 65535)
+ // FullURL is formed as "http://backend.pizzamorgana.com/event.php?Event=<EventName>&player=<PlayerName>&extraParams=<ExtraParams>&SN=<ProductKey>&Episode=1&GameTime=<CurrentTime>&UniqueID=<UniqueId>"
+ // Known EventName values are: "GameStart", "ChangeGoal", "EndGame" and "QuitGame"
+ // Known ExtraParams values are: "ACT0", "ACT1", "ACT2", "ACT3", "ACT4", "Ep0FindFood", "Ep0FindCellMenu", "Ep0BroRoom", "Ep0FindKey", "Ep0FindCellMenuKey", "Ep0FindMenuKey", "Ep0FindCell", "Ep0FindMenu", "Ep0OrderPizza", "Ep0GetRidOfVamp", "Ep0GetVampAttention", "Ep0License"
+ // Return value is never used
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "SendHTTPAsync") == 0) {
+ stack->correctParams(6);
+ const char *server = stack->pop()->getString();
+ int serverMaxLen = stack->pop()->getInt();
+ const char *fullUrl = stack->pop()->getString();
+ int fullUrlMaxLen = stack->pop()->getInt();
+ const char *param5 = stack->pop()->getString();
+ int param5MaxLen = stack->pop()->getInt();
+
+ // TODO: Maybe parse URL and call some Achievements API using ExtraParams values in some late future
+ warning("SendHTTPAsync(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // SendRecvHTTP (6 params variant)
+ // Declared at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
+ // Seems to be unused, probably SendRecvHTTP was initially used instead of SendHTTPAsync
+ // Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long, string, long)
+ // Always returns -7 for me in a test game, probably returns the same network errors as Register()
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "SendRecvHTTP") == 0 && function->nu_params == 6) {
+ stack->correctParams(6);
+ const char *server = stack->pop()->getString();
+ int serverMaxLen = stack->pop()->getInt();
+ const char *fullUrl = stack->pop()->getString();
+ int fullUrlMaxLen = stack->pop()->getInt();
+ const char *param5 = stack->pop()->getString();
+ int param5MaxLen = stack->pop()->getInt();
+
+ warning("SendRecvHTTP(\"%s\",%d,\"%s\",%d,\"%s\",%d) is not implemented", server, serverMaxLen, fullUrl, fullUrlMaxLen, param5, param5MaxLen);
+
+ stack->pushInt(-7); // "no internet connection" error
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // SendRecvHTTP (4 params variant)
+ // Used to call HTTP methods at Zbang! The Game
+ // Specification: external "httpconnect.dll" cdecl long SendRecvHTTP(string, long, string, long)
+ // Known usage: SendRecvHTTP("scoresshort.php?player=<PlayerName>", 65535, <Buffer>, 65535)
+ // Known usage: SendRecvHTTP("/update.php?player=<PlayerName>&difficulty=<Difficulty>&items=<CommaSeparatedItemList>", 65535, <Buffer>, 65535)
+ // My Zbang demo does not have this dll, so there is no way to actually test it with a test game
+ // Return value is never used in Zbang scripts
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "SendRecvHTTP") == 0 && function->nu_params == 4) {
+ stack->correctParams(4);
+ const char *dirUrl = stack->pop()->getString();
+ int dirUrlMaxLen = stack->pop()->getInt();
+ /*ScValue *buf =*/ stack->pop();
+ int bufMaxLen = stack->pop()->getInt();
+
+ //TODO: Count items and give scores, persist those values
+ warning("SendRecvHTTP(\"%s\",%d,buf,%d) is not implemented", dirUrl, dirUrlMaxLen, bufMaxLen);
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_img.cpp b/engines/wintermute/ext/dll_img.cpp
new file mode 100644
index 0000000000..668b54d974
--- /dev/null
+++ b/engines/wintermute/ext/dll_img.cpp
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateImgExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // changeWindowCaption
+ // Used to change game's window caption at games by HeroCraft
+ // Specification: external "img.dll" cdecl changeWindowCaption(long, string)
+ // Known usage: changeWindowCaption(Game.Hwnd, <Title>)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "changeWindowCaption") == 0) {
+ stack->correctParams(2);
+ /*int hwnd =*/ stack->pop()->getInt();
+ /*const char *title =*/ stack->pop()->getString();
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // maximizedWindow
+ // Used to change game's window size at games by HeroCraft
+ // Specification: external "img.dll" cdecl maximizedWindow(long, long, long)
+ // Known usage: maximizedWindow(Game.Hwnd, 1024, 768)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "maximizedWindow") == 0) {
+ stack->correctParams(3);
+ /*int hwnd =*/ stack->pop()->getInt();
+ /*int width =*/ stack->pop()->getInt();
+ /*int height =*/ stack->pop()->getInt();
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_installutil.cpp b/engines/wintermute/ext/dll_installutil.cpp
new file mode 100644
index 0000000000..8b8bf3bac5
--- /dev/null
+++ b/engines/wintermute/ext/dll_installutil.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateInstallUtilExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // _InstallUtilAnsi at 0
+ // Used to check if DVD is inserted at Art of Murder: FBI Confidential
+ // Specification: external "installutil.dll" stdcall long _InstallUtilAnsi at 0()
+ // Known usage: _InstallUtilAnsi at 0()
+ // Returns 1 on success, other value on fail (which leads to Game.QuitGame() in non-Debug mode)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "_InstallUtilAnsi at 0") == 0) {
+ stack->correctParams(0);
+ stack->pushInt(1);
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_kernel32.cpp b/engines/wintermute/ext/dll_kernel32.cpp
new file mode 100644
index 0000000000..a86941b7b5
--- /dev/null
+++ b/engines/wintermute/ext/dll_kernel32.cpp
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateKernel32ExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // LoadLibraryA
+ // Used for checking library availability at games by Corbomite Games
+ // Specification: external "kernel32.dll" stdcall long LoadLibraryA(string)
+ // Known usage: LoadLibraryA("httpconnect.dll"), LoadLibraryA("dlltest.dll")
+ // Return values are only compared with zero and are never used in other APIs
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "LoadLibraryA") == 0) {
+ stack->correctParams(1);
+ const char *dllName = stack->pop()->getString();
+ int result = 0;
+
+ if (strcmp(dllName, "httpconnect.dll") == 0) {
+ result = 1; // some non-zero value
+ } else if (strcmp(dllName, "dlltest.dll") == 0) {
+ result = 2; // some other non-zero value
+ } else {
+ warning("LoadLibraryA(\"%s\") is not implemented", dllName);
+ }
+
+ stack->pushInt(result);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // FreeLibrary
+ // Declared at games by Corbomite Games
+ // Seems to be unused, probably was used for unloading IRC & HTTP libraries
+ // Specification: external "kernel32.dll" stdcall FreeLibrary(long)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "FreeLibrary") == 0) {
+ stack->correctParams(1);
+ /*int dllId =*/ stack->pop()->getInt();
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // GetEnvironmentVariableA
+ // Used for getting environment variables at Pizza Morgana: Episode 1 - Monsters and Manipulations in the Magical Forest
+ // Specification: external "kernel32.dll" stdcall long GetEnvironmentVariableA(string, string, long)
+ // Known usage: GetEnvironmentVariableA(<EnvName>, <buffer>, 65535)
+ // Known EnvName values used in debug code: "USERKEY", "ALTUSERNAME", "ENHFINGERPRINT", "EXTRAINFO", "FINGERPRINT", "KEYSTRING", "STOLENKEY", "TRIAL"
+ // Known EnvName values used in licensing code: "FULLGAME"
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(function->name, "GetEnvironmentVariableA") == 0) {
+ stack->correctParams(3);
+ const char *name = stack->pop()->getString();
+ /*ScValue *buf =*/ stack->pop();
+ /*int bufMaxLen =*/ stack->pop()->getInt();
+
+ warning("Assuming variable \"%s\" is not set", name);
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_shell32.cpp b/engines/wintermute/ext/dll_shell32.cpp
new file mode 100644
index 0000000000..a2b081b48b
--- /dev/null
+++ b/engines/wintermute/ext/dll_shell32.cpp
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateShell32ExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // ShellExecuteA
+ // Used to open URL in browser at Wilma Tetris
+ // Specification: external "shell32.dll" stdcall long ShellExecuteA(long, string, string, string, string, long)
+ // Known usage: ShellExecuteA(0, "open", <URL>, "", "", 3)
+ // Returns value >32 on success
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "ShellExecuteA") == 0) {
+ stack->correctParams(6);
+ int hwnd = stack->pop()->getInt();
+ const char *operation = stack->pop()->getString();
+ const char *file = stack->pop()->getString();
+ const char *params = stack->pop()->getString();
+ const char *directory = stack->pop()->getString();
+ int cmd = stack->pop()->getInt();
+
+ if (strcmp(operation, "open") == 0 && !strlen(params) && !strlen(directory)) {
+ g_system->openUrl(file);
+ } else {
+ warning("ShellExecuteA(%d,\"%s\",\"%s\",\"%s\",\"%s\",%d) is not implemented", hwnd, operation, file, params, directory, cmd);
+ }
+
+ stack->pushInt(42);
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/dll_tools.cpp b/engines/wintermute/ext/dll_tools.cpp
new file mode 100644
index 0000000000..253e53555c
--- /dev/null
+++ b/engines/wintermute/ext/dll_tools.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/gfx/base_renderer.h"
+#include "engines/wintermute/base/scriptables/script.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+namespace Wintermute {
+
+bool EmulateToolsExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+ //////////////////////////////////////////////////////////////////////////
+ // SetValueToReg
+ // Used to switch game's windowed/fullscreen mode at games by HeroCraft
+ // Specification: external "tools.dll" cdecl SetValueToReg(string, string, long)
+ // Known usage: SetValueToReg("Software\HeroCraft\<GameID>\Video", "Windowed", 1)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(function->name, "SetValueToReg") == 0) {
+ stack->correctParams(3);
+ const char *regpath = stack->pop()->getString();
+ const char *key = stack->pop()->getString();
+ int value = stack->pop()->getInt();
+
+ if (strcmp(key, "Windowed") == 0) {
+ inGame->_renderer->setWindowed(value);
+ } else {
+ warning("SetValueToReg(\"%s\",\"%s\",%d) is not implemented", regpath, key, value);
+ }
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/externals.h b/engines/wintermute/ext/externals.h
new file mode 100644
index 0000000000..fad8c45a2b
--- /dev/null
+++ b/engines/wintermute/ext/externals.h
@@ -0,0 +1,104 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+#ifndef WINTERMUTE_PLUGINS_H
+#define WINTERMUTE_PLUGINS_H
+
+namespace Wintermute {
+
+// Implemented in their respective .cpp-files
+bool EmulateGetURLExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateToolsExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateImgExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateShell32ExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateInstallUtilExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateDLLTestExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateKernel32ExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+bool EmulateHTTPConnectExternalCalls(BaseGame *, ScStack *, ScStack *, ScScript::TExternalFunction *);
+
+bool EmulateExternalCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
+
+ if (strcmp(function->dll_name, "geturl.dll") == 0) {
+ if (!DID_FAIL(EmulateGetURLExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "tools.dll") == 0) {
+ if (!DID_FAIL(EmulateToolsExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "img.dll") == 0) {
+ if (!DID_FAIL(EmulateImgExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "shell32.dll") == 0) {
+ if (!DID_FAIL(EmulateShell32ExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "installutil.dll") == 0) {
+ if (!DID_FAIL(EmulateInstallUtilExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "dlltest.dll") == 0) {
+ if (!DID_FAIL(EmulateDLLTestExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "kernel32.dll") == 0) {
+ if (!DID_FAIL(EmulateKernel32ExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ if (strcmp(function->dll_name, "httpconnect.dll") == 0) {
+ if (!DID_FAIL(EmulateHTTPConnectExternalCalls(inGame, stack, thisStack, function))) {
+ return STATUS_OK;
+ }
+ }
+
+ warning("External function %s from %s library is not known by ScummVM", function->name, function->dll_name);
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index e45703775a..b054f53edd 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -94,6 +94,14 @@ MODULE_OBJS := \
base/saveload.o \
base/save_thumb_helper.o \
base/timer.o \
+ ext/dll_dlltest.o \
+ ext/dll_geturl.o \
+ ext/dll_httpconnect.o \
+ ext/dll_img.o \
+ ext/dll_installutil.o \
+ ext/dll_kernel32.o \
+ ext/dll_shell32.o \
+ ext/dll_tools.o \
debugger/breakpoint.o \
debugger/debugger_controller.o \
debugger/error.o \
Commit: b783f984f11ad7ca9431324ba7c5c4f7c6fa5224
https://github.com/scummvm/scummvm/commit/b783f984f11ad7ca9431324ba7c5c4f7c6fa5224
Author: lolbot-iichan (lolbot_iichan at mail.ru)
Date: 2020-05-05T21:51:22+02:00
Commit Message:
WINTERMUTE: Move wme-plugins implementations to /ext/ folder
Changed paths:
A engines/wintermute/ext/plugins.h
A engines/wintermute/ext/wme_galaxy.cpp
A engines/wintermute/ext/wme_galaxy.h
A engines/wintermute/ext/wme_steam.cpp
A engines/wintermute/ext/wme_steam.h
R engines/wintermute/base/scriptables/script_ext_steam_api.cpp
R engines/wintermute/base/scriptables/script_ext_steam_api.h
R engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.cpp
R engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.h
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_scriptable.h
engines/wintermute/module.mk
engines/wintermute/persistent.cpp
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 668351f18d..f0c5f8d4df 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -54,6 +54,7 @@
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/sound/base_sound.h"
+#include "engines/wintermute/ext/plugins.h"
#include "engines/wintermute/video/video_player.h"
#include "engines/wintermute/video/video_theora_player.h"
#include "engines/wintermute/utils/utils.h"
@@ -3146,26 +3147,6 @@ bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack
stack->pushNULL();
}
- //////////////////////////////////////////////////////////////////////////
- // SteamAPI
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "SteamAPI") == 0) {
- thisObj = thisStack->getTop();
-
- thisObj->setNative(makeSXSteamAPI(_gameRef, stack));
- stack->pushNULL();
- }
-
- //////////////////////////////////////////////////////////////////////////
- // WMEGalaxyAPI
- //////////////////////////////////////////////////////////////////////////
- else if (strcmp(name, "WMEGalaxyAPI") == 0) {
- thisObj = thisStack->getTop();
-
- thisObj->setNative(makeSXWMEGalaxyAPI(_gameRef, stack));
- stack->pushNULL();
- }
-
//////////////////////////////////////////////////////////////////////////
// Object
//////////////////////////////////////////////////////////////////////////
@@ -3413,6 +3394,12 @@ bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack
}
#endif
+#if 1
+ else if(!DID_FAIL(EmulatePluginCall(_gameRef, stack, thisStack, name))) {
+ return STATUS_OK;
+ }
+#endif
+
//////////////////////////////////////////////////////////////////////////
// failure
else {
diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h
index 02ea854d3a..ef61d7c7af 100644
--- a/engines/wintermute/base/base_scriptable.h
+++ b/engines/wintermute/base/base_scriptable.h
@@ -79,8 +79,6 @@ BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXStore(BaseGame *inGame);
BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack);
-BaseScriptable *makeSXSteamAPI(BaseGame *inGame, ScStack *stack);
-BaseScriptable *makeSXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack);
} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/plugins.h b/engines/wintermute/ext/plugins.h
new file mode 100644
index 0000000000..342f78feeb
--- /dev/null
+++ b/engines/wintermute/ext/plugins.h
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+
+#ifndef WINTERMUTE_PLUGINS_H
+#define WINTERMUTE_PLUGINS_H
+
+namespace Wintermute {
+
+// Implemented in their respective .cpp-files
+BaseScriptable *makeSXSteamAPI(BaseGame *inGame, ScStack *stack);
+BaseScriptable *makeSXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack);
+
+bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, char *name) {
+ ScValue *thisObj;
+
+ //////////////////////////////////////////////////////////////////////////
+ // SteamAPI (from wme_steam.dll)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "SteamAPI") == 0) {
+ thisObj = thisStack->getTop();
+
+ thisObj->setNative(makeSXSteamAPI(inGame, stack));
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // WMEGalaxyAPI (from GOG version of julia.exe)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "WMEGalaxyAPI") == 0) {
+ thisObj = thisStack->getTop();
+
+ thisObj->setNative(makeSXWMEGalaxyAPI(inGame, stack));
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.cpp b/engines/wintermute/ext/wme_galaxy.cpp
similarity index 98%
rename from engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.cpp
rename to engines/wintermute/ext/wme_galaxy.cpp
index 5b9f3ee1cf..949839a046 100644
--- a/engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.cpp
+++ b/engines/wintermute/ext/wme_galaxy.cpp
@@ -32,7 +32,7 @@
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
-#include "engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.h"
+#include "engines/wintermute/ext/wme_galaxy.h"
namespace Wintermute {
diff --git a/engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.h b/engines/wintermute/ext/wme_galaxy.h
similarity index 100%
rename from engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.h
rename to engines/wintermute/ext/wme_galaxy.h
diff --git a/engines/wintermute/base/scriptables/script_ext_steam_api.cpp b/engines/wintermute/ext/wme_steam.cpp
similarity index 99%
rename from engines/wintermute/base/scriptables/script_ext_steam_api.cpp
rename to engines/wintermute/ext/wme_steam.cpp
index 01bb937879..47812abc32 100644
--- a/engines/wintermute/base/scriptables/script_ext_steam_api.cpp
+++ b/engines/wintermute/ext/wme_steam.cpp
@@ -32,7 +32,7 @@
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
-#include "engines/wintermute/base/scriptables/script_ext_steam_api.h"
+#include "engines/wintermute/ext/wme_steam.h"
namespace Wintermute {
diff --git a/engines/wintermute/base/scriptables/script_ext_steam_api.h b/engines/wintermute/ext/wme_steam.h
similarity index 100%
rename from engines/wintermute/base/scriptables/script_ext_steam_api.h
rename to engines/wintermute/ext/wme_steam.h
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index b054f53edd..59d1b4844d 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -41,8 +41,6 @@ MODULE_OBJS := \
base/scriptables/script_ext_object.o \
base/scriptables/script_ext_mem_buffer.o \
base/scriptables/script_ext_string.o \
- base/scriptables/script_ext_steam_api.o \
- base/scriptables/script_ext_wme_galaxy_api.o \
base/file/base_disk_file.o \
base/file/base_file.o \
base/file/base_file_entry.o \
@@ -102,6 +100,8 @@ MODULE_OBJS := \
ext/dll_kernel32.o \
ext/dll_shell32.o \
ext/dll_tools.o \
+ ext/wme_galaxy.o \
+ ext/wme_steam.o \
debugger/breakpoint.o \
debugger/debugger_controller.o \
debugger/error.o \
diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp
index 23356ace9b..c5424757ea 100644
--- a/engines/wintermute/persistent.cpp
+++ b/engines/wintermute/persistent.cpp
@@ -81,8 +81,8 @@
#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h"
#include "engines/wintermute/base/scriptables/script_ext_object.h"
#include "engines/wintermute/base/scriptables/script_ext_string.h"
-#include "engines/wintermute/base/scriptables/script_ext_steam_api.h"
-#include "engines/wintermute/base/scriptables/script_ext_wme_galaxy_api.h"
+#include "engines/wintermute/ext/wme_steam.h"
+#include "engines/wintermute/ext/wme_galaxy.h"
#include "engines/wintermute/ui/ui_button.h"
#include "engines/wintermute/ui/ui_edit.h"
#include "engines/wintermute/ui/ui_entity.h"
@@ -158,6 +158,7 @@ void SystemClassRegistry::registerClasses() {
REGISTER_CLASS(SXMemBuffer, false)
REGISTER_CLASS(SXObject, false)
REGISTER_CLASS(SXString, false)
+
REGISTER_CLASS(SXSteamAPI, false)
REGISTER_CLASS(SXWMEGalaxyAPI, false)
Commit: 14c54b0395be568f55534f30dc5460f415446b28
https://github.com/scummvm/scummvm/commit/14c54b0395be568f55534f30dc5460f415446b28
Author: lolbot-iichan (lolbot_iichan at mail.ru)
Date: 2020-05-05T21:51:22+02:00
Commit Message:
WINTERMUTE: Add stub for wme_3fstatistics.dll data collecting plugin
Changed paths:
A engines/wintermute/ext/wme_3fstatistics.cpp
A engines/wintermute/ext/wme_3fstatistics.h
engines/wintermute/ext/plugins.h
engines/wintermute/module.mk
engines/wintermute/persistent.cpp
diff --git a/engines/wintermute/ext/plugins.h b/engines/wintermute/ext/plugins.h
index 342f78feeb..4c61188fbd 100644
--- a/engines/wintermute/ext/plugins.h
+++ b/engines/wintermute/ext/plugins.h
@@ -38,6 +38,7 @@ namespace Wintermute {
// Implemented in their respective .cpp-files
BaseScriptable *makeSXSteamAPI(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack);
+BaseScriptable *makeSX3fStatistics(BaseGame *inGame, ScStack *stack);
bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, char *name) {
ScValue *thisObj;
@@ -66,6 +67,18 @@ bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, cha
return STATUS_OK;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Statistics (from wme_3fstatistics.dll)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "Statistics") == 0) {
+ thisObj = thisStack->getTop();
+
+ thisObj->setNative(makeSX3fStatistics(inGame, stack));
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
return STATUS_FAILED;
}
diff --git a/engines/wintermute/ext/wme_3fstatistics.cpp b/engines/wintermute/ext/wme_3fstatistics.cpp
new file mode 100644
index 0000000000..bb5d8e29a8
--- /dev/null
+++ b/engines/wintermute/ext/wme_3fstatistics.cpp
@@ -0,0 +1,173 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/metaengine.h"
+#include "engines/wintermute/wintermute.h"
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/ext/wme_3fstatistics.h"
+
+namespace Wintermute {
+
+IMPLEMENT_PERSISTENT(SX3fStatistics, false)
+
+BaseScriptable *makeSX3fStatistics(BaseGame *inGame, ScStack *stack) {
+ return new SX3fStatistics(inGame, stack);
+}
+
+//////////////////////////////////////////////////////////////////////////
+SX3fStatistics::SX3fStatistics(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
+ stack->correctParams(4);
+
+ ScValue * tmp;
+ _baseUrl = stack->pop()->getString();
+ tmp = stack->pop();
+ _chapter = tmp->isNULL() ? "" : tmp->getString();
+ tmp = stack->pop();
+ _language = tmp->isNULL() ? "" : tmp->getString();
+ tmp = stack->pop();
+ _buildNum = tmp->isNULL() ? "" : tmp->getString();
+
+ _repeat = 0;
+
+ _gameRef->LOG(0, "new Statistics(\"%s\", \"%s\", \"%s\", \"%s\")", _baseUrl.c_str(), _chapter.c_str(), _language.c_str(), _buildNum.c_str());
+}
+
+//////////////////////////////////////////////////////////////////////////
+SX3fStatistics::~SX3fStatistics() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+const char *SX3fStatistics::scToString() {
+ return "[statistics object]";
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool SX3fStatistics::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
+ //////////////////////////////////////////////////////////////////////////
+ // Send()
+ // Known stats to send are "Start a new game" and "--Juego Finalizado--"
+ // Known action: send HTTP POST request to _baseUrl
+ //
+ // Headers:
+ // Accept: */*
+ // User-Agent: Mozilla/4.0
+ // Content-Length: <len>
+ // Accept-Language: en-us
+ // Host: www.soluciones3f.com.ar
+ //
+ // Body:
+ // {
+ // "capitulo": "<_chapter value, e.g. '1'>",
+ // "dispositivo": "<OS family, e.g. 'windows'>",
+ // "hash": "<MD5 of MAC address, e.g. '58cb64ba781ca09f9e9cf8bd51ff0b05' for 44:8a:5b:00:00:00>",
+ // "idioma": "<_language value, e.g. 'ru'>",
+ // "idioma_os": "<OS language code, e.g. 'Russian_Russia.1251'>",
+ // "memoria": "<RAM size in bytes, e.g. '8504971264'>",
+ // "message": "<message value, e.g. 'Start a new game'>",
+ // "procesador": "<CPU model name, see /proc/cpuinfo for examples>",
+ // "resolucion": "<screen resolution, e.g. '1920x1080'>",
+ // "sistema": "<OS version, e.g. 'Microsoft (build 9200), 64-bit'",
+ // "version": "<_buildNum value, e.g. '1.3.2369'>",
+ // "windowed": "<screen mode windowed flag, e.g. 'yes'>"
+ // }
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Send") == 0) {
+ stack->correctParams(1);
+ const char *message = stack->pop()->getString();
+ _gameRef->LOG(0, "Send(\"%s\")", message);
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // SetRepeat()
+ // Known _repeat values are 0 and 60
+ // Known action: set timer to send HTTP POST request every _repeat seconds
+ // HTTP POST request is the same as with Send(), message is "Tick"
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "SetRepeat") == 0) {
+ stack->correctParams(1);
+ _repeat = stack->pop()->getInt();
+
+ // do nothing
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
+ else {
+ return STATUS_FAILED;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+ScValue *SX3fStatistics::scGetProperty(const Common::String &name) {
+ _scValue->setNULL();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Type (RO)
+ //////////////////////////////////////////////////////////////////////////
+ if (name == "Type") {
+ _scValue->setString("statistics");
+ return _scValue;
+ }
+
+ else {
+ return _scValue;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool SX3fStatistics::scSetProperty(const char *name, ScValue *value) {
+ return STATUS_FAILED;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool SX3fStatistics::persist(BasePersistenceManager *persistMgr) {
+ BaseScriptable::persist(persistMgr);
+
+ persistMgr->transferString(TMEMBER(_baseUrl));
+ persistMgr->transferString(TMEMBER(_chapter));
+ persistMgr->transferString(TMEMBER(_language));
+ persistMgr->transferString(TMEMBER(_buildNum));
+ persistMgr->transferSint32(TMEMBER(_repeat));
+
+ return STATUS_OK;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/wme_3fstatistics.h b/engines/wintermute/ext/wme_3fstatistics.h
new file mode 100644
index 0000000000..6ced2eb1f2
--- /dev/null
+++ b/engines/wintermute/ext/wme_3fstatistics.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_SX3FSTATISTICS_H
+#define WINTERMUTE_SX3FSTATISTICS_H
+
+#include "common/str.h"
+#include "engines/wintermute/base/base_scriptable.h"
+
+namespace Wintermute {
+
+class SX3fStatistics : public BaseScriptable {
+public:
+ DECLARE_PERSISTENT(SX3fStatistics, BaseScriptable)
+ ScValue *scGetProperty(const Common::String &name) override;
+ bool scSetProperty(const char *name, ScValue *value) override;
+ bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
+ const char *scToString() override;
+ SX3fStatistics(BaseGame *inGame, ScStack *stack);
+ ~SX3fStatistics() override;
+
+private:
+ Common::String _baseUrl;
+ Common::String _chapter;
+ Common::String _language;
+ Common::String _buildNum;
+ int _repeat;
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 59d1b4844d..f273083d21 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -100,6 +100,7 @@ MODULE_OBJS := \
ext/dll_kernel32.o \
ext/dll_shell32.o \
ext/dll_tools.o \
+ ext/wme_3fstatistics.o \
ext/wme_galaxy.o \
ext/wme_steam.o \
debugger/breakpoint.o \
diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp
index c5424757ea..00e8184397 100644
--- a/engines/wintermute/persistent.cpp
+++ b/engines/wintermute/persistent.cpp
@@ -81,6 +81,7 @@
#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h"
#include "engines/wintermute/base/scriptables/script_ext_object.h"
#include "engines/wintermute/base/scriptables/script_ext_string.h"
+#include "engines/wintermute/ext/wme_3fstatistics.h"
#include "engines/wintermute/ext/wme_steam.h"
#include "engines/wintermute/ext/wme_galaxy.h"
#include "engines/wintermute/ui/ui_button.h"
@@ -159,6 +160,7 @@ void SystemClassRegistry::registerClasses() {
REGISTER_CLASS(SXObject, false)
REGISTER_CLASS(SXString, false)
+ REGISTER_CLASS(SX3fStatistics, false)
REGISTER_CLASS(SXSteamAPI, false)
REGISTER_CLASS(SXWMEGalaxyAPI, false)
Commit: 7b2e3fb4407cb16948880522595c0dfb9e53f225
https://github.com/scummvm/scummvm/commit/7b2e3fb4407cb16948880522595c0dfb9e53f225
Author: lolbot-iichan (lolbot_iichan at mail.ru)
Date: 2020-05-05T21:51:22+02:00
Commit Message:
WINTERMUTE: Remove "#if 1" marks
Changed paths:
engines/wintermute/base/base_game.cpp
engines/wintermute/base/scriptables/script.cpp
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index f0c5f8d4df..341d65a571 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -3394,11 +3394,12 @@ bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack
}
#endif
-#if 1
+ //////////////////////////////////////////////////////////////////////////
+ // Plugins: emulate object constructors from known "wme_*.dll" plugins
+ //////////////////////////////////////////////////////////////////////////
else if(!DID_FAIL(EmulatePluginCall(_gameRef, stack, thisStack, name))) {
return STATUS_OK;
}
-#endif
//////////////////////////////////////////////////////////////////////////
// failure
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index 889e691d71..b2685a0280 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -1420,13 +1420,12 @@ ScScript::TExternalFunction *ScScript::getExternal(char *name) {
//////////////////////////////////////////////////////////////////////////
bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
-#if 1
+ //////////////////////////////////////////////////////////////////////////
+ // Externals: emulate external functions used in known games
+ //////////////////////////////////////////////////////////////////////////
if (!DID_FAIL(EmulateExternalCall(_gameRef, stack, thisStack, function))) {
return STATUS_OK;
}
-#else
- _gameRef->LOG(0, "External functions are not supported on this platform.");
-#endif
stack->correctParams(0);
stack->pushNULL();
More information about the Scummvm-git-logs
mailing list