core/metamod.cpp
changeset 683 b507295429f9
parent 639 5b691c4b0849
child 705 a1001281dcb1
     1.1 --- a/core/metamod.cpp	Tue Nov 17 04:49:17 2009 -0500
     1.2 +++ b/core/metamod.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 <stdio.h>
    1.23 @@ -182,17 +180,8 @@
    1.24  bool
    1.25  mm_DetectGameInformation()
    1.26  {
    1.27 -	char mm_path[PATH_SIZE];
    1.28  	char game_path[PATH_SIZE];
    1.29  
    1.30 -	/* Get path to SourceMM DLL */
    1.31 -	if (!GetFileOfAddress((void *)mm_InitializeForLoad, mm_path, sizeof(mm_path)))
    1.32 -	{
    1.33 -		return false;
    1.34 -	}
    1.35 -
    1.36 -	metamod_path.assign(mm_path);
    1.37 -
    1.38  	/* Get value of -game from command line, defaulting to hl2 as engine seems to do */
    1.39  	const char *game_dir = provider->GetCommandLineValue("-game");
    1.40  
    1.41 @@ -220,33 +209,6 @@
    1.42  	IFACE_MACRO(gamedll_info.factory, GameDLL);
    1.43  }
    1.44  
    1.45 -SMM_API void *
    1.46 -CreateInterface(const char *iface, int *ret)
    1.47 -{
    1.48 -	void *ptr = NULL;
    1.49 -
    1.50 -	if (!mm_IsVspBridged() && strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
    1.51 -	{
    1.52 -		if (vsp_callbacks != NULL)
    1.53 -		{
    1.54 -			if (ret != NULL)
    1.55 -				*ret = IFACE_FAILED;
    1.56 -			return NULL;
    1.57 -		}
    1.58 -
    1.59 -		vsp_version = atoi(&iface[22]);
    1.60 -		ptr = provider->GetVSPCallbacks(vsp_version);
    1.61 -
    1.62 -		if (ptr == NULL)
    1.63 -			vsp_version = 0;
    1.64 -	}
    1.65 -
    1.66 -	if (ret)
    1.67 -		*ret = (ptr != NULL) ? IFACE_OK : IFACE_FAILED;
    1.68 -
    1.69 -	return ptr;
    1.70 -}
    1.71 -
    1.72  static int
    1.73  LoadPluginsFromFile(const char *filepath, int &skipped)
    1.74  {
    1.75 @@ -868,7 +830,9 @@
    1.76  void MetamodSource::EnableVSPListener()
    1.77  {
    1.78  	if (is_game_init && !vsp_load_requested && !vsp_loaded)
    1.79 +	{
    1.80  		InitializeVSP();
    1.81 +	}
    1.82  
    1.83  	vsp_load_requested = true;
    1.84  }
    1.85 @@ -1077,6 +1041,16 @@
    1.86  	
    1.87  	vsp_callbacks = callbacks;
    1.88  	ITER_EVENT(OnVSPListening, (callbacks));
    1.89 +
    1.90 +	if (is_gamedll_loaded)
    1.91 +	{
    1.92 +		/*
    1.93 +		 * MM:S is loaded as a game DLL so we need to set these for mm_IsVspBridged() and
    1.94 +		 * mm_IsVspLoadComplete()
    1.95 +		 */
    1.96 +		g_bIsVspBridged = true;
    1.97 +		were_plugins_loaded = true;
    1.98 +	}
    1.99  }
   1.100  
   1.101  IServerPluginCallbacks *MetamodSource::GetVSPInfo(int *pVersion)
   1.102 @@ -1118,6 +1092,11 @@
   1.103  	is_gamedll_loaded = loaded;
   1.104  }
   1.105  
   1.106 +void MetamodSource::SetVSPListener(const char *path)
   1.107 +{
   1.108 +	metamod_path.assign(path);
   1.109 +}
   1.110 +
   1.111  static bool
   1.112  ProcessVDF(const char *path, bool &skipped)
   1.113  {