AGS: Plugin code cleanup, stubs for Galaxy/Steam plugins

This commit is contained in:
Paul Gilbert 2021-02-07 17:40:55 -08:00
parent e9300f33d5
commit e6f7b43945
15 changed files with 555 additions and 626 deletions

View File

@ -36,13 +36,11 @@ public:
virtual ~BaseLibrary() {}
virtual AGS::Shared::String GetFilenameForLib(AGS::Shared::String libraryName) = 0;
virtual bool Load(AGS::Shared::String libraryName) = 0;
virtual bool Load(const AGS::Shared::String &libraryName) = 0;
virtual bool Unload() = 0;
virtual void *GetFunctionAddress(AGS::Shared::String functionName) = 0;
virtual void *GetFunctionAddress(const AGS::Shared::String &functionName) = 0;
};
@ -50,17 +48,4 @@ public:
} // namespace AGS
} // namespace AGS3
#if AGS_PLATFORM_OS_WINDOWS
#include "ags/shared/library_windows.h"
#elif AGS_PLATFORM_OS_LINUX \
|| AGS_PLATFORM_OS_MACOS \
|| AGS_PLATFORM_OS_ANDROID
#include "ags/engine/util/library_posix.h"
#elif AGS_PLATFORM_OS_IOS
#include "ags/engine/util/library_dummy.h"
#endif
#endif

View File

@ -1,143 +0,0 @@
/* 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.
*
*/
#ifndef AGS_ENGINE_UTIL_LIBRARY_POSIX_H
#define AGS_ENGINE_UTIL_LIBRARY_POSIX_H
//include <dlfcn.h>
#include "ags/shared/core/platform.h"
#include "ags/shared/util/string.h"
#include "ags/shared/debugging/out.h"
#include "ags/plugins/library.h"
#include "ags/engine/globals.h"
namespace AGS3 {
// FIXME: Replace with a unified way to get the directory which contains the engine binary
#if AGS_PLATFORM_OS_ANDROID
extern char android_app_directory[256];
#endif
namespace AGS {
namespace Engine {
class PosixLibrary : BaseLibrary {
public:
PosixLibrary()
: _library(nullptr) {
};
~PosixLibrary() override {
Unload();
};
AGS::Shared::String BuildFilename(AGS::Shared::String libraryName) {
return String::FromFormat(
#if AGS_PLATFORM_OS_MACOS
"lib%s.dylib"
#else
"lib%s.so"
#endif
, libraryName.GetCStr());
}
AGS::Shared::String BuildPath(const char *path, AGS::Shared::String libraryName) {
AGS::Shared::String platformLibraryName = "";
if (path) {
platformLibraryName = path;
platformLibraryName.Append("/");
}
platformLibraryName.Append(BuildFilename(libraryName));
AGS::Shared::Debug::Printf("Built library path: %s", platformLibraryName.GetCStr());
return platformLibraryName;
}
AGS::Shared::String GetFilenameForLib(AGS::Shared::String libraryName) override {
return BuildFilename(libraryName);
}
bool Load(AGS::Shared::String libraryName) override {
Unload();
// Try rpath first
_library = dlopen(BuildPath(nullptr, libraryName).GetCStr(), RTLD_LAZY);
AGS::Shared::Debug::Printf("dlopen returned: %s", dlerror());
if (_library != nullptr) {
return true;
}
// Try current path
_library = dlopen(BuildPath(".", libraryName).GetCStr(), RTLD_LAZY);
AGS::Shared::Debug::Printf("dlopen returned: %s", dlerror());
if (_library == nullptr) {
// Try the engine directory
#if AGS_PLATFORM_OS_ANDROID
char buffer[200];
sprintf(buffer, "%s%s", android_app_directory, "/lib");
_library = dlopen(BuildPath(buffer, libraryName).GetCStr(), RTLD_LAZY);
#else
_library = dlopen(BuildPath(_G(appDirectory), libraryName).GetCStr(), RTLD_LAZY);
#endif
AGS::Shared::Debug::Printf("dlopen returned: %s", dlerror());
}
return (_library != nullptr);
}
bool Unload() override {
if (_library) {
void *lib = _library;
_library = nullptr;
return (dlclose(lib) == 0);
} else {
return true;
}
}
void *GetFunctionAddress(AGS::Shared::String functionName) override {
if (_library) {
return dlsym(_library, functionName.GetCStr());
} else {
return nullptr;
}
}
private:
void *_library;
};
typedef PosixLibrary Library;
} // namespace Engine
} // namespace AGS
} // namespace AGS3
#endif

View File

@ -1,134 +0,0 @@
/* 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.
*
*/
#ifndef AGS_ENGINE_UTIL_LIBRARY_PSP_H
#define AGS_ENGINE_UTIL_LIBRARY_PSP_H
//include <pspsdk.h>
#include "ags/shared/util/string.h"
#include "ags/shared/debugging/out.h"
namespace AGS3 {
namespace AGS {
namespace Engine {
class PSPLibrary : BaseLibrary {
public:
PSPLibrary()
: _library(-1) {
};
virtual ~PSPLibrary() {
Unload();
};
AGS::Shared::String BuildPath(char *path, AGS::Shared::String libraryName) {
AGS::Shared::String platformLibraryName = path;
platformLibraryName.Append(libraryName);
platformLibraryName.Append(".prx");
AGS::Shared::Debug::Printf("Built library path: %s", platformLibraryName.GetCStr());
return platformLibraryName;
}
bool Load(AGS::Shared::String libraryName) {
Unload();
// Try current path
_library = pspSdkLoadStartModule(BuildPath("./", libraryName).GetCStr(), PSP_MEMORY_PARTITION_USER);
if (_library < 0) {
// Try one directory higher, usually the AGS base directory
_library = pspSdkLoadStartModule(BuildPath("../", libraryName).GetCStr(), PSP_MEMORY_PARTITION_USER);
}
// The PSP module and PSP library name are assumed to be the same as the file name
_moduleName = libraryName;
_moduleName.MakeLower();
AGS::Shared::Debug::Printf("Result is %s %d", _moduleName.GetCStr(), _library);
return (_library > -1);
}
bool Unload() {
if (_library > -1) {
return (sceKernelUnloadModule(_library) > -1);
} else {
return true;
}
}
void *GetFunctionAddress(AGS::Shared::String functionName) {
if (_library > -1) {
// On the PSP functions are identified by an ID that is the first 4 byte of the SHA1 of the name.
int functionId;
#if 1
// Hardcoded values for plugin loading.
if (functionName == "AGS_PluginV2") {
functionId = 0x960C49BD;
} else if (functionName == "AGS_EngineStartup") {
functionId = 0x0F13D9E8;
} else if (functionName == "AGS_EngineShutdown") {
functionId = 0x2F131C76;
} else if (functionName == "AGS_EngineOnEvent") {
functionId = 0xE3DFFC5A;
} else if (functionName == "AGS_EngineDebugHook") {
functionId = 0xC37D6879;
} else if (functionName == "AGS_EngineInitGfx") {
functionId = 0xA428D254;
} else {
AGS::Shared::Debug::Printf("Function ID not found: %s", functionName.GetCStr());
functionId = -1;
}
#else
// This is a possible SHA1 implementation.
SceKernelUtilsSha1Context ctx;
uint8_t digest[20];
sceKernelUtilsSha1BlockInit(&ctx);
sceKernelUtilsSha1BlockUpdate(&ctx, (uint8_t *)functionName.GetCStr(), functionName.GetLength());
sceKernelUtilsSha1BlockResult(&ctx, digest);
functionId = strtol(digest, NULL, 8);
#endif
return (void *)kernel_sctrlHENFindFunction((char *)_moduleName.GetCStr(), (char *)_moduleName.GetCStr(), functionId);
} else {
return NULL;
}
}
private:
SceUID _library;
AGS::Shared::String _moduleName;
};
typedef PSPLibrary Library;
} // namespace Engine
} // namespace AGS
} // namespace AGS3
#endif

View File

@ -20,39 +20,64 @@
*
*/
#ifndef AGS_ENGINE_UTIL_LIBRARY_DUMMY_H
#define AGS_ENGINE_UTIL_LIBRARY_DUMMY_H
#ifndef AGS_ENGINE_UTIL_LIBRARY_SCUMMVM_H
#define AGS_ENGINE_UTIL_LIBRARY_SCUMMVM_H
#include "ags/shared/core/platform.h"
#include "ags/shared/util/string.h"
#include "ags/shared/debugging/out.h"
#include "ags/plugins/dll.h"
#include "ags/engine/globals.h"
namespace AGS3 {
namespace AGS {
namespace Engine {
class DummyLibrary : BaseLibrary {
class ScummVMLibrary : BaseLibrary {
public:
DummyLibrary() {
ScummVMLibrary()
: _library(nullptr) {
};
~DummyLibrary() override {
~ScummVMLibrary() override {
Unload();
};
AGS::Shared::String GetFilenameForLib(AGS::Shared::String libraryName) override {
return libraryName;
}
bool Load(const AGS::Shared::String &libraryName) override {
Unload();
bool Load(AGS::Shared::String libraryName) override {
return false;
_library = Plugins::pluginOpen(libraryName.GetCStr());
AGS::Shared::Debug::Printf("pluginOpen returned: %s", Plugins::pluginError());
return (_library != nullptr);
}
bool Unload() override {
return true;
if (_library) {
void *lib = _library;
_library = nullptr;
return (Plugins::pluginClose(lib) == 0);
} else {
return true;
}
}
void *GetFunctionAddress(AGS::Shared::String functionName) override {
return NULL;
void *GetFunctionAddress(const AGS::Shared::String &functionName) override {
if (_library) {
return Plugins::pluginSym(_library, functionName.GetCStr());
} else {
return nullptr;
}
}
private:
void *_library;
};
typedef DummyLibrary Library;
typedef ScummVMLibrary Library;
} // namespace Engine
} // namespace AGS

View File

@ -1,108 +0,0 @@
/* 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.
*
*/
#ifndef AGS_ENGINE_UTIL_LIBRARY_WINDOWS_H
#define AGS_ENGINE_UTIL_LIBRARY_WINDOWS_H
#include "ags/shared/debugging/out.h"
#include "ags/shared/platform/windows/winapi_exclusive.h"
#include "ags/shared/util/string.h"
namespace AGS3 {
// Because this class may be exposed to generic code in sake of inlining,
// we should avoid including <windows.h> full of macros with common names.
#ifdef __cplusplus
extern "C" {
#endif
WINBASEAPI BOOL WINAPI FreeLibrary(HMODULE hLibModule);
WINBASEAPI FARPROC WINAPI GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
WINBASEAPI HMODULE WINAPI LoadLibraryA(LPCSTR lpLibFileName);
#ifdef __cplusplus
} // extern "C"
#endif
namespace AGS {
namespace Engine {
class WindowsLibrary : BaseLibrary {
public:
WindowsLibrary()
: _library(NULL) {
};
virtual ~WindowsLibrary() {
Unload();
};
AGS::Shared::String BuildFilename(AGS::Shared::String libraryName) {
return String::FromFormat("%s.dll", libraryName.GetCStr());
}
AGS::Shared::String BuildPath(AGS::Shared::String libraryName) {
AGS::Shared::String platformLibraryName = BuildFilename(libraryName);
AGS::Shared::Debug::Printf("Built library path: %s", platformLibraryName.GetCStr());
return platformLibraryName;
}
AGS::Shared::String GetFilenameForLib(AGS::Shared::String libraryName) override {
return BuildFilename(libraryName);
}
bool Load(AGS::Shared::String libraryName) {
Unload();
_library = LoadLibraryA(BuildPath(libraryName).GetCStr());
return (_library != NULL);
}
bool Unload() {
if (_library) {
return (FreeLibrary(_library) != 0);
} else {
return true;
}
}
void *GetFunctionAddress(AGS::Shared::String functionName) {
return GetProcAddress(_library, functionName.GetCStr());
}
private:
HANDLE _library;
};
typedef WindowsLibrary Library;
} // namespace Engine
} // namespace AGS
} // namespace AGS3
#endif

View File

@ -288,11 +288,11 @@ MODULE_OBJS = \
plugins/agsplugin.o \
plugins/dll.o \
plugins/global_plugin.o \
plugins/library.o \
plugins/pluginobjectreader.o \
plugins/ags_blend/ags_blend.o \
plugins/ags_creditz/ags_creditz.o \
plugins/ags_flashlight/ags_flashlight.o \
plugins/ags_galaxy_steam/ags_galaxy_steam.o \
plugins/ags_pal_render/ags_pal_render.o \
plugins/ags_pal_render/raycast.o \
plugins/ags_parallax/ags_parallax.o \
@ -304,8 +304,7 @@ MODULE_OBJS = \
plugins/ags_sprite_font/sprite_font.o \
plugins/ags_sprite_font/sprite_font_renderer.o \
plugins/ags_sprite_font/variable_width_font.o \
plugins/ags_sprite_font/variable_width_sprite_font.o \
plugins/ags_steam/ags_steam.o
plugins/ags_sprite_font/variable_width_sprite_font.o
ifdef ENABLE_AGS_SCANNER
MODULE_OBJS += \

View File

@ -0,0 +1,356 @@
/* 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.
*
*/
#include "ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
AGS2Client::AGS2Client() : DLL() {
DLL_METHOD(AGS_EngineStartup);
}
void AGS2Client::AGS_EngineStartup(IAGSEngine *engine) {
SCRIPT_METHOD_EXT(AGS2Client::IsAchievementAchieved^1, IsAchievementAchieved);
SCRIPT_METHOD_EXT(AGS2Client::SetAchievementAchieved^1, SetAchievementAchieved);
SCRIPT_METHOD_EXT(AGS2Client::ResetAchievement^1, ResetAchievement);
SCRIPT_METHOD_EXT(AGS2Client::GetIntStat^1, GetIntStat);
SCRIPT_METHOD_EXT(AGS2Client::GetFloatStat^1, GetFloatStat);
SCRIPT_METHOD_EXT(AGS2Client::GetAverageRateStat^1, GetAverageRateStat);
SCRIPT_METHOD_EXT(AGS2Client::SetIntStat^2, SetIntStat);
SCRIPT_METHOD_EXT(AGS2Client::SetFloatStat^2, SetFloatStat);
SCRIPT_METHOD_EXT(AGS2Client::UpdateAverageRateStat^3, UpdateAverageRateStat);
SCRIPT_METHOD_EXT(AGS2Client::ResetStatsAndAchievements^0, ResetStatsAndAchievements);
SCRIPT_METHOD_EXT(AGS2Client::get_Initialized, get_Initialized);
SCRIPT_METHOD_EXT(AGS2Client::get_CurrentLeaderboardName, get_CurrentLeaderboardName);
SCRIPT_METHOD_EXT(AGS2Client::RequestLeaderboard^3, RequestLeaderboard);
SCRIPT_METHOD_EXT(AGS2Client::UploadScore^1, UploadScore);
SCRIPT_METHOD_EXT(AGS2Client::geti_LeaderboardNames, geti_LeaderboardNames);
SCRIPT_METHOD_EXT(AGS2Client::geti_LeaderboardScores, geti_LeaderboardScores);
SCRIPT_METHOD_EXT(AGS2Client::get_LeaderboardCount, get_LeaderboardCount);
SCRIPT_METHOD_EXT(AGS2Client::GetUserName^0, GetUserName);
SCRIPT_METHOD_EXT(AGS2Client::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
SCRIPT_METHOD_EXT(AGS2Client::FindLeaderboard^1, FindLeaderboard);
SCRIPT_METHOD_EXT(AGS2Client::Initialize^2, Initialize);
}
int AGS2Client::IsAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::SetAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::ResetAchievement(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::GetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::GetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::GetAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::SetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::SetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::UpdateAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
void AGS2Client::ResetStatsAndAchievements(const ScriptMethodParams &params) {
}
int AGS2Client::get_Initialized(const ScriptMethodParams &params) {
return 0;
}
void AGS2Client::get_CurrentLeaderboardName(const ScriptMethodParams &params) {
}
void AGS2Client::RequestLeaderboard(const ScriptMethodParams &params) {
}
int AGS2Client::UploadScore(const ScriptMethodParams &params) {
return 0;
}
void AGS2Client::geti_LeaderboardNames(const ScriptMethodParams &params) {
}
int AGS2Client::geti_LeaderboardScores(const ScriptMethodParams &params) {
return 0;
}
int AGS2Client::get_LeaderboardCount(const ScriptMethodParams &params) {
return 0;
}
void AGS2Client::GetUserName(const ScriptMethodParams &params) {
}
void AGS2Client::GetCurrentGameLanguage(const ScriptMethodParams &params) {
}
void AGS2Client::FindLeaderboard(const ScriptMethodParams &params) {
}
int AGS2Client::Initialize(const ScriptMethodParams &params) {
return 0;
}
/*------------------------------------------------------------------*/
AGSGalaxy::AGSGalaxy() : AGS2Client() {
DLL_METHOD(AGS_GetPluginName);
DLL_METHOD(AGS_EngineStartup);
}
const char *AGSGalaxy::AGS_GetPluginName() {
return "AGSGalaxy";
}
void AGSGalaxy::AGS_EngineStartup(IAGSEngine *engine) {
AGS2Client::AGS_EngineStartup(engine);
SCRIPT_METHOD_EXT(AGSGalaxy::IsAchievementAchieved^1, IsAchievementAchieved);
SCRIPT_METHOD_EXT(AGSGalaxy::SetAchievementAchieved^1, SetAchievementAchieved);
SCRIPT_METHOD_EXT(AGSGalaxy::ResetAchievement^1, ResetAchievement);
SCRIPT_METHOD_EXT(AGSGalaxy::GetIntStat^1, GetIntStat);
SCRIPT_METHOD_EXT(AGSGalaxy::GetFloatStat^1, GetFloatStat);
SCRIPT_METHOD_EXT(AGSGalaxy::GetAverageRateStat^1, GetAverageRateStat);
SCRIPT_METHOD_EXT(AGSGalaxy::SetIntStat^2, SetIntStat);
SCRIPT_METHOD_EXT(AGSGalaxy::SetFloatStat^2, SetFloatStat);
SCRIPT_METHOD_EXT(AGSGalaxy::UpdateAverageRateStat^3, UpdateAverageRateStat);
SCRIPT_METHOD_EXT(AGSGalaxy::ResetStatsAndAchievements^0, ResetStatsAndAchievements);
SCRIPT_METHOD_EXT(AGSGalaxy::get_Initialized, get_Initialized);
SCRIPT_METHOD_EXT(AGSGalaxy::get_CurrentLeaderboardName, get_CurrentLeaderboardName);
SCRIPT_METHOD_EXT(AGSGalaxy::RequestLeaderboard^3, RequestLeaderboard);
SCRIPT_METHOD_EXT(AGSGalaxy::UploadScore^1, UploadScore);
SCRIPT_METHOD_EXT(AGSGalaxy::geti_LeaderboardNames, geti_LeaderboardNames);
SCRIPT_METHOD_EXT(AGSGalaxy::geti_LeaderboardScores, geti_LeaderboardScores);
SCRIPT_METHOD_EXT(AGSGalaxy::get_LeaderboardCount, get_LeaderboardCount);
SCRIPT_METHOD_EXT(AGSGalaxy::GetUserName^0, GetUserName);
SCRIPT_METHOD_EXT(AGSGalaxy::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
SCRIPT_METHOD_EXT(AGSGalaxy::Initialize^2, Initialize);
}
int AGSGalaxy::IsAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::SetAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::ResetAchievement(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::GetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::GetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::GetAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::SetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::SetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::UpdateAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
void AGSGalaxy::ResetStatsAndAchievements(const ScriptMethodParams &params) {
}
int AGSGalaxy::get_Initialized(const ScriptMethodParams &params) {
return 0;
}
void AGSGalaxy::get_CurrentLeaderboardName(const ScriptMethodParams &params) {
}
void AGSGalaxy::RequestLeaderboard(const ScriptMethodParams &params) {
}
int AGSGalaxy::UploadScore(const ScriptMethodParams &params) {
return 0;
}
void AGSGalaxy::geti_LeaderboardNames(const ScriptMethodParams &params) {
}
int AGSGalaxy::geti_LeaderboardScores(const ScriptMethodParams &params) {
return 0;
}
int AGSGalaxy::get_LeaderboardCount(const ScriptMethodParams &params) {
return 0;
}
void AGSGalaxy::GetUserName(const ScriptMethodParams &params) {
}
void AGSGalaxy::GetCurrentGameLanguage(const ScriptMethodParams &params) {
}
int AGSGalaxy::Initialize(const ScriptMethodParams &params) {
return 0;
}
/*------------------------------------------------------------------*/
AGSSteam::AGSSteam() : AGS2Client() {
DLL_METHOD(AGS_GetPluginName);
DLL_METHOD(AGS_EngineStartup);
}
const char *AGSSteam::AGS_GetPluginName() {
return "AGSSteam";
}
void AGSSteam::AGS_EngineStartup(IAGSEngine *engine) {
AGS2Client::AGS_EngineStartup(engine);
SCRIPT_METHOD_EXT(AGSteam::IsAchievementAchieved^1, IsAchievementAchieved);
SCRIPT_METHOD_EXT(AGSteam::SetAchievementAchieved^1, SetAchievementAchieved);
SCRIPT_METHOD_EXT(AGSteam::ResetAchievement^1, ResetAchievement);
SCRIPT_METHOD_EXT(AGSteam::GetIntStat^1, GetIntStat);
SCRIPT_METHOD_EXT(AGSteam::GetFloatStat^1, GetFloatStat);
SCRIPT_METHOD_EXT(AGSteam::GetAverageRateStat^1, GetAverageRateStat);
SCRIPT_METHOD_EXT(AGSteam::SetIntStat^2, SetIntStat);
SCRIPT_METHOD_EXT(AGSteam::SetFloatStat^2, SetFloatStat);
SCRIPT_METHOD_EXT(AGSteam::UpdateAverageRateStat^3, UpdateAverageRateStat);
SCRIPT_METHOD_EXT(AGSteam::ResetStatsAndAchievements^0, ResetStatsAndAchievements);
SCRIPT_METHOD_EXT(AGSteam::get_Initialized, get_Initialized);
SCRIPT_METHOD_EXT(AGSteam::get_CurrentLeaderboardName, get_CurrentLeaderboardName);
SCRIPT_METHOD_EXT(AGSteam::RequestLeaderboard^3, RequestLeaderboard);
SCRIPT_METHOD_EXT(AGSteam::UploadScore^1, UploadScore);
SCRIPT_METHOD_EXT(AGSteam::geti_LeaderboardNames, geti_LeaderboardNames);
SCRIPT_METHOD_EXT(AGSteam::geti_LeaderboardScores, geti_LeaderboardScores);
SCRIPT_METHOD_EXT(AGSteam::get_LeaderboardCount, get_LeaderboardCount);
SCRIPT_METHOD_EXT(AGSteam::GetUserName^0, GetUserName);
SCRIPT_METHOD_EXT(AGSteam::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
SCRIPT_METHOD_EXT(AGSteam::FindLeaderboard^1, FindLeaderboard);
}
int AGSSteam::IsAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::SetAchievementAchieved(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::ResetAchievement(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::GetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::GetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::GetAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::SetIntStat(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::SetFloatStat(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::UpdateAverageRateStat(const ScriptMethodParams &params) {
return 0;
}
void AGSSteam::ResetStatsAndAchievements(const ScriptMethodParams &params) {
}
int AGSSteam::get_Initialized(const ScriptMethodParams &params) {
return 0;
}
void AGSSteam::get_CurrentLeaderboardName(const ScriptMethodParams &params) {
}
void AGSSteam::RequestLeaderboard(const ScriptMethodParams &params) {
}
int AGSSteam::UploadScore(const ScriptMethodParams &params) {
return 0;
}
void AGSSteam::geti_LeaderboardNames(const ScriptMethodParams &params) {
}
int AGSSteam::geti_LeaderboardScores(const ScriptMethodParams &params) {
return 0;
}
int AGSSteam::get_LeaderboardCount(const ScriptMethodParams &params) {
return 0;
}
void AGSSteam::GetUserName(const ScriptMethodParams &params) {
}
void AGSSteam::GetCurrentGameLanguage(const ScriptMethodParams &params) {
}
int AGSSteam::FindLeaderboard(const ScriptMethodParams &params) {
return 0;
}
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3

View File

@ -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.
*
*/
#ifndef AGS_PLUGINS_AGS_GALAXY_STEAM_AGS_GALAXY_STEAM_H
#define AGS_PLUGINS_AGS_GALAXY_STEAM_AGS_GALAXY_STEAM_H
#include "ags/plugins/dll.h"
#include "common/array.h"
#include "common/rect.h"
#include "common/str.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
class AGS2Client : public DLL {
private:
static int IsAchievementAchieved(const ScriptMethodParams &params);
static int SetAchievementAchieved(const ScriptMethodParams &params);
static int ResetAchievement(const ScriptMethodParams &params);
static int GetIntStat(const ScriptMethodParams &params);
static int GetFloatStat(const ScriptMethodParams &params);
static int GetAverageRateStat(const ScriptMethodParams &params);
static int SetIntStat(const ScriptMethodParams &params);
static int SetFloatStat(const ScriptMethodParams &params);
static int UpdateAverageRateStat(const ScriptMethodParams &params);
static void ResetStatsAndAchievements(const ScriptMethodParams &params);
static int get_Initialized(const ScriptMethodParams &params);
static void get_CurrentLeaderboardName(const ScriptMethodParams &params);
static void RequestLeaderboard(const ScriptMethodParams &params);
static int UploadScore(const ScriptMethodParams &params);
static void geti_LeaderboardNames(const ScriptMethodParams &params);
static int geti_LeaderboardScores(const ScriptMethodParams &params);
static int get_LeaderboardCount(const ScriptMethodParams &params);
static void GetUserName(const ScriptMethodParams &params);
static void GetCurrentGameLanguage(const ScriptMethodParams &params);
static void FindLeaderboard(const ScriptMethodParams &params);
static int Initialize(const ScriptMethodParams &params);
protected:
static void AGS_EngineStartup(IAGSEngine *engine);
public:
AGS2Client();
};
class AGSGalaxy : public AGS2Client {
private:
static const char *AGS_GetPluginName();
static void AGS_EngineStartup(IAGSEngine *engine);
static int IsAchievementAchieved(const ScriptMethodParams &params);
static int SetAchievementAchieved(const ScriptMethodParams &params);
static int ResetAchievement(const ScriptMethodParams &params);
static int GetIntStat(const ScriptMethodParams &params);
static int GetFloatStat(const ScriptMethodParams &params);
static int GetAverageRateStat(const ScriptMethodParams &params);
static int SetIntStat(const ScriptMethodParams &params);
static int SetFloatStat(const ScriptMethodParams &params);
static int UpdateAverageRateStat(const ScriptMethodParams &params);
static void ResetStatsAndAchievements(const ScriptMethodParams &params);
static int get_Initialized(const ScriptMethodParams &params);
static void get_CurrentLeaderboardName(const ScriptMethodParams &params);
static void RequestLeaderboard(const ScriptMethodParams &params);
static int UploadScore(const ScriptMethodParams &params);
static void geti_LeaderboardNames(const ScriptMethodParams &params);
static int geti_LeaderboardScores(const ScriptMethodParams &params);
static int get_LeaderboardCount(const ScriptMethodParams &params);
static void GetUserName(const ScriptMethodParams &params);
static void GetCurrentGameLanguage(const ScriptMethodParams &params);
static int Initialize(const ScriptMethodParams &params);
public:
AGSGalaxy();
};
class AGSSteam : public AGS2Client {
private:
static const char *AGS_GetPluginName();
static void AGS_EngineStartup(IAGSEngine *engine);
static int IsAchievementAchieved(const ScriptMethodParams &params);
static int SetAchievementAchieved(const ScriptMethodParams &params);
static int ResetAchievement(const ScriptMethodParams &params);
static int GetIntStat(const ScriptMethodParams &params);
static int GetFloatStat(const ScriptMethodParams &params);
static int GetAverageRateStat(const ScriptMethodParams &params);
static int SetIntStat(const ScriptMethodParams &params);
static int SetFloatStat(const ScriptMethodParams &params);
static int UpdateAverageRateStat(const ScriptMethodParams &params);
static void ResetStatsAndAchievements(const ScriptMethodParams &params);
static int get_Initialized(const ScriptMethodParams &params);
static void get_CurrentLeaderboardName(const ScriptMethodParams &params);
static void RequestLeaderboard(const ScriptMethodParams &params);
static int UploadScore(const ScriptMethodParams &params);
static void geti_LeaderboardNames(const ScriptMethodParams &params);
static int geti_LeaderboardScores(const ScriptMethodParams &params);
static int get_LeaderboardCount(const ScriptMethodParams &params);
static void GetUserName(const ScriptMethodParams &params);
static void GetCurrentGameLanguage(const ScriptMethodParams &params);
static int FindLeaderboard(const ScriptMethodParams &params);
public:
AGSSteam();
};
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3
#endif

View File

@ -1,43 +0,0 @@
/* 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.
*
*/
#include "ags/plugins/ags_steam/ags_steam.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSteam {
AGSSteam::AGSSteam() {
DLL_METHOD(AGS_GetPluginName);
DLL_METHOD(AGS_EngineStartup);
}
const char *AGSSteam::AGS_GetPluginName() {
return "";
}
void AGSSteam::AGS_EngineStartup(IAGSEngine *engine) {
}
} // namespace AGSSteam
} // namespace Plugins
} // namespace AGS3

View File

@ -1,49 +0,0 @@
/* 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.
*
*/
#ifndef AGS_PLUGINS_AGSSTEAM_AGSSTEAM_H
#define AGS_PLUGINS_AGSSTEAM_AGSSTEAM_H
#include "ags/plugins/dll.h"
#include "common/array.h"
#include "common/rect.h"
#include "common/str.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSteam {
class AGSSteam : public DLL {
private:
static const char *AGS_GetPluginName();
static void AGS_EngineStartup(IAGSEngine *engine);
public:
AGSSteam();
};
} // namespace AGSSteam
} // namespace Plugins
} // namespace AGS3
#endif

View File

@ -73,19 +73,9 @@
#include "ags/shared/util/memory.h"
#include "ags/shared/util/filestream.h"
#include "ags/engine/media/audio/audio_system.h"
#include "ags/engine/util/library.h"
#include "ags/engine/globals.h"
#if defined(BUILTIN_PLUGINS)
#include "ags/shared/../Plugins/AGSflashlight/agsflashlight.h"
#include "ags/shared/../Plugins/agsblend/agsblend.h"
#include "ags/shared/../Plugins/ags_snowrain/ags_snowrain.h"
#include "ags/shared/../Plugins/ags_parallax/ags_parallax.h"
#include "ags/shared/../Plugins/agspalrender/agspalrender.h"
#if AGS_PLATFORM_OS_IOS
#include "ags/shared/../Plugins/agstouch/agstouch.h"
#endif // AGS_PLATFORM_OS_IOS
#endif // BUILTIN_PLUGINS
#include "ags/engine/util/library.h"
#include "ags/engine/util/library_scummvm.h"
namespace AGS3 {
@ -1028,7 +1018,7 @@ Engine::GameInitError pl_register_plugins(const std::vector<Shared::PluginInfo>
strcpy(apl->filename, "ags_snowrain");
}
String expect_filename = apl->library.GetFilenameForLib(apl->filename);
String expect_filename = apl->filename;
if (apl->library.Load(apl->filename)) {
AGS::Shared::Debug::Printf(kDbgMsg_Info, "Plugin '%s' loaded as '%s', resolving imports...", apl->filename, expect_filename.GetCStr());

View File

@ -25,10 +25,10 @@
#include "ags/plugins/ags_blend/ags_blend.h"
#include "ags/plugins/ags_creditz/ags_creditz.h"
#include "ags/plugins/ags_flashlight/ags_flashlight.h"
#include "ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h"
#include "ags/plugins/ags_pal_render/ags_pal_render.h"
#include "ags/plugins/ags_snow_rain/ags_snow_rain.h"
#include "ags/plugins/ags_sprite_font/ags_sprite_font.h"
#include "ags/plugins/ags_steam/ags_steam.h"
#include "ags/ags.h"
#include "ags/detection.h"
#include "common/str.h"
@ -36,59 +36,64 @@
namespace AGS3 {
namespace Plugins {
void *dlopen(const char *filename) {
void *pluginOpen(const char *filename) {
Common::String fname(filename);
// Check for if the game specifies a specific plugin version for this game
int version = 0;
for (const ::AGS::PluginVersion *v = ::AGS::g_vm->getNeededPlugins();
v && v->_plugin; ++v) {
if (Common::String::format("lib%s.so", v->_plugin).equalsIgnoreCase(filename)) {
if (Common::String(v->_plugin).equalsIgnoreCase(filename)) {
version = v->_version;
break;
}
}
if (fname.equalsIgnoreCase("libAGSBlend.so"))
if (fname.equalsIgnoreCase("AGSBlend"))
return new AGSBlend::AGSBlend();
if (fname.equalsIgnoreCase("libagsCreditz.so")) {
if (fname.equalsIgnoreCase("agsCreditz")) {
if (version == 20)
return new AGSCreditz::AGSCreditz20();
else
return new AGSCreditz::AGSCreditz11();
}
if (fname.equalsIgnoreCase("libAGSFlashlight.so"))
if (fname.equalsIgnoreCase("AGSFlashlight"))
return new AGSFlashlight::AGSFlashlight();
if (fname.equalsIgnoreCase("libAGSPalRender.so"))
if (fname.equalsIgnoreCase("AGSPalRender"))
return new AGSPalRender::AGSPalRender();
if (fname.equalsIgnoreCase("libAGSSnowRain.so"))
if (fname.equalsIgnoreCase("AGSSnowRain"))
return new AGSSnowRain::AGSSnowRain();
if (fname.equalsIgnoreCase("libAGSSpriteFont.so"))
if (fname.equalsIgnoreCase("AGSSpriteFont"))
return new AGSSpriteFont::AGSSpriteFont();
if (fname.equalsIgnoreCase("libagsteam.so"))
return new AGSSteam::AGSSteam();
if (fname.equalsIgnoreCase("agsgalaxy") || fname.equalsIgnoreCase("agsgalaxy-unified") ||
fname.equalsIgnoreCase("agsgalaxy-disjoint"))
return new AGSGalaxySteam::AGSGalaxy();
if (fname.equalsIgnoreCase("agsteam") || fname.equalsIgnoreCase("agsteam-unified") ||
fname.equalsIgnoreCase("agsteam-disjoint"))
return new AGSGalaxySteam::AGSSteam();
return nullptr;
}
int dlclose(void *lib) {
int pluginClose(void *lib) {
DLL *dll = static_cast<DLL *>(lib);
delete dll;
return 0;
}
void *dlsym(void *lib, const char *method) {
void *pluginSym(void *lib, const char *method) {
DLL *dll = static_cast<DLL *>(lib);
return (*dll)[method];
}
const char *dlerror() {
const char *pluginError() {
return nullptr;
}

View File

@ -112,13 +112,13 @@ public:
}
};
extern void *dlopen(const char *filename);
extern void *pluginOpen(const char *filename);
extern int dlclose(void *lib);
extern int pluginClose(void *lib);
extern void *dlsym(void *lib, const char *method);
extern void *pluginSym(void *lib, const char *method);
extern const char *dlerror();
extern const char *pluginError();
} // namespace Plugins
} // namespace AGS3

View File

@ -1,44 +0,0 @@
/* 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.
*
*/
#include "ags/plugins/library.h"
#include "ags/plugins/dll.h"
namespace AGS3 {
void *dlopen(const char *filename, bool) {
return Plugins::dlopen(filename);
}
int dlclose(void *lib) {
return Plugins::dlclose(lib);
}
void *dlsym(void *lib, const char *method) {
return Plugins::dlsym(lib, method);
}
const char *dlerror() {
return Plugins::dlerror();
}
} // namespace AGS3

View File

@ -1,40 +0,0 @@
/* 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.
*
*/
#ifndef AGS_ENGINE_PLUGIN_LIBRARY_H
#define AGS_ENGINE_PLUGIN_LIBRARY_H
namespace AGS3 {
#define RTLD_LAZY true
extern void *dlopen(const char *filename, bool);
extern int dlclose(void *lib);
extern void *dlsym(void *lib, const char *method);
extern const char *dlerror();
} // namespace AGS3
#endif