2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-02-05 10:10:38 +03:00

Small refactoring

This commit is contained in:
asmodai 2017-06-08 03:15:22 +03:00
parent 895dea5eba
commit 5753c397d1
4 changed files with 12 additions and 16 deletions

View File

@ -3,13 +3,15 @@
// Our structure for storing engine references.
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
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;

View File

@ -20,8 +20,6 @@ gamedll_t g_GameDLL;
ALIGN16
meta_globals_t g_metaGlobals;
enginefuncs_t g_plugin_engfuncs;
MPluginList *g_plugins;
MRegCmdList *g_regCmds;
MRegCvarList *g_regCvars;
@ -157,16 +155,15 @@ void metamod_startup()
// 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
// pointer to match the other g_engfuncs.
g_plugin_engfuncs = *g_engine.funcs;
g_engine.pl_funcs = &g_plugin_engfuncs;
g_engine.pl_funcs = *g_engine.funcs;
// substitute our special versions of various commands
g_engine.pl_funcs->pfnAddServerCommand = meta_AddServerCommand;
g_engine.pl_funcs->pfnCVarRegister = meta_CVarRegister;
g_engine.pl_funcs->pfnCvar_RegisterVariable = meta_CVarRegister;
g_engine.pl_funcs->pfnRegUserMsg = meta_RegUserMsg;
g_engine.pl_funcs.pfnAddServerCommand = meta_AddServerCommand;
g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister;
g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister;
g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg;
if (g_engine.pl_funcs->pfnQueryClientCvarValue)
g_engine.pl_funcs->pfnQueryClientCvarValue = meta_QueryClientCvarValue;
if (g_engine.pl_funcs.pfnQueryClientCvarValue)
g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue;
// Before, we loaded plugins before loading the game DLL, so that if no
// plugins caught engine functions, we could pass engine funcs straight

View File

@ -34,9 +34,6 @@ extern gamedll_t g_GameDLL;
extern enginefuncs_t g_engfuncs;
extern globalvars_t* gpGlobals;
// Our modified version of the engine funcs, to give to plugins.
extern enginefuncs_t g_plugin_engfuncs;
// g_config structure.
extern MConfig* g_config;

View File

@ -785,7 +785,7 @@ bool MPlugin::query()
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);
// Call plugin's Meta_Query(), to pass our meta interface version, and get