[Scummvm-git-logs] scummvm master -> c671020d85fbe300c6d40231072c10b8a9f0c610
dreammaster
dreammaster at scummvm.org
Fri Feb 26 16:02:20 UTC 2021
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:
c671020d85 AGS: Further fixes to plugin script method definitions
Commit: c671020d85fbe300c6d40231072c10b8a9f0c610
https://github.com/scummvm/scummvm/commit/c671020d85fbe300c6d40231072c10b8a9f0c610
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-26T08:01:58-08:00
Commit Message:
AGS: Further fixes to plugin script method definitions
Changed paths:
engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.cpp
engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.h
engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
engines/ags/plugins/plugin_base.h
diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.cpp b/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.cpp
index 9bd0f8b360..c1969b7ced 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.cpp
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.cpp
@@ -30,7 +30,7 @@ AGSBlackwellSteam::AGSBlackwellSteam() : AGSSteam() {
DLL_METHOD(AGS_EngineStartup);
}
-int AGSBlackwellSteam::AddAchievement(const ScriptMethodParams ¶ms) {
+NumberPtr AGSBlackwellSteam::AddAchievement(const ScriptMethodParams ¶ms) {
return 0;
}
diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.h b/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.h
index 2aeac32a6b..15594cb491 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.h
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_blackwell_steam.h
@@ -32,7 +32,7 @@ namespace AGSGalaxySteam {
class AGSBlackwellSteam : public AGSSteam {
private:
static void AGS_EngineStartup(IAGSEngine *engine);
- static int AddAchievement(const ScriptMethodParams ¶ms);
+ static NumberPtr AddAchievement(const ScriptMethodParams ¶ms);
public:
AGSBlackwellSteam();
diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
index c78a40321a..bd69c44878 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
@@ -56,46 +56,46 @@ void AGS2Client::AGS_EngineStartup(IAGSEngine *engine) {
SCRIPT_METHOD_EXT(AGS2Client::Initialize^2, Initialize);
}
-bool AGS2Client::IsAchievementAchieved(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::IsAchievementAchieved(const ScriptMethodParams ¶ms) {
return false;
}
-bool AGS2Client::SetAchievementAchieved(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::SetAchievementAchieved(const ScriptMethodParams ¶ms) {
return false;
}
-bool AGS2Client::ResetAchievement(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::ResetAchievement(const ScriptMethodParams ¶ms) {
return false;
}
-int AGS2Client::GetIntStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::GetIntStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::GetFloatStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::GetFloatStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::GetAverageRateStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::GetAverageRateStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::SetIntStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::SetIntStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::SetFloatStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::SetFloatStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::UpdateAverageRateStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::UpdateAverageRateStat(const ScriptMethodParams ¶ms) {
return 0;
}
void AGS2Client::ResetStatsAndAchievements(const ScriptMethodParams ¶ms) {
}
-int AGS2Client::get_Initialized(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::get_Initialized(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -105,18 +105,18 @@ void AGS2Client::get_CurrentLeaderboardName(const ScriptMethodParams ¶ms) {
void AGS2Client::RequestLeaderboard(const ScriptMethodParams ¶ms) {
}
-int AGS2Client::UploadScore(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::UploadScore(const ScriptMethodParams ¶ms) {
return 0;
}
void AGS2Client::geti_LeaderboardNames(const ScriptMethodParams ¶ms) {
}
-int AGS2Client::geti_LeaderboardScores(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::geti_LeaderboardScores(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGS2Client::get_LeaderboardCount(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::get_LeaderboardCount(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -129,7 +129,7 @@ void AGS2Client::GetCurrentGameLanguage(const ScriptMethodParams ¶ms) {
void AGS2Client::FindLeaderboard(const ScriptMethodParams ¶ms) {
}
-int AGS2Client::Initialize(const ScriptMethodParams ¶ms) {
+NumberPtr AGS2Client::Initialize(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -315,12 +315,12 @@ void AGSSteam::AGS_EngineStartup(IAGSEngine *engine) {
}
}
-bool AGSSteam::IsAchievementAchieved(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::IsAchievementAchieved(const ScriptMethodParams ¶ms) {
PARAMS1(char *, id);
return AchMan.isAchieved(id);
}
-bool AGSSteam::SetAchievementAchieved(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::SetAchievementAchieved(const ScriptMethodParams ¶ms) {
PARAMS1(char *, id);
const MetaEngine &meta = ::AGS::g_vm->getMetaEngine();
@@ -336,32 +336,32 @@ bool AGSSteam::SetAchievementAchieved(const ScriptMethodParams ¶ms) {
return AchMan.setAchievement(id, msg);
}
-bool AGSSteam::ResetAchievement(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::ResetAchievement(const ScriptMethodParams ¶ms) {
PARAMS1(char *, id);
return AchMan.clearAchievement(id);
}
-int AGSSteam::GetIntStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::GetIntStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::GetFloatStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::GetFloatStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::GetAverageRateStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::GetAverageRateStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::SetIntStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::SetIntStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::SetFloatStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::SetFloatStat(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::UpdateAverageRateStat(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::UpdateAverageRateStat(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -370,7 +370,7 @@ void AGSSteam::ResetStatsAndAchievements(const ScriptMethodParams ¶ms) {
AchMan.resetAllStats();
}
-int AGSSteam::get_Initialized(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::get_Initialized(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -380,18 +380,18 @@ void AGSSteam::get_CurrentLeaderboardName(const ScriptMethodParams ¶ms) {
void AGSSteam::RequestLeaderboard(const ScriptMethodParams ¶ms) {
}
-int AGSSteam::UploadScore(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::UploadScore(const ScriptMethodParams ¶ms) {
return 0;
}
void AGSSteam::geti_LeaderboardNames(const ScriptMethodParams ¶ms) {
}
-int AGSSteam::geti_LeaderboardScores(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::geti_LeaderboardScores(const ScriptMethodParams ¶ms) {
return 0;
}
-int AGSSteam::get_LeaderboardCount(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::get_LeaderboardCount(const ScriptMethodParams ¶ms) {
return 0;
}
@@ -401,7 +401,7 @@ void AGSSteam::GetUserName(const ScriptMethodParams ¶ms) {
void AGSSteam::GetCurrentGameLanguage(const ScriptMethodParams ¶ms) {
}
-int AGSSteam::FindLeaderboard(const ScriptMethodParams ¶ms) {
+NumberPtr AGSSteam::FindLeaderboard(const ScriptMethodParams ¶ms) {
return 0;
}
diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
index 8dc970e626..bad7f9fac9 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
@@ -35,27 +35,27 @@ namespace AGSGalaxySteam {
class AGS2Client : public PluginBase {
protected:
- static bool IsAchievementAchieved(const ScriptMethodParams ¶ms);
- static bool SetAchievementAchieved(const ScriptMethodParams ¶ms);
- static bool ResetAchievement(const ScriptMethodParams ¶ms);
- static int GetIntStat(const ScriptMethodParams ¶ms);
- static int GetFloatStat(const ScriptMethodParams ¶ms);
- static int GetAverageRateStat(const ScriptMethodParams ¶ms);
- static int SetIntStat(const ScriptMethodParams ¶ms);
- static int SetFloatStat(const ScriptMethodParams ¶ms);
- static int UpdateAverageRateStat(const ScriptMethodParams ¶ms);
+ static NumberPtr IsAchievementAchieved(const ScriptMethodParams ¶ms);
+ static NumberPtr SetAchievementAchieved(const ScriptMethodParams ¶ms);
+ static NumberPtr ResetAchievement(const ScriptMethodParams ¶ms);
+ static NumberPtr GetIntStat(const ScriptMethodParams ¶ms);
+ static NumberPtr GetFloatStat(const ScriptMethodParams ¶ms);
+ static NumberPtr GetAverageRateStat(const ScriptMethodParams ¶ms);
+ static NumberPtr SetIntStat(const ScriptMethodParams ¶ms);
+ static NumberPtr SetFloatStat(const ScriptMethodParams ¶ms);
+ static NumberPtr UpdateAverageRateStat(const ScriptMethodParams ¶ms);
static void ResetStatsAndAchievements(const ScriptMethodParams ¶ms);
- static int get_Initialized(const ScriptMethodParams ¶ms);
+ static NumberPtr get_Initialized(const ScriptMethodParams ¶ms);
static void get_CurrentLeaderboardName(const ScriptMethodParams ¶ms);
static void RequestLeaderboard(const ScriptMethodParams ¶ms);
- static int UploadScore(const ScriptMethodParams ¶ms);
+ static NumberPtr UploadScore(const ScriptMethodParams ¶ms);
static void geti_LeaderboardNames(const ScriptMethodParams ¶ms);
- static int geti_LeaderboardScores(const ScriptMethodParams ¶ms);
- static int get_LeaderboardCount(const ScriptMethodParams ¶ms);
+ static NumberPtr geti_LeaderboardScores(const ScriptMethodParams ¶ms);
+ static NumberPtr get_LeaderboardCount(const ScriptMethodParams ¶ms);
static void GetUserName(const ScriptMethodParams ¶ms);
static void GetCurrentGameLanguage(const ScriptMethodParams ¶ms);
static void FindLeaderboard(const ScriptMethodParams ¶ms);
- static int Initialize(const ScriptMethodParams ¶ms);
+ static NumberPtr Initialize(const ScriptMethodParams ¶ms);
protected:
static void AGS_EngineStartup(IAGSEngine *engine);
@@ -101,26 +101,26 @@ private:
protected:
static void AGS_EngineStartup(IAGSEngine *engine);
- static bool IsAchievementAchieved(const ScriptMethodParams ¶ms);
- static bool SetAchievementAchieved(const ScriptMethodParams ¶ms);
- static bool ResetAchievement(const ScriptMethodParams ¶ms);
- static int GetIntStat(const ScriptMethodParams ¶ms);
- static int GetFloatStat(const ScriptMethodParams ¶ms);
- static int GetAverageRateStat(const ScriptMethodParams ¶ms);
- static int SetIntStat(const ScriptMethodParams ¶ms);
- static int SetFloatStat(const ScriptMethodParams ¶ms);
- static int UpdateAverageRateStat(const ScriptMethodParams ¶ms);
+ static NumberPtr IsAchievementAchieved(const ScriptMethodParams ¶ms);
+ static NumberPtr SetAchievementAchieved(const ScriptMethodParams ¶ms);
+ static NumberPtr ResetAchievement(const ScriptMethodParams ¶ms);
+ static NumberPtr GetIntStat(const ScriptMethodParams ¶ms);
+ static NumberPtr GetFloatStat(const ScriptMethodParams ¶ms);
+ static NumberPtr GetAverageRateStat(const ScriptMethodParams ¶ms);
+ static NumberPtr SetIntStat(const ScriptMethodParams ¶ms);
+ static NumberPtr SetFloatStat(const ScriptMethodParams ¶ms);
+ static NumberPtr UpdateAverageRateStat(const ScriptMethodParams ¶ms);
static void ResetStatsAndAchievements(const ScriptMethodParams ¶ms);
- static int get_Initialized(const ScriptMethodParams ¶ms);
+ static NumberPtr get_Initialized(const ScriptMethodParams ¶ms);
static void get_CurrentLeaderboardName(const ScriptMethodParams ¶ms);
static void RequestLeaderboard(const ScriptMethodParams ¶ms);
- static int UploadScore(const ScriptMethodParams ¶ms);
+ static NumberPtr UploadScore(const ScriptMethodParams ¶ms);
static void geti_LeaderboardNames(const ScriptMethodParams ¶ms);
- static int geti_LeaderboardScores(const ScriptMethodParams ¶ms);
- static int get_LeaderboardCount(const ScriptMethodParams ¶ms);
+ static NumberPtr geti_LeaderboardScores(const ScriptMethodParams ¶ms);
+ static NumberPtr get_LeaderboardCount(const ScriptMethodParams ¶ms);
static void GetUserName(const ScriptMethodParams ¶ms);
static void GetCurrentGameLanguage(const ScriptMethodParams ¶ms);
- static int FindLeaderboard(const ScriptMethodParams ¶ms);
+ static NumberPtr FindLeaderboard(const ScriptMethodParams ¶ms);
public:
AGSSteam();
diff --git a/engines/ags/plugins/plugin_base.h b/engines/ags/plugins/plugin_base.h
index 5ff72e0090..f38dfb2f94 100644
--- a/engines/ags/plugins/plugin_base.h
+++ b/engines/ags/plugins/plugin_base.h
@@ -32,8 +32,8 @@ namespace AGS3 {
namespace Plugins {
#define DLL_METHOD(NAME) _methods[#NAME] = (void *)&NAME
-#define SCRIPT_METHOD(NAME) engine->RegisterScriptFunction(#NAME, (void *)&NAME)
-#define SCRIPT_METHOD_EXT(NAME, PROC) engine->RegisterScriptFunction(#NAME, (void *)&(PROC))
+#define SCRIPT_METHOD(NAME) registerFunction(engine, #NAME, &NAME)
+#define SCRIPT_METHOD_EXT(NAME, PROC) registerFunction(engine, #NAME, &(PROC))
#define PARAMS1(T1, N1) \
T1 N1 = (T1)params[0]
@@ -94,6 +94,9 @@ namespace Plugins {
using string = const char *;
typedef uint32 HWND;
+typedef void (*PluginMethod)(const ScriptMethodParams ¶ms);
+typedef NumberPtr(*PluginFunction)(const ScriptMethodParams ¶ms);
+
/**
* Base class for the implementation of AGS plugins
*/
@@ -114,6 +117,13 @@ protected:
static NumberPtr AGS_EngineOnEvent(int, NumberPtr);
static int AGS_EngineDebugHook(const char *, int, int);
static void AGS_EngineInitGfx(const char *driverID, void *data);
+
+ static inline void registerFunction(IAGSEngine *engine, const char *name, PluginMethod fn) {
+ engine->RegisterScriptFunction(name, (void *)fn);
+ }
+ static inline void registerFunction(IAGSEngine *engine, const char *name, PluginFunction fn) {
+ engine->RegisterScriptFunction(name, (void *)fn);
+ }
public:
PluginBase();
More information about the Scummvm-git-logs
mailing list