2023-10-29 00:00:36 +08:00
|
|
|
|
|
|
|
#ifndef _PLUGINS_H_INCLUDED
|
|
|
|
#define _PLUGINS_H_INCLUDED
|
|
|
|
|
2023-11-23 23:34:47 +08:00
|
|
|
#include "plugincommon.h"
|
|
|
|
#include "plugininternal.h"
|
|
|
|
|
2024-04-18 22:41:01 +08:00
|
|
|
#ifdef LINUX
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
#define PLUGIN_LOAD(p) dlopen(p, RTLD_LAZY)
|
|
|
|
#define PLUGIN_UNLOAD dlclose
|
|
|
|
#define PLUGIN_GETFUNCTION dlsym
|
|
|
|
#else
|
|
|
|
#define PLUGIN_LOAD LoadLibrary
|
|
|
|
#define PLUGIN_UNLOAD FreeLibrary
|
|
|
|
#define PLUGIN_GETFUNCTION GetProcAddress
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef bool (PLUGIN_CALL *ServerPluginLoad_t)(void **data);
|
|
|
|
typedef void (PLUGIN_CALL *ServerPluginUnload_t)();
|
|
|
|
typedef unsigned int (PLUGIN_CALL *ServerPluginSupports_t)();
|
|
|
|
typedef void (PLUGIN_CALL *ServerPluginProcessTick_t)();
|
|
|
|
|
|
|
|
typedef int (PLUGIN_CALL *ServerPluginAmxLoad_t)(AMX *amx);
|
|
|
|
typedef int (PLUGIN_CALL *ServerPluginAmxUnload_t)(AMX *amx);
|
|
|
|
|
|
|
|
struct ServerPlugin_s
|
|
|
|
{
|
|
|
|
#ifdef LINUX
|
|
|
|
void *hModule;
|
|
|
|
#else
|
|
|
|
HMODULE hModule;
|
|
|
|
#endif
|
|
|
|
SUPPORTS_FLAGS dwSupportFlags;
|
|
|
|
|
|
|
|
// Core Plugin Interface
|
|
|
|
ServerPluginLoad_t Load;
|
|
|
|
ServerPluginUnload_t Unload;
|
|
|
|
ServerPluginSupports_t Supports;
|
|
|
|
ServerPluginProcessTick_t ProcessTick;
|
|
|
|
|
|
|
|
// AMX Plugin Interface
|
|
|
|
ServerPluginAmxLoad_t AmxLoad;
|
|
|
|
ServerPluginAmxUnload_t AmxUnload;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ServerPlugin_s*> ServerPluginVector;
|
|
|
|
|
|
|
|
//---------------------------------------
|
|
|
|
|
|
|
|
class CPlugins
|
2023-10-29 00:00:36 +08:00
|
|
|
{
|
|
|
|
private:
|
2023-11-23 23:34:47 +08:00
|
|
|
|
|
|
|
void* m_PluginData[MAX_PLUGIN_DATA];
|
|
|
|
void* m_AMXExports[MAX_PLUGIN_AMX_EXPORT];
|
|
|
|
|
2024-04-18 22:41:01 +08:00
|
|
|
ServerPluginVector m_Plugins;
|
|
|
|
|
|
|
|
BOOL LoadSinglePlugin(char *szPluginPath);
|
|
|
|
|
2023-10-29 00:00:36 +08:00
|
|
|
public:
|
|
|
|
CPlugins();
|
|
|
|
~CPlugins();
|
|
|
|
|
|
|
|
void LoadPlugins(char *szSearchPath);
|
2024-04-18 22:41:01 +08:00
|
|
|
void LoadPluginsSearch(char *szSearchPath);
|
|
|
|
DWORD GetPluginCount();
|
|
|
|
ServerPlugin_s* GetPlugin(DWORD index);
|
|
|
|
|
|
|
|
void DoProcessTick();
|
|
|
|
|
|
|
|
void DoAmxLoad(AMX *amx);
|
|
|
|
void DoAmxUnload(AMX *amx);
|
2023-10-29 00:00:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|