mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-26 19:54:14 +01:00
prevented plugin_unload on MM:S
--HG-- branch : sourcemm-1.4.3 extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.3%40592
This commit is contained in:
parent
1a73ba9801
commit
b585c5806a
@ -12,9 +12,23 @@
|
|||||||
#include "CPlugin.h"
|
#include "CPlugin.h"
|
||||||
#include "concommands.h"
|
#include "concommands.h"
|
||||||
|
|
||||||
|
SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||||
|
|
||||||
using namespace SourceMM;
|
using namespace SourceMM;
|
||||||
|
|
||||||
VSPListener g_VspListener;
|
VSPListener g_VspListener;
|
||||||
|
ConCommand *g_plugin_unload = NULL;
|
||||||
|
bool g_bIsTryingToUnload;
|
||||||
|
|
||||||
|
void InterceptPluginUnloads()
|
||||||
|
{
|
||||||
|
g_bIsTryingToUnload = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterceptPluginUnloads_Post()
|
||||||
|
{
|
||||||
|
g_bIsTryingToUnload = false;
|
||||||
|
}
|
||||||
|
|
||||||
VSPListener::VSPListener()
|
VSPListener::VSPListener()
|
||||||
{
|
{
|
||||||
@ -94,8 +108,19 @@ void VSPListener::ServerActivate(edict_t *pEdictList, int edictCount, int client
|
|||||||
|
|
||||||
void VSPListener::Unload()
|
void VSPListener::Unload()
|
||||||
{
|
{
|
||||||
|
if (g_bIsTryingToUnload)
|
||||||
|
{
|
||||||
|
Error("Metamod:Source cannot be unloaded from VSP mode. Use \"meta unload\" to unload specific plugins.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (IsRootLoadMethod())
|
if (IsRootLoadMethod())
|
||||||
{
|
{
|
||||||
|
if (g_plugin_unload != NULL)
|
||||||
|
{
|
||||||
|
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
|
||||||
|
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
||||||
|
g_plugin_unload = NULL;
|
||||||
|
}
|
||||||
g_SMConVarAccessor.UnloadMetamodCommands();
|
g_SMConVarAccessor.UnloadMetamodCommands();
|
||||||
UnloadMetamod(false);
|
UnloadMetamod(false);
|
||||||
}
|
}
|
||||||
@ -131,6 +156,23 @@ bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gam
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConCommandBase *pBase = g_Engine.icvar->GetCommands();
|
||||||
|
while (pBase != NULL)
|
||||||
|
{
|
||||||
|
if (pBase->IsCommand() && strcmp(pBase->GetName(), "plugin_unload") == 0)
|
||||||
|
{
|
||||||
|
g_plugin_unload = (ConCommand *)pBase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pBase = const_cast<ConCommandBase *>(pBase->GetNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_plugin_unload != NULL)
|
||||||
|
{
|
||||||
|
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
|
||||||
|
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Loaded = true;
|
m_Loaded = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user