core-legacy/vsp_bridge.cpp
changeset 683 b507295429f9
parent 666 acab40e6dbd7
child 887 e30d4a37f5e5
     1.1 --- a/core-legacy/vsp_bridge.cpp	Tue Nov 17 04:49:17 2009 -0500
     1.2 +++ b/core-legacy/vsp_bridge.cpp	Sun Nov 22 23:54:55 2009 -0600
     1.3 @@ -1,8 +1,8 @@
     1.4  /**
     1.5 - * vim: set ts=4 :
     1.6 + * vim: set ts=4 sw=4 tw=99 noet :
     1.7   * ======================================================
     1.8   * Metamod:Source
     1.9 - * Copyright (C) 2004-2008 AlliedModders LLC and authors.
    1.10 + * Copyright (C) 2004-2009 AlliedModders LLC and authors.
    1.11   * All rights reserved.
    1.12   * ======================================================
    1.13   *
    1.14 @@ -21,8 +21,6 @@
    1.15   * 2. Altered source versions must be plainly marked as such, and must not be
    1.16   * misrepresented as being the original software.
    1.17   * 3. This notice may not be removed or altered from any source distribution.
    1.18 - *
    1.19 - * Version: $Id$
    1.20   */
    1.21  
    1.22  #include <assert.h>
    1.23 @@ -36,6 +34,7 @@
    1.24  ConCommand *g_plugin_unload = NULL;
    1.25  bool g_bIsTryingToUnload;
    1.26  bool g_bIsBridgedAsVsp;
    1.27 +const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
    1.28  
    1.29  void InterceptPluginUnloads()
    1.30  {
    1.31 @@ -51,13 +50,26 @@
    1.32  {
    1.33  	virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
    1.34  	{
    1.35 -		assert(!g_GameDll.loaded && !g_bIsBridgedAsVsp);
    1.36 +		assert(!g_bIsBridgedAsVsp);
    1.37 +
    1.38 +		if (!g_GameDll.loaded)
    1.39 +		{
    1.40 +			CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
    1.41 +			CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
    1.42 +
    1.43 +			if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
    1.44 +				return false;
    1.45  
    1.46 -		CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
    1.47 -		CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
    1.48 +			extern ConVar metamod_version;
    1.49 +			char buffer[255];
    1.50  
    1.51 -		if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
    1.52 -			return false;
    1.53 +			UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
    1.54 +			metamod_version.SetValue(buffer);
    1.55 +		}
    1.56 +		else
    1.57 +		{
    1.58 +			vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION;
    1.59 +		}
    1.60  
    1.61  		ConCommandBase *pBase = g_Engine.icvar->GetCommands();
    1.62  		while (pBase != NULL)
    1.63 @@ -76,12 +88,6 @@
    1.64  			SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
    1.65  		}
    1.66  
    1.67 -		extern ConVar metamod_version;
    1.68 -		char buffer[255];
    1.69 -
    1.70 -		UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
    1.71 -		metamod_version.SetValue(buffer);
    1.72 -
    1.73  		g_bIsBridgedAsVsp = true;
    1.74  		g_pRealVspCallbacks = info->vsp_callbacks;
    1.75  		g_vsp_version = info->vsp_version;
    1.76 @@ -104,13 +110,16 @@
    1.77  			SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
    1.78  			g_plugin_unload = NULL;
    1.79  		}
    1.80 -		g_SMConVarAccessor.UnloadMetamodCommands();
    1.81 -		UnloadMetamod(false);
    1.82 +		if (!g_GameDll.loaded)
    1.83 +		{
    1.84 +			g_SMConVarAccessor.UnloadMetamodCommands();
    1.85 +			UnloadMetamod(false);
    1.86 +		}
    1.87  	}
    1.88  
    1.89  	virtual const char *GetDescription()
    1.90  	{
    1.91 -		return "Metamod:Source " MMS_FULL_VERSION;
    1.92 +		return vsp_desc;
    1.93  	}
    1.94  };
    1.95