Bumped all versions.
3 * ======================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
30 #include "concommands.h"
31 #include <loader_bridge.h>
33 SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
35 ConCommand *g_plugin_unload = NULL;
36 bool g_bIsTryingToUnload;
37 bool g_bIsBridgedAsVsp;
39 void InterceptPluginUnloads()
41 g_bIsTryingToUnload = true;
44 void InterceptPluginUnloads_Post()
46 g_bIsTryingToUnload = false;
49 class VspBridge : public IVspBridge
51 virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
53 assert(!g_GameDll.loaded && !g_bIsBridgedAsVsp);
55 CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
56 CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
58 if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
61 ConCommandBase *pBase = g_Engine.icvar->GetCommands();
64 if (pBase->IsCommand() && strcmp(pBase->GetName(), "plugin_unload") == 0)
66 g_plugin_unload = (ConCommand *)pBase;
69 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
72 if (g_plugin_unload != NULL)
74 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
75 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
78 extern ConVar metamod_version;
81 UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
82 metamod_version.SetValue(buffer);
84 g_bIsBridgedAsVsp = true;
85 g_pRealVspCallbacks = info->vsp_callbacks;
87 g_PluginMngr.SetVSPAsLoaded();
94 if (g_bIsTryingToUnload)
96 Error("Metamod:Source cannot be unloaded from VSP mode. Use \"meta unload\" to unload specific plugins.\n");
99 if (g_plugin_unload != NULL)
101 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
102 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
103 g_plugin_unload = NULL;
105 g_SMConVarAccessor.UnloadMetamodCommands();
106 UnloadMetamod(false);
109 virtual const char *GetDescription()
111 return "Metamod:Source " MMS_FULL_VERSION;
115 VspBridge mm14_vsp_bridge;
120 return &mm14_vsp_bridge;