mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-02-10 21:58:47 +03:00
Small refactoring
This commit is contained in:
parent
895dea5eba
commit
5753c397d1
@ -3,13 +3,15 @@
|
|||||||
// Our structure for storing engine references.
|
// Our structure for storing engine references.
|
||||||
struct engine_t
|
struct engine_t
|
||||||
{
|
{
|
||||||
engine_t() : funcs(nullptr), globals(nullptr), pl_funcs(nullptr)
|
engine_t() : funcs(nullptr), globals(nullptr)
|
||||||
{
|
{
|
||||||
|
memset(&pl_funcs, 0, sizeof pl_funcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
enginefuncs_t* funcs; // engine funcs
|
enginefuncs_t* funcs; // engine funcs
|
||||||
globalvars_t* globals; // engine globals
|
globalvars_t* globals; // engine globals
|
||||||
enginefuncs_t* pl_funcs; // "modified" eng funcs we give to plugins
|
// Our modified version of the engine funcs, to give to plugins.
|
||||||
|
enginefuncs_t pl_funcs; // "modified" eng funcs we give to plugins
|
||||||
};
|
};
|
||||||
|
|
||||||
extern engine_t g_engine;
|
extern engine_t g_engine;
|
||||||
|
@ -20,8 +20,6 @@ gamedll_t g_GameDLL;
|
|||||||
ALIGN16
|
ALIGN16
|
||||||
meta_globals_t g_metaGlobals;
|
meta_globals_t g_metaGlobals;
|
||||||
|
|
||||||
enginefuncs_t g_plugin_engfuncs;
|
|
||||||
|
|
||||||
MPluginList *g_plugins;
|
MPluginList *g_plugins;
|
||||||
MRegCmdList *g_regCmds;
|
MRegCmdList *g_regCmds;
|
||||||
MRegCvarList *g_regCvars;
|
MRegCvarList *g_regCvars;
|
||||||
@ -157,16 +155,15 @@ void metamod_startup()
|
|||||||
// Copy, and store pointer in g_engine struct. Yes, we could just store
|
// Copy, and store pointer in g_engine struct. Yes, we could just store
|
||||||
// the actual engine_t struct in g_engine, but then it wouldn't be a
|
// the actual engine_t struct in g_engine, but then it wouldn't be a
|
||||||
// pointer to match the other g_engfuncs.
|
// pointer to match the other g_engfuncs.
|
||||||
g_plugin_engfuncs = *g_engine.funcs;
|
g_engine.pl_funcs = *g_engine.funcs;
|
||||||
g_engine.pl_funcs = &g_plugin_engfuncs;
|
|
||||||
// substitute our special versions of various commands
|
// substitute our special versions of various commands
|
||||||
g_engine.pl_funcs->pfnAddServerCommand = meta_AddServerCommand;
|
g_engine.pl_funcs.pfnAddServerCommand = meta_AddServerCommand;
|
||||||
g_engine.pl_funcs->pfnCVarRegister = meta_CVarRegister;
|
g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister;
|
||||||
g_engine.pl_funcs->pfnCvar_RegisterVariable = meta_CVarRegister;
|
g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister;
|
||||||
g_engine.pl_funcs->pfnRegUserMsg = meta_RegUserMsg;
|
g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg;
|
||||||
|
|
||||||
if (g_engine.pl_funcs->pfnQueryClientCvarValue)
|
if (g_engine.pl_funcs.pfnQueryClientCvarValue)
|
||||||
g_engine.pl_funcs->pfnQueryClientCvarValue = meta_QueryClientCvarValue;
|
g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue;
|
||||||
|
|
||||||
// Before, we loaded plugins before loading the game DLL, so that if no
|
// Before, we loaded plugins before loading the game DLL, so that if no
|
||||||
// plugins caught engine functions, we could pass engine funcs straight
|
// plugins caught engine functions, we could pass engine funcs straight
|
||||||
|
@ -34,9 +34,6 @@ extern gamedll_t g_GameDLL;
|
|||||||
extern enginefuncs_t g_engfuncs;
|
extern enginefuncs_t g_engfuncs;
|
||||||
extern globalvars_t* gpGlobals;
|
extern globalvars_t* gpGlobals;
|
||||||
|
|
||||||
// Our modified version of the engine funcs, to give to plugins.
|
|
||||||
extern enginefuncs_t g_plugin_engfuncs;
|
|
||||||
|
|
||||||
// g_config structure.
|
// g_config structure.
|
||||||
extern MConfig* g_config;
|
extern MConfig* g_config;
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ bool MPlugin::query()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pfn_give_engfuncs(g_engine.pl_funcs, g_engine.globals);
|
pfn_give_engfuncs(&g_engine.pl_funcs, g_engine.globals);
|
||||||
META_DEBUG(6, "dll: Plugin '%s': Called GiveFnptrsToDll()", m_desc);
|
META_DEBUG(6, "dll: Plugin '%s': Called GiveFnptrsToDll()", m_desc);
|
||||||
|
|
||||||
// Call plugin's Meta_Query(), to pass our meta interface version, and get
|
// Call plugin's Meta_Query(), to pass our meta interface version, and get
|
||||||
|
Loading…
x
Reference in New Issue
Block a user