Virtualize MMS functions in the core/logic bridge.

This commit is contained in:
David Anderson
2015-08-30 23:29:46 -07:00
parent 5c5d43137d
commit 9e4d396d5e
2 changed files with 43 additions and 41 deletions
+38 -38
View File
@@ -338,42 +338,6 @@ static bool look_for_cmd_admin_flags(const char *cmd, FlagBits *pFlags)
return g_ConCmds.LookForCommandAdminFlags(cmd, pFlags);
}
static int load_mms_plugin(const char *file, bool *ok, char *error, size_t maxlength)
{
bool ignore_already;
PluginId id = g_pMMPlugins->Load(file, g_PLID, ignore_already, error, maxlength);
Pl_Status status;
#ifndef METAMOD_PLAPI_VERSION
const char *filep;
PluginId source;
#endif
if (!id || (
#ifndef METAMOD_PLAPI_VERSION
g_pMMPlugins->Query(id, filep, status, source)
#else
g_pMMPlugins->Query(id, NULL, &status, NULL)
#endif
&& status < Pl_Paused))
{
*ok = false;
}
else
{
*ok = true;
}
return id;
}
static void unload_mms_plugin(int id)
{
char ignore[255];
g_pMMPlugins->Unload(id, true, ignore, sizeof(ignore));
}
void do_global_plugin_loads()
{
g_SourceMod.DoGlobalPluginLoads();
@@ -474,8 +438,6 @@ public:
this->spe1 = &g_pSourcePawn;
this->spe2 = &g_pSourcePawn2;
this->GetCoreConfigValue = get_core_config_value;
this->LoadMMSPlugin = load_mms_plugin;
this->UnloadMMSPlugin = unload_mms_plugin;
this->DoGlobalPluginLoads = do_global_plugin_loads;
this->AreConfigsExecuted = SM_AreConfigsExecuted;
this->ExecuteConfigs = SM_ExecuteForPlugin;
@@ -507,6 +469,8 @@ public:
void LogToGame(const char *message) override;
void ConPrint(const char *message) override;
void ConsolePrintVa(const char *fmt, va_list ap) override;
int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) override;
void UnloadMMSPlugin(int id) override;
} sCoreProviderImpl;
ConVar *CoreProviderImpl::FindConVar(const char *name)
@@ -664,6 +628,42 @@ bool CoreProviderImpl::DescribePlayer(int index, const char **namep, const char
return true;
}
int CoreProviderImpl::LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength)
{
bool ignore_already;
PluginId id = g_pMMPlugins->Load(file, g_PLID, ignore_already, error, maxlength);
Pl_Status status;
#ifndef METAMOD_PLAPI_VERSION
const char *filep;
PluginId source;
#endif
if (!id || (
#ifndef METAMOD_PLAPI_VERSION
g_pMMPlugins->Query(id, filep, status, source)
#else
g_pMMPlugins->Query(id, NULL, &status, NULL)
#endif
&& status < Pl_Paused))
{
*ok = false;
}
else
{
*ok = true;
}
return id;
}
void CoreProviderImpl::UnloadMMSPlugin(int id)
{
char ignore[255];
g_pMMPlugins->Unload(id, true, ignore, sizeof(ignore));
}
void InitLogicBridge()
{
serverGlobals.universalTime = g_pUniversalTime;