fetch correct sdk module from pluginsdk

This commit is contained in:
rexx 2023-05-08 19:28:16 +01:00
parent b7fafa6b65
commit f310497464
5 changed files with 7 additions and 4 deletions

View File

@ -9,9 +9,11 @@
#include "core/stdafx.h"
#include "pluginsdk.h"
extern "C" __declspec(dllexport) bool PluginInstance_OnLoad(const char* pszSelfModule)
extern "C" __declspec(dllexport) bool PluginInstance_OnLoad(const char* pszSelfModule, const char* pszSDKModule)
{
g_pPluginSDK = new CPluginSDK(pszSelfModule);
g_pPluginSDK->SetSDKModule(CModule(pszSDKModule));
return g_pPluginSDK->InitSDK();
}

View File

@ -21,7 +21,6 @@ CPluginSDK::CPluginSDK(const char* pszSelfModule) : m_FactoryInstance(nullptr),
{
m_SelfModule = CModule(pszSelfModule);
m_GameModule = CModule("r5apex.exe");
m_SDKModule = CModule("gamesdk.dll"); // THIS NEEDS TO BE CHANGED FOR DEDI/CLIENT SDK SUPPORT. AT BEST DO THIS VIA PluginInstance_OnLoad.
}
//---------------------------------------------------------------------------------

View File

@ -11,6 +11,8 @@ public:
~CPluginSDK();
bool InitSDK();
inline void SetSDKModule(const CModule& sdkModule) { m_SDKModule = sdkModule; };
private:
IFactory* m_FactoryInstance;

View File

@ -60,7 +60,7 @@ bool CPluginSystem::LoadPluginInstance(PluginInstance_t& pluginInst)
auto onLoadFn = pluginModule.GetExportedFunction("PluginInstance_OnLoad").RCast<PluginInstance_t::OnLoad>();
Assert(onLoadFn);
if (!onLoadFn(pluginInst.m_svPluginName.c_str()))
if (!onLoadFn(pluginInst.m_svPluginName.c_str(), g_SDKDll.GetModuleName().c_str()))
{
FreeLibrary(loadedPlugin);
return false;

View File

@ -81,7 +81,7 @@ public:
PluginInstance_t(string svPluginName, string svPluginFullPath) : m_svPluginName(svPluginName), m_svPluginFullPath(svPluginFullPath), m_svDescription(std::string()), m_bIsLoaded(false) {};
// Might wanna make a status code system.
typedef bool(*OnLoad)(const char*);
typedef bool(*OnLoad)(const char*, const char*);
typedef void(*OnUnload)();
CModule m_hModule;