diff -r f125dd3ed7d0 -r b507295429f9 core/vsp_bridge.cpp --- a/core/vsp_bridge.cpp Tue Nov 17 04:49:17 2009 -0500 +++ b/core/vsp_bridge.cpp Sun Nov 22 23:54:55 2009 -0600 @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ====================================================== * Metamod:Source - * Copyright (C) 2004-2008 AlliedModders LLC and authors. + * Copyright (C) 2004-2009 AlliedModders LLC and authors. * All rights reserved. * ====================================================== * @@ -21,8 +21,6 @@ * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id$ */ #include "metamod.h" @@ -42,6 +40,7 @@ ConCommand *g_plugin_unload = NULL; bool g_bIsTryingToUnload; +const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION; #if SOURCE_ENGINE >= SE_ORANGEBOX void InterceptPluginUnloads(const CCommand &args) @@ -66,59 +65,65 @@ public: virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength) { - assert(!g_Metamod.IsLoadedAsGameDLL()); + if (!g_Metamod.IsLoadedAsGameDLL()) + { + CGlobalVars *pGlobals; + IPlayerInfoManager *playerInfoManager; - CGlobalVars *pGlobals; - IPlayerInfoManager *playerInfoManager; + playerInfoManager = (IPlayerInfoManager *)info->gsFactory("PlayerInfoManager002", NULL); + if (playerInfoManager == NULL) + { + UTIL_Format(error, maxlength, "Metamod:Source requires gameinfo.txt modification to load on this game"); + return false; + } - playerInfoManager = (IPlayerInfoManager *)info->gsFactory("PlayerInfoManager002", NULL); - if (playerInfoManager == NULL) - { - UTIL_Format(error, maxlength, "Metamod:Source requires gameinfo.txt modification to load on this game"); - return false; - } + pGlobals = playerInfoManager->GetGlobalVars(); + + char gamedll_iface[] = "ServerGameDLL000"; + for (unsigned int i = 3; i <= 50; i++) + { + gamedll_iface[15] = '0' + i; + if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface, NULL)) != NULL) + { + g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, i, false); + break; + } + } - pGlobals = playerInfoManager->GetGlobalVars(); + if (server == NULL) + { + UTIL_Format(error, maxlength, "Metamod:Source could not load (GameDLL version not compatible)."); + return false; + } + + char gameclients_iface[] = "ServerGameClients000"; + for (unsigned int i = 3; i <= 4; i++) + { + gameclients_iface[19] = '0' + i; + if ((gameclients = (IServerGameClients *)info->gsFactory(gameclients_iface, NULL)) == NULL) + break; + } - char gamedll_iface[] = "ServerGameDLL000"; - for (unsigned int i = 3; i <= 50; i++) + if (!mm_DetectGameInformation()) + { + UTIL_Format(error, maxlength, "Metamod:Source failed to detect game paths; cannot load."); + return false; + } + + mm_InitializeForLoad(); + mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory, + (CreateInterfaceFn)info->engineFactory, + (CreateInterfaceFn)info->engineFactory, + pGlobals); + g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version); + mm_StartupMetamod(true); + } + else { - gamedll_iface[15] = '0' + i; - if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface, NULL)) != NULL) - { - g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, i, false); - break; - } + vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION; + g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version); } - if (server == NULL) - { - UTIL_Format(error, maxlength, "Metamod:Source could not load (GameDLL version not compatible)."); - return false; - } - - char gameclients_iface[] = "ServerGameClients000"; - for (unsigned int i = 3; i <= 4; i++) - { - gameclients_iface[19] = '0' + i; - if ((gameclients = (IServerGameClients *)info->gsFactory(gameclients_iface, NULL)) == NULL) - break; - } - - if (!mm_DetectGameInformation()) - { - UTIL_Format(error, maxlength, "Metamod:Source failed to detect game paths; cannot load."); - return false; - } - - mm_InitializeForLoad(); - mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory, - (CreateInterfaceFn)info->engineFactory, - (CreateInterfaceFn)info->engineFactory, - pGlobals); - g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version); - mm_StartupMetamod(true); - #if SOURCE_ENGINE >= SE_ORANGEBOX g_plugin_unload = icvar->FindCommand("plugin_unload"); #else @@ -156,12 +161,15 @@ SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true); g_plugin_unload = NULL; } - mm_UnloadMetamod(); + if (!g_Metamod.IsLoadedAsGameDLL()) + { + mm_UnloadMetamod(); + } } virtual const char *GetDescription() { - return "Metamod:Source " MMS_FULL_VERSION; + return vsp_desc; } };