[server] Update CPlugins constructor

This commit is contained in:
RD42 2024-04-12 22:09:26 +08:00
parent 5d5702b8c0
commit c5845d46da
4 changed files with 82 additions and 1 deletions

View File

@ -73,6 +73,8 @@ public:
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
RakServerInterface * GetRakServer() { return m_pRak; };
CGameMode * GetGameMode() { return m_pGameMode; };
CFilterScripts * GetFilterScripts() { return m_pFilterScripts; };
void LoadAllFilterscripts();

View File

@ -2,6 +2,8 @@
#ifndef _PLUGINCOMMON_H_INCLUDED
#define _PLUGINCOMMON_H_INCLUDED
//----------------------------------------------------------
enum PLUGIN_DATA_TYPE
{
// For some debugging
@ -9,8 +11,12 @@ enum PLUGIN_DATA_TYPE
// AMX
PLUGIN_DATA_AMX_EXPORTS = 0x10, // void* AmxFunctionTable[] (see PLUGIN_AMX_EXPORT)
PLUGIN_DATA_CALLPUBLIC_FS = 0x11, // int (*AmxCallPublicFilterScript)(char *szFunctionName)
PLUGIN_DATA_CALLPUBLIC_GM = 0x12, // int (*AmxCallPublicGameMode)(char *szFunctionName)
};
//----------------------------------------------------------
enum PLUGIN_AMX_EXPORT
{
PLUGIN_AMX_EXPORT_Align16 = 0,

View File

@ -5,4 +5,13 @@
#define MAX_PLUGIN_DATA 256
#define MAX_PLUGIN_AMX_EXPORT 44
enum PLUGIN_DATA_TYPE_INTERNAL
{
PLUGIN_DATA_NETGAME = 0xE1, // CNetGame* GetNetGame();
PLUGIN_DATA_RAKSERVER = 0xE2, // RakServerInterface* PluginGetRakServer()
PLUGIN_DATA_LOADFSCRIPT = 0xE3, // bool LoadFilterscriptFromMemory(char* pFileName, char* pFileData)
PLUGIN_DATA_UNLOADFSCRIPT = 0xE5, // bool UnloadFilterScript(char* pFileName)
PLUGIN_DATA_CONSOLE = 0xE4, // CConsole* GetConsole();
};
#endif

View File

@ -1,6 +1,61 @@
#include "main.h"
//---------------------------------------
// Some Helpers
extern "C" RakServerInterface* PluginGetRakServer()
{
if (pNetGame != NULL)
return pNetGame->GetRakServer();
else
return NULL;
}
extern "C" CNetGame* PluginGetNetGame()
{
return pNetGame;
}
extern "C" CConsole* PluginGetConsole()
{
return pConsole;
}
extern "C" bool PluginUnloadFilterScript(char* pFileName)
{
if (pNetGame != NULL)
return pNetGame->GetFilterScripts()->UnloadOneFilterScript(pFileName);
else
return false;
}
extern "C" bool PluginLoadFilterScriptFromMemory(char* pFileName, char* pFileData)
{
if (pNetGame != NULL)
return pNetGame->GetFilterScripts()->LoadFilterScriptFromMemory(pFileName, pFileData);
else
return false;
}
extern "C" int PluginCallPublicFS(char *szFunctionName)
{
if (pNetGame != NULL)
return pNetGame->GetFilterScripts()->CallPublic(szFunctionName);
else
return 0;
}
extern "C" int PluginCallPublicGM(char *szFunctionName)
{
if (pNetGame != NULL && pNetGame->GetGameMode())
return pNetGame->GetGameMode()->CallPublic(szFunctionName);
else
return 0;
}
//---------------------------------------
CPlugins::CPlugins()
{
// Set up the table of AMX functions to be exported
@ -57,10 +112,19 @@ CPlugins::CPlugins()
m_PluginData[PLUGIN_DATA_LOGPRINTF] = (void*)&logprintf;
m_PluginData[PLUGIN_DATA_AMX_EXPORTS] = m_AMXExports;
m_PluginData[PLUGIN_DATA_CALLPUBLIC_FS] = (void*)&PluginCallPublicFS;
m_PluginData[PLUGIN_DATA_CALLPUBLIC_GM] = (void*)&PluginCallPublicGM;
// TODO: CPlugins::CPlugins W: 0046A1D0 L: constructor
// Internals
m_PluginData[PLUGIN_DATA_NETGAME] = (void*)&PluginGetNetGame;
m_PluginData[PLUGIN_DATA_CONSOLE] = (void*)&PluginGetConsole;
m_PluginData[PLUGIN_DATA_RAKSERVER] = (void*)&PluginGetRakServer;
m_PluginData[PLUGIN_DATA_LOADFSCRIPT] = (void*)&PluginLoadFilterScriptFromMemory;
m_PluginData[PLUGIN_DATA_UNLOADFSCRIPT] = (void*)&PluginUnloadFilterScript;
}
//---------------------------------------
CPlugins::~CPlugins()
{
// TODO: CPlugins::~CPlugins W: 00469DB0 L: 080D20E0