1.1 --- a/core-legacy/vsp_bridge.cpp Mon Nov 24 03:30:52 2008 -0600
1.2 +++ b/core-legacy/vsp_bridge.cpp Mon Nov 24 03:50:12 2008 -0600
1.3 @@ -1,69 +1,69 @@
1.4 -#include <assert.h>
1.5 -#include "sourcemm.h"
1.6 -#include "concommands.h"
1.7 -#include <loader_bridge.h>
1.8 -
1.9 -SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
1.10 -
1.11 -ConCommand *g_plugin_unload = NULL;
1.12 -bool g_bIsTryingToUnload;
1.13 -bool g_bIsBridgedAsVsp;
1.14 -
1.15 -void InterceptPluginUnloads()
1.16 -{
1.17 - g_bIsTryingToUnload = true;
1.18 -}
1.19 -
1.20 -void InterceptPluginUnloads_Post()
1.21 -{
1.22 - g_bIsTryingToUnload = false;
1.23 -}
1.24 -
1.25 -class VspBridge : public IVspBridge
1.26 -{
1.27 - virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
1.28 - {
1.29 - assert(!g_GameDll.loaded && !g_bIsBridgedAsVsp);
1.30 -
1.31 - CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
1.32 - CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
1.33 -
1.34 - if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
1.35 - return false;
1.36 -
1.37 - ConCommandBase *pBase = g_Engine.icvar->GetCommands();
1.38 - while (pBase != NULL)
1.39 - {
1.40 - if (pBase->IsCommand() && strcmp(pBase->GetName(), "plugin_unload") == 0)
1.41 - {
1.42 - g_plugin_unload = (ConCommand *)pBase;
1.43 - break;
1.44 - }
1.45 - pBase = const_cast<ConCommandBase *>(pBase->GetNext());
1.46 - }
1.47 -
1.48 - if (g_plugin_unload != NULL)
1.49 - {
1.50 - SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
1.51 - SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
1.52 - }
1.53 -
1.54 - extern ConVar metamod_version;
1.55 - char buffer[255];
1.56 -
1.57 - UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
1.58 - metamod_version.SetValue(buffer);
1.59 -
1.60 - g_bIsBridgedAsVsp = true;
1.61 - g_pRealVspCallbacks = info->vsp_callbacks;
1.62 -
1.63 - g_PluginMngr.SetVSPAsLoaded();
1.64 -
1.65 - return true;
1.66 - }
1.67 -
1.68 - virtual void Unload()
1.69 - {
1.70 +#include <assert.h>
1.71 +#include "sourcemm.h"
1.72 +#include "concommands.h"
1.73 +#include <loader_bridge.h>
1.74 +
1.75 +SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
1.76 +
1.77 +ConCommand *g_plugin_unload = NULL;
1.78 +bool g_bIsTryingToUnload;
1.79 +bool g_bIsBridgedAsVsp;
1.80 +
1.81 +void InterceptPluginUnloads()
1.82 +{
1.83 + g_bIsTryingToUnload = true;
1.84 +}
1.85 +
1.86 +void InterceptPluginUnloads_Post()
1.87 +{
1.88 + g_bIsTryingToUnload = false;
1.89 +}
1.90 +
1.91 +class VspBridge : public IVspBridge
1.92 +{
1.93 + virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
1.94 + {
1.95 + assert(!g_GameDll.loaded && !g_bIsBridgedAsVsp);
1.96 +
1.97 + CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
1.98 + CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
1.99 +
1.100 + if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
1.101 + return false;
1.102 +
1.103 + ConCommandBase *pBase = g_Engine.icvar->GetCommands();
1.104 + while (pBase != NULL)
1.105 + {
1.106 + if (pBase->IsCommand() && strcmp(pBase->GetName(), "plugin_unload") == 0)
1.107 + {
1.108 + g_plugin_unload = (ConCommand *)pBase;
1.109 + break;
1.110 + }
1.111 + pBase = const_cast<ConCommandBase *>(pBase->GetNext());
1.112 + }
1.113 +
1.114 + if (g_plugin_unload != NULL)
1.115 + {
1.116 + SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
1.117 + SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
1.118 + }
1.119 +
1.120 + extern ConVar metamod_version;
1.121 + char buffer[255];
1.122 +
1.123 + UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
1.124 + metamod_version.SetValue(buffer);
1.125 +
1.126 + g_bIsBridgedAsVsp = true;
1.127 + g_pRealVspCallbacks = info->vsp_callbacks;
1.128 +
1.129 + g_PluginMngr.SetVSPAsLoaded();
1.130 +
1.131 + return true;
1.132 + }
1.133 +
1.134 + virtual void Unload()
1.135 + {
1.136 if (g_bIsTryingToUnload)
1.137 {
1.138 Error("Metamod:Source cannot be unloaded from VSP mode. Use \"meta unload\" to unload specific plugins.\n");
1.139 @@ -74,21 +74,21 @@
1.140 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
1.141 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
1.142 g_plugin_unload = NULL;
1.143 - }
1.144 - g_SMConVarAccessor.UnloadMetamodCommands();
1.145 - UnloadMetamod(false);
1.146 - }
1.147 -
1.148 - virtual const char *GetDescription()
1.149 - {
1.150 - return "Metamod:Source " SVN_FULL_VERSION;
1.151 - }
1.152 -};
1.153 -
1.154 -VspBridge mm14_vsp_bridge;
1.155 -
1.156 -SMM_API IVspBridge *
1.157 -GetVspBridge()
1.158 -{
1.159 - return &mm14_vsp_bridge;
1.160 -}
1.161 + }
1.162 + g_SMConVarAccessor.UnloadMetamodCommands();
1.163 + UnloadMetamod(false);
1.164 + }
1.165 +
1.166 + virtual const char *GetDescription()
1.167 + {
1.168 + return "Metamod:Source " MMS_FULL_VERSION;
1.169 + }
1.170 +};
1.171 +
1.172 +VspBridge mm14_vsp_bridge;
1.173 +
1.174 +SMM_API IVspBridge *
1.175 +GetVspBridge()
1.176 +{
1.177 + return &mm14_vsp_bridge;
1.178 +}