Virtualize MMS functions in the core/logic bridge.
This commit is contained in:
parent
5c5d43137d
commit
9e4d396d5e
@ -52,7 +52,7 @@ using namespace SourceHook;
|
|||||||
* Add 1 to the RHS of this expression to bump the intercom file
|
* Add 1 to the RHS of this expression to bump the intercom file
|
||||||
* This is to prevent mismatching core/logic binaries
|
* This is to prevent mismatching core/logic binaries
|
||||||
*/
|
*/
|
||||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 44)
|
#define SM_LOGIC_MAGIC (0x0F47C0DE - 45)
|
||||||
|
|
||||||
#if defined SM_LOGIC
|
#if defined SM_LOGIC
|
||||||
class IVEngineServer
|
class IVEngineServer
|
||||||
@ -317,9 +317,11 @@ public:
|
|||||||
virtual void ConPrint(const char *message) = 0;
|
virtual void ConPrint(const char *message) = 0;
|
||||||
virtual void ConsolePrintVa(const char *fmt, va_list ap) = 0;
|
virtual void ConsolePrintVa(const char *fmt, va_list ap) = 0;
|
||||||
|
|
||||||
|
// Metamod:Source functions.
|
||||||
|
virtual int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) = 0;
|
||||||
|
virtual void UnloadMMSPlugin(int id) = 0;
|
||||||
|
|
||||||
const char * (*GetCoreConfigValue)(const char*);
|
const char * (*GetCoreConfigValue)(const char*);
|
||||||
int (*LoadMMSPlugin)(const char *file, bool *ok, char *error, size_t maxlength);
|
|
||||||
void (*UnloadMMSPlugin)(int id);
|
|
||||||
void (*DoGlobalPluginLoads)();
|
void (*DoGlobalPluginLoads)();
|
||||||
bool (*AreConfigsExecuted)();
|
bool (*AreConfigsExecuted)();
|
||||||
void (*ExecuteConfigs)(IPluginContext *ctx);
|
void (*ExecuteConfigs)(IPluginContext *ctx);
|
||||||
|
@ -338,42 +338,6 @@ static bool look_for_cmd_admin_flags(const char *cmd, FlagBits *pFlags)
|
|||||||
return g_ConCmds.LookForCommandAdminFlags(cmd, 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()
|
void do_global_plugin_loads()
|
||||||
{
|
{
|
||||||
g_SourceMod.DoGlobalPluginLoads();
|
g_SourceMod.DoGlobalPluginLoads();
|
||||||
@ -474,8 +438,6 @@ public:
|
|||||||
this->spe1 = &g_pSourcePawn;
|
this->spe1 = &g_pSourcePawn;
|
||||||
this->spe2 = &g_pSourcePawn2;
|
this->spe2 = &g_pSourcePawn2;
|
||||||
this->GetCoreConfigValue = get_core_config_value;
|
this->GetCoreConfigValue = get_core_config_value;
|
||||||
this->LoadMMSPlugin = load_mms_plugin;
|
|
||||||
this->UnloadMMSPlugin = unload_mms_plugin;
|
|
||||||
this->DoGlobalPluginLoads = do_global_plugin_loads;
|
this->DoGlobalPluginLoads = do_global_plugin_loads;
|
||||||
this->AreConfigsExecuted = SM_AreConfigsExecuted;
|
this->AreConfigsExecuted = SM_AreConfigsExecuted;
|
||||||
this->ExecuteConfigs = SM_ExecuteForPlugin;
|
this->ExecuteConfigs = SM_ExecuteForPlugin;
|
||||||
@ -507,6 +469,8 @@ public:
|
|||||||
void LogToGame(const char *message) override;
|
void LogToGame(const char *message) override;
|
||||||
void ConPrint(const char *message) override;
|
void ConPrint(const char *message) override;
|
||||||
void ConsolePrintVa(const char *fmt, va_list ap) 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;
|
} sCoreProviderImpl;
|
||||||
|
|
||||||
ConVar *CoreProviderImpl::FindConVar(const char *name)
|
ConVar *CoreProviderImpl::FindConVar(const char *name)
|
||||||
@ -664,6 +628,42 @@ bool CoreProviderImpl::DescribePlayer(int index, const char **namep, const char
|
|||||||
return true;
|
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()
|
void InitLogicBridge()
|
||||||
{
|
{
|
||||||
serverGlobals.universalTime = g_pUniversalTime;
|
serverGlobals.universalTime = g_pUniversalTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user