Initial commit of vsp bridge for new core. Not tested, barely compiles.
authorDavid Anderson <dvander@alliedmods.net>
Sat Nov 15 23:46:27 2008 -0600 (2008-11-15)
changeset 5524b73ffd6e176
parent 551 747f2a3e0e11
child 553 8fc4ad22c73d
Initial commit of vsp bridge for new core. Not tested, barely compiles.
core-legacy/svn_version.h
core/ISmmAPI.h
core/Makefile
core/metamod.cpp
core/metamod.h
core/metamod_console.cpp
core/metamod_provider.h
core/provider/provider_ep2.cpp
core/provider/provider_ep2.h
core/provider/vsp_listener.cpp
core/provider/vsp_listener.h
core/svn_version.h
     1.1 --- a/core-legacy/svn_version.h	Sat Nov 15 21:54:46 2008 -0600
     1.2 +++ b/core-legacy/svn_version.h	Sat Nov 15 23:46:27 2008 -0600
     1.3 @@ -3,11 +3,11 @@
     1.4  #ifndef _INCLUDE_SVN_VERSION_H_
     1.5  #define _INCLUDE_SVN_VERSION_H_
     1.6  
     1.7 -#define SVN_PRODUCT_VERSION		"1.4.4"
     1.8 +#define SVN_PRODUCT_VERSION		"1.7.0"
     1.9  
    1.10  #define SVN_REVISION			705
    1.11  #define SVN_REVISION_STRING		"705"
    1.12 -#define SVN_FILE_VERSION		1,4,4,705
    1.13 -#define SVN_FILE_VERSION_STRING	"1.4.4.705"
    1.14 +#define SVN_FILE_VERSION		1,7,0,705
    1.15 +#define SVN_FILE_VERSION_STRING	"1.7.0.705"
    1.16  
    1.17  #endif //_INCLUDE_SVN_VERSION_H_
     2.1 --- a/core/ISmmAPI.h	Sat Nov 15 21:54:46 2008 -0600
     2.2 +++ b/core/ISmmAPI.h	Sat Nov 15 23:46:27 2008 -0600
     2.3 @@ -366,10 +366,10 @@
     2.4  		 * @return				Number of bytes actually written, not including 
     2.5  		 * 						the null terminator.
     2.6  		 */
     2.7 -	virtual size_t Format(char *buffer, 
     2.8 -						  size_t maxlength,
     2.9 -						  const char *format,
    2.10 -						  ...) =0;
    2.11 +		virtual size_t Format(char *buffer, 
    2.12 +						  	  size_t maxlength,
    2.13 +						  	  const char *format,
    2.14 +						  	  ...) =0;
    2.15  
    2.16  		/**
    2.17  		 * @brief Formats a string.  This is a platform safe wrapper around 
     3.1 --- a/core/Makefile	Sat Nov 15 21:54:46 2008 -0600
     3.2 +++ b/core/Makefile	Sat Nov 15 23:46:27 2008 -0600
     3.3 @@ -18,7 +18,8 @@
     3.4  		  sourcehook/sourcehook_hookmangen.cpp \
     3.5  		  provider/console.cpp 		\
     3.6  		  provider/provider_ep2.cpp \
     3.7 -		  provider/vsp_listener.cpp
     3.8 +		  provider/vsp_listener.cpp	\
     3.9 +		  vsp_bridge.cpp
    3.10  
    3.11  ##############################################
    3.12  ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    3.13 @@ -54,7 +55,7 @@
    3.14  
    3.15  	
    3.16  INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
    3.17 -	-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -Isourcehook \
    3.18 +	-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -Isourcehook -I../loader
    3.19  
    3.20  CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
    3.21  	-Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca \
     4.1 --- a/core/metamod.cpp	Sat Nov 15 21:54:46 2008 -0600
     4.2 +++ b/core/metamod.cpp	Sat Nov 15 23:46:27 2008 -0600
     4.3 @@ -50,14 +50,40 @@
     4.4  SH_DECL_MANUALHOOK0_void(SGD_LevelShutdown, 0, 0, 0);
     4.5  SH_DECL_MANUALHOOK0_void(SGD_DLLShutdown, 0, 0, 0);
     4.6  
     4.7 -bool Handler_DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals);
     4.8 -bool Handler_DLLInit_Post(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals);
     4.9 -void Handler_DLLShutdown();
    4.10 -void Handler_LevelShutdown();
    4.11 -bool Handler_LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    4.12 -bool Handler_GameInit();
    4.13 -void InitializeVSP();
    4.14 -void LookForVDFs(const char *dir);
    4.15 +static bool
    4.16 +Handler_DLLInit(CreateInterfaceFn engineFactory,
    4.17 +				CreateInterfaceFn physicsFactory,
    4.18 +				CreateInterfaceFn filesystemFactory,
    4.19 +				CGlobalVars *pGlobals);
    4.20 +
    4.21 +static bool
    4.22 +Handler_DLLInit_Post(CreateInterfaceFn engineFactory,
    4.23 +					 CreateInterfaceFn physicsFactory,
    4.24 +					 CreateInterfaceFn filesystemFactory,
    4.25 +					 CGlobalVars *pGlobals);
    4.26 +
    4.27 +static void
    4.28 +Handler_DLLShutdown();
    4.29 +
    4.30 +static void
    4.31 +Handler_LevelShutdown();
    4.32 +
    4.33 +static bool
    4.34 +Handler_LevelInit(char const *pMapName,
    4.35 +				  char const *pMapEntities,
    4.36 +				  char const *pOldLevel,
    4.37 +				  char const *pLandmarkName,
    4.38 +				  bool loadGame,
    4.39 +				  bool background);
    4.40 +
    4.41 +static bool
    4.42 +Handler_GameInit();
    4.43 +
    4.44 +static void
    4.45 +InitializeVSP();
    4.46 +
    4.47 +static void
    4.48 +LookForVDFs(const char *dir);
    4.49  
    4.50  struct game_dll_t
    4.51  {
    4.52 @@ -65,41 +91,42 @@
    4.53  	CreateInterfaceFn factory;
    4.54  };
    4.55  
    4.56 -String mod_path;
    4.57 -String metamod_path;
    4.58 -String full_bin_path;
    4.59 -bool parsed_game_info = false;
    4.60 -int vsp_version = 0;
    4.61 -int gamedll_version = 0;
    4.62 -int engine_build = SOURCE_ENGINE_UNKNOWN;
    4.63 -List<game_dll_t *> gamedll_list;
    4.64 -bool is_gamedll_loaded = false;
    4.65 -bool in_first_level = true;
    4.66 -bool is_game_init = false;
    4.67 -bool vsp_load_attempted = false;
    4.68 -bool vsp_load_requested = false;
    4.69 -bool vsp_loaded = false;
    4.70 -game_dll_t gamedll_info;
    4.71 -ConVar *metamod_version = NULL;
    4.72 -ConVar *mm_pluginsfile = NULL;
    4.73 -ConVar *mm_basedir = NULL;
    4.74 -IServerGameDLL *server = NULL;
    4.75 -CreateInterfaceFn engine_factory = NULL;
    4.76 -CreateInterfaceFn physics_factory = NULL;
    4.77 -CreateInterfaceFn filesystem_factory = NULL;
    4.78 -CGlobalVars *gpGlobals = NULL;
    4.79 -CSourceHookImpl g_SourceHook;
    4.80 -CHookManagerAutoGen g_SH_HookManagerAutoGen(&g_SourceHook);
    4.81 -ISourceHook *g_SHPtr = &g_SourceHook;
    4.82 -PluginId g_PLID = Pl_Console;
    4.83 -META_RES last_meta_res;
    4.84 -IServerPluginCallbacks *vsp_callbacks = NULL;
    4.85 -bool were_plugins_loaded = false;
    4.86 +static String mod_path;
    4.87 +static String metamod_path;
    4.88 +static String full_bin_path;
    4.89 +static bool parsed_game_info = false;
    4.90 +static int vsp_version = 0;
    4.91 +static int gamedll_version = 0;
    4.92 +static int engine_build = SOURCE_ENGINE_UNKNOWN;
    4.93 +static List<game_dll_t *> gamedll_list;
    4.94 +static bool is_gamedll_loaded = false;
    4.95 +static bool in_first_level = true;
    4.96 +static bool is_game_init = false;
    4.97 +static bool vsp_load_requested = false;
    4.98 +static bool vsp_loaded = false;
    4.99 +static game_dll_t gamedll_info;
   4.100 +static ConVar *metamod_version = NULL;
   4.101 +static ConVar *mm_pluginsfile = NULL;
   4.102 +static ConVar *mm_basedir = NULL;
   4.103 +static IServerGameDLL *server = NULL;
   4.104 +static CreateInterfaceFn engine_factory = NULL;
   4.105 +static CreateInterfaceFn physics_factory = NULL;
   4.106 +static CreateInterfaceFn filesystem_factory = NULL;
   4.107 +static CGlobalVars *gpGlobals = NULL;
   4.108 +static CHookManagerAutoGen g_SH_HookManagerAutoGen(&g_SourceHook);
   4.109 +static META_RES last_meta_res;
   4.110 +static IServerPluginCallbacks *vsp_callbacks = NULL;
   4.111 +static bool were_plugins_loaded = false;
   4.112 +static bool g_bIsVspBridged = false;
   4.113  
   4.114  MetamodSource g_Metamod;
   4.115 +PluginId g_PLID = Pl_Console;
   4.116 +CSourceHookImpl g_SourceHook;
   4.117 +ISourceHook *g_SHPtr = &g_SourceHook;
   4.118  SourceMM::ISmmAPI *g_pMetamod = &g_Metamod;
   4.119  
   4.120 -void ClearGamedllList();
   4.121 +static void
   4.122 +ClearGamedllList();
   4.123  
   4.124  /* Helper Macro */
   4.125  #define	IFACE_MACRO(orig,nam) \
   4.126 @@ -133,8 +160,15 @@
   4.127  		} \
   4.128  	}
   4.129  
   4.130 +void
   4.131 +mm_SetVspInfo(IServerPluginCallbacks *ispc, unsigned int version)
   4.132 +{
   4.133 +	vsp_version = version;
   4.134 +}
   4.135 +
   4.136  /* Initialize everything here */
   4.137 -void InitializeForLoad()
   4.138 +void
   4.139 +mm_InitializeForLoad()
   4.140  {
   4.141  	char full_path[PATH_SIZE] = {0};
   4.142  	GetFileOfAddress((void *)gamedll_info.factory, full_path, sizeof(full_path));
   4.143 @@ -185,13 +219,14 @@
   4.144  	SH_ADD_MANUALHOOK_STATICFUNC(SGD_DLLShutdown, server, Handler_DLLShutdown, false);
   4.145  }
   4.146  
   4.147 -bool DetectGameInformation()
   4.148 +bool
   4.149 +mm_DetectGameInformation()
   4.150  {
   4.151  	char mm_path[PATH_SIZE];
   4.152  	char game_path[PATH_SIZE];
   4.153  
   4.154  	/* Get path to SourceMM DLL */
   4.155 -	if (!GetFileOfAddress((void *)InitializeForLoad, mm_path, sizeof(mm_path)))
   4.156 +	if (!GetFileOfAddress((void *)mm_InitializeForLoad, mm_path, sizeof(mm_path)))
   4.157  	{
   4.158  		return false;
   4.159  	}
   4.160 @@ -211,7 +246,8 @@
   4.161  }
   4.162  
   4.163  /* This is where the magic happens */
   4.164 -SMM_API void *CreateInterface(const char *iface, int *ret)
   4.165 +SMM_API void *
   4.166 +CreateInterface(const char *iface, int *ret)
   4.167  {
   4.168  	/* Prevent loading of self as a SourceMM plugin or Valve server plugin :x */
   4.169  	if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
   4.170 @@ -226,14 +262,12 @@
   4.171  		return NULL;
   4.172  	}
   4.173  
   4.174 -	if (strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
   4.175 +	if (!g_bIsVspBridged && strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
   4.176  	{
   4.177  		if (vsp_callbacks != NULL && atoi(&iface[22]) != vsp_version)
   4.178  		{
   4.179  			if (ret != NULL)
   4.180 -			{
   4.181  				*ret = IFACE_FAILED;
   4.182 -			}
   4.183  			return NULL;
   4.184  		}
   4.185  
   4.186 @@ -241,19 +275,15 @@
   4.187  		vsp_callbacks = provider->GetVSPCallbacks(vsp_version);
   4.188  
   4.189  		if (ret)
   4.190 -		{
   4.191  			*ret = (vsp_callbacks != NULL) ? IFACE_OK : IFACE_FAILED;
   4.192 -		}
   4.193  
   4.194  		if (vsp_callbacks == NULL)
   4.195 -		{
   4.196  			vsp_version = 0;
   4.197 -		}
   4.198  
   4.199  		return vsp_callbacks;
   4.200  	}
   4.201  
   4.202 -	if (provider->IsAlternatelyLoaded())
   4.203 +	if (g_bIsVspBridged)
   4.204  	{
   4.205  		IFACE_MACRO(gamedll_info.factory, GameDLL);
   4.206  	}
   4.207 @@ -262,7 +292,7 @@
   4.208  	{
   4.209  		parsed_game_info = true;
   4.210  
   4.211 -		if (!DetectGameInformation())
   4.212 +		if (!mm_DetectGameInformation())
   4.213  		{
   4.214  			provider->DisplayError("GetFileOfAddress() failed! Metamod cannot load.\n");
   4.215  			return NULL;
   4.216 @@ -435,7 +465,7 @@
   4.217  			if (is_gamedll_loaded)
   4.218  			{
   4.219  				ClearGamedllList();
   4.220 -				InitializeForLoad();
   4.221 +				mm_InitializeForLoad();
   4.222  			}
   4.223  			else
   4.224  			{
   4.225 @@ -459,7 +489,8 @@
   4.226  	IFACE_MACRO(gamedll_info.factory, GameDLL);
   4.227  }
   4.228  
   4.229 -void ClearGamedllList()
   4.230 +static void
   4.231 +ClearGamedllList()
   4.232  {
   4.233  	List<game_dll_t *>::iterator iter;
   4.234  
   4.235 @@ -474,7 +505,8 @@
   4.236  	gamedll_list.clear();
   4.237  }
   4.238  
   4.239 -int LoadPluginsFromFile(const char *_file)
   4.240 +int
   4.241 +mm_LoadPluginsFromFile(const char *_file)
   4.242  {
   4.243  	FILE *fp;
   4.244  	int total = 0, skipped=0;
   4.245 @@ -625,10 +657,8 @@
   4.246  
   4.247  void InitializeVSP()
   4.248  {
   4.249 -	if (provider->IsAlternatelyLoaded())
   4.250 -	{
   4.251 +	if (g_bIsVspBridged)
   4.252  		return;
   4.253 -	}
   4.254  
   4.255  	size_t len;
   4.256  	char engine_file[PATH_SIZE];
   4.257 @@ -663,7 +693,8 @@
   4.258  /* Wrapper function.  This is called when the GameDLL thinks it's using
   4.259   * the engine's real engineFactory.
   4.260   */
   4.261 -void *EngineFactory(const char *iface, int *ret)
   4.262 +static void *
   4.263 +EngineFactory(const char *iface, int *ret)
   4.264  {
   4.265  	IFACE_MACRO(engine_factory, Engine);
   4.266  }
   4.267 @@ -671,7 +702,8 @@
   4.268  /* Wrapper function.  This is called when the GameDLL thinks it's using
   4.269   * the engine's real physicsFactory.
   4.270   */
   4.271 -void *PhysicsFactory(const char *iface, int *ret)
   4.272 +static void *
   4.273 +PhysicsFactory(const char *iface, int *ret)
   4.274  {
   4.275  	IFACE_MACRO(physics_factory, Physics);
   4.276  }
   4.277 @@ -679,12 +711,14 @@
   4.278  /* Wrapper function.  This is called when the GameDLL thinks it's using
   4.279   * the engine's real fileSystemFactory.
   4.280   */
   4.281 -void *FileSystemFactory(const char *iface, int *ret)
   4.282 +static void *
   4.283 +FileSystemFactory(const char *iface, int *ret)
   4.284  {
   4.285  	IFACE_MACRO(filesystem_factory, FileSystem);
   4.286  }
   4.287  
   4.288 -void LogMessage(const char *msg, ...)
   4.289 +void
   4.290 +mm_LogMessage(const char *msg, ...)
   4.291  {
   4.292  	va_list ap;
   4.293  	static char buffer[2048];
   4.294 @@ -702,7 +736,8 @@
   4.295  	}
   4.296  }
   4.297  
   4.298 -void DoInitialPluginLoads()
   4.299 +static void
   4.300 +DoInitialPluginLoads()
   4.301  {
   4.302  	const char *pluginFile = provider->GetCommandLineValue("mm_pluginsfile", NULL);
   4.303  	const char *mmBaseDir = provider->GetCommandLineValue("mm_basedir", NULL);
   4.304 @@ -726,13 +761,14 @@
   4.305  	char full_path[260];
   4.306  
   4.307  	g_Metamod.PathFormat(full_path, sizeof(full_path), "%s/%s", mod_path.c_str(), pluginFile);
   4.308 -	LoadPluginsFromFile(full_path);
   4.309 +	mm_LoadPluginsFromFile(full_path);
   4.310  
   4.311  	g_Metamod.PathFormat(full_path, sizeof(full_path), "%s/%s", mod_path.c_str(), mmBaseDir);
   4.312  	LookForVDFs(full_path);
   4.313  }
   4.314  
   4.315 -void StartupMetamod(bool is_vsp_load)
   4.316 +void
   4.317 +mm_StartupMetamod(bool is_vsp_load)
   4.318  {
   4.319  	char buffer[255];
   4.320  
   4.321 @@ -766,6 +802,8 @@
   4.322  #endif
   4.323  		"Metamod:Source Base Folder",
   4.324  		ConVarFlag_SpOnly);
   4.325 +	
   4.326 +	g_bIsVspBridged = true;
   4.327  
   4.328  	if (!is_vsp_load)
   4.329  	{
   4.330 @@ -774,10 +812,11 @@
   4.331  	}
   4.332  }
   4.333  
   4.334 -void InitializeGlobals(CreateInterfaceFn engineFactory, 
   4.335 -					   CreateInterfaceFn physicsFactory,
   4.336 -					   CreateInterfaceFn filesystemFactory,
   4.337 -					   CGlobalVars *pGlobals)
   4.338 +void
   4.339 +mm_InitializeGlobals(CreateInterfaceFn engineFactory, 
   4.340 +					 CreateInterfaceFn physicsFactory,
   4.341 +					 CreateInterfaceFn filesystemFactory,
   4.342 +					 CGlobalVars *pGlobals)
   4.343  {
   4.344  	engine_factory = engineFactory;
   4.345  	physics_factory = physicsFactory;
   4.346 @@ -786,27 +825,28 @@
   4.347  	provider->Notify_DLLInit_Pre(engineFactory, gamedll_info.factory);
   4.348  }
   4.349  
   4.350 -bool Handler_DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals)
   4.351 +static bool
   4.352 +Handler_DLLInit(CreateInterfaceFn engineFactory,
   4.353 +				CreateInterfaceFn physicsFactory,
   4.354 +				CreateInterfaceFn filesystemFactory,
   4.355 +				CGlobalVars *pGlobals)
   4.356  {
   4.357 -	InitializeGlobals(engineFactory, physicsFactory, filesystemFactory, pGlobals);
   4.358 -	StartupMetamod(false);
   4.359 +	mm_InitializeGlobals(engineFactory, physicsFactory, filesystemFactory, pGlobals);
   4.360 +	mm_StartupMetamod(false);
   4.361  
   4.362  	RETURN_META_VALUE(MRES_IGNORED, true);
   4.363  }
   4.364  
   4.365 -bool Handler_GameInit()
   4.366 +static bool
   4.367 +Handler_GameInit()
   4.368  {
   4.369  	if (is_game_init)
   4.370 -	{
   4.371  		return true;
   4.372 -	}
   4.373  
   4.374  	if (vsp_load_requested)
   4.375 -	{
   4.376  		InitializeVSP();
   4.377 -	}
   4.378  
   4.379 -	if (provider->IsAlternatelyLoaded() && !were_plugins_loaded)
   4.380 +	if (g_bIsVspBridged && !were_plugins_loaded)
   4.381  	{
   4.382  		DoInitialPluginLoads();
   4.383  		g_PluginMngr.SetAllLoaded();
   4.384 @@ -818,13 +858,18 @@
   4.385  	RETURN_META_VALUE(MRES_IGNORED, true);
   4.386  }
   4.387  
   4.388 -bool Handler_DLLInit_Post(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals)
   4.389 +static bool
   4.390 +Handler_DLLInit_Post(CreateInterfaceFn engineFactory,
   4.391 +					 CreateInterfaceFn physicsFactory,
   4.392 +					 CreateInterfaceFn filesystemFactory,
   4.393 +					 CGlobalVars *pGlobals)
   4.394  {
   4.395  	g_PluginMngr.SetAllLoaded();
   4.396  	RETURN_META_VALUE(MRES_IGNORED, true);
   4.397  }
   4.398  
   4.399 -void UnloadMetamod()
   4.400 +void
   4.401 +mm_UnloadMetamod()
   4.402  {
   4.403  	/* Unload plugins */
   4.404  	g_PluginMngr.UnloadAll();
   4.405 @@ -845,15 +890,17 @@
   4.406  	}
   4.407  }
   4.408  
   4.409 -void Handler_DLLShutdown()
   4.410 +static void
   4.411 +Handler_DLLShutdown()
   4.412  {
   4.413 -	UnloadMetamod();
   4.414 +	mm_UnloadMetamod();
   4.415  	RETURN_META(MRES_SUPERCEDE);
   4.416  }
   4.417  
   4.418 -void Handler_LevelShutdown(void)
   4.419 +static void
   4.420 +Handler_LevelShutdown(void)
   4.421  {
   4.422 -	if (provider->IsAlternatelyLoaded() && !were_plugins_loaded)
   4.423 +	if (g_bIsVspBridged && !were_plugins_loaded)
   4.424  	{
   4.425  		g_PluginMngr.SetAllLoaded();
   4.426  		DoInitialPluginLoads();
   4.427 @@ -870,7 +917,7 @@
   4.428  			"%s/%s", 
   4.429  			mod_path.c_str(),
   4.430  			provider->GetConVarString(mm_pluginsfile));
   4.431 -		LoadPluginsFromFile(full_path);
   4.432 +		mm_LoadPluginsFromFile(full_path);
   4.433  
   4.434  		g_Metamod.PathFormat(full_path,
   4.435  			sizeof(full_path),
   4.436 @@ -889,7 +936,13 @@
   4.437  	RETURN_META(MRES_IGNORED);
   4.438  }
   4.439  
   4.440 -bool Handler_LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
   4.441 +static bool
   4.442 +Handler_LevelInit(char const *pMapName,
   4.443 +				  char const *pMapEntities,
   4.444 +				  char const *pOldLevel,
   4.445 +				  char const *pLandmarkName,
   4.446 +				  bool loadGame,
   4.447 +				  bool background)
   4.448  {
   4.449  	ITER_EVENT(OnLevelInit, (pMapName, pMapEntities, pOldLevel, pLandmarkName, loadGame, background));
   4.450  
   4.451 @@ -911,40 +964,28 @@
   4.452  CreateInterfaceFn MetamodSource::GetEngineFactory(bool syn/* =true */)
   4.453  {
   4.454  	if (syn)
   4.455 -	{
   4.456  		return EngineFactory;
   4.457 -	}
   4.458 -
   4.459  	return engine_factory;
   4.460  }
   4.461  
   4.462  CreateInterfaceFn MetamodSource::GetPhysicsFactory(bool syn/* =true */)
   4.463  {
   4.464  	if (syn)
   4.465 -	{
   4.466  		return PhysicsFactory;
   4.467 -	}
   4.468 -
   4.469  	return physics_factory;
   4.470  }
   4.471  
   4.472  CreateInterfaceFn MetamodSource::GetFileSystemFactory(bool syn/* =true */)
   4.473  {
   4.474  	if (syn)
   4.475 -	{
   4.476  		return FileSystemFactory;
   4.477 -	}
   4.478 -
   4.479  	return filesystem_factory;
   4.480  }
   4.481  
   4.482  CreateInterfaceFn MetamodSource::GetServerFactory(bool syn/* =true */)
   4.483  {
   4.484  	if (syn)
   4.485 -	{
   4.486  		return CreateInterface;
   4.487 -	}
   4.488 -
   4.489  	return gamedll_info.factory;
   4.490  }
   4.491  
   4.492 @@ -1145,9 +1186,7 @@
   4.493  void MetamodSource::EnableVSPListener()
   4.494  {
   4.495  	if (is_game_init && !vsp_load_requested && !vsp_loaded)
   4.496 -	{
   4.497  		InitializeVSP();
   4.498 -	}
   4.499  
   4.500  	vsp_load_requested = true;
   4.501  }
   4.502 @@ -1387,12 +1426,8 @@
   4.503  	gamedll_version = version;
   4.504  }
   4.505  
   4.506 -bool MetamodSource::IsAlternateLoadComplete()
   4.507 -{
   4.508 -	return were_plugins_loaded;
   4.509 -}
   4.510 -
   4.511 -void ProcessVDF(const char *path)
   4.512 +static void
   4.513 +ProcessVDF(const char *path)
   4.514  {
   4.515  	PluginId id;
   4.516  	bool already;
   4.517 @@ -1415,7 +1450,8 @@
   4.518  	}
   4.519  }
   4.520  
   4.521 -void LookForVDFs(const char *dir)
   4.522 +static void
   4.523 +LookForVDFs(const char *dir)
   4.524  {
   4.525  	char path[MAX_PATH];
   4.526  	int extidx;
   4.527 @@ -1486,3 +1522,16 @@
   4.528  	closedir(pDir);
   4.529  #endif
   4.530  }
   4.531 +
   4.532 +bool
   4.533 +mm_IsVspBridged()
   4.534 +{
   4.535 +	return g_bIsVspBridged;
   4.536 +}
   4.537 +
   4.538 +bool
   4.539 +mm_IsVspLoadComplete()
   4.540 +{
   4.541 +	return were_plugins_loaded;
   4.542 +}
   4.543 +
     5.1 --- a/core/metamod.h	Sat Nov 15 21:54:46 2008 -0600
     5.2 +++ b/core/metamod.h	Sat Nov 15 23:46:27 2008 -0600
     5.3 @@ -99,19 +99,39 @@
     5.4  	void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
     5.5  	void NotifyVSPListening(IServerPluginCallbacks *callbacks);
     5.6  	void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version);
     5.7 -	bool IsAlternateLoadComplete();
     5.8  };
     5.9  
    5.10 -bool DetectGameInformation();
    5.11 -void LogMessage(const char *msg, ...);
    5.12 -int LoadPluginsFromFile(const char *_file);
    5.13 -void InitializeForLoad();
    5.14 -void InitializeGlobals(CreateInterfaceFn engineFactory, 
    5.15 -					   CreateInterfaceFn physicsFactory,
    5.16 -					   CreateInterfaceFn filesystemFactory,
    5.17 -					   CGlobalVars *pGlobals);
    5.18 -void StartupMetamod(bool is_vsp_load);
    5.19 -void UnloadMetamod();
    5.20 +bool
    5.21 +mm_DetectGameInformation();
    5.22 +
    5.23 +void
    5.24 +mm_LogMessage(const char *msg, ...);
    5.25 +
    5.26 +int
    5.27 +mm_LoadPluginsFromFile(const char *_file);
    5.28 +
    5.29 +void
    5.30 +mm_InitializeForLoad();
    5.31 +
    5.32 +void
    5.33 +mm_InitializeGlobals(CreateInterfaceFn engineFactory, 
    5.34 +					 CreateInterfaceFn physicsFactory,
    5.35 +					 CreateInterfaceFn filesystemFactory,
    5.36 +					 CGlobalVars *pGlobals);
    5.37 +void
    5.38 +mm_StartupMetamod(bool is_vsp_load);
    5.39 +
    5.40 +void
    5.41 +mm_UnloadMetamod();
    5.42 +
    5.43 +void
    5.44 +mm_SetVspInfo(IServerPluginCallbacks *ispc, unsigned int version);
    5.45 +
    5.46 +bool
    5.47 +mm_IsVspBridged();
    5.48 +
    5.49 +bool
    5.50 +mm_IsVspLoadComplete();
    5.51  
    5.52  extern MetamodSource g_Metamod;
    5.53  extern SourceHook::Impl::CSourceHookImpl g_SourceHook;
     6.1 --- a/core/metamod_console.cpp	Sat Nov 15 21:54:46 2008 -0600
     6.2 +++ b/core/metamod_console.cpp	Sat Nov 15 23:46:27 2008 -0600
     6.3 @@ -48,7 +48,7 @@
     6.4  {
     6.5  	unsigned int args = info->GetArgCount();
     6.6  
     6.7 -	if (provider->IsAlternatelyLoaded() && !g_Metamod.IsAlternateLoadComplete())
     6.8 +	if (mm_IsVspBridged() && !mm_IsVspLoadComplete())
     6.9  	{
    6.10  		CONMSG("You must change the map to activate Metamod:Source.\n");
    6.11  		return true;
    6.12 @@ -151,7 +151,7 @@
    6.13  				g_Metamod.GetBaseDir(), 
    6.14  				g_Metamod.GetPluginsFile());
    6.15  
    6.16 -			LoadPluginsFromFile(full_path);
    6.17 +			mm_LoadPluginsFromFile(full_path);
    6.18  
    6.19  			return true;
    6.20  		}
     7.1 --- a/core/metamod_provider.h	Sat Nov 15 21:54:46 2008 -0600
     7.2 +++ b/core/metamod_provider.h	Sat Nov 15 23:46:27 2008 -0600
     7.3 @@ -298,14 +298,6 @@
     7.4  		virtual int DetermineSourceEngine(const char *game) =0;
     7.5  
     7.6  		/**
     7.7 -		 * @brief Returns if the provider has loaded itself through an 
     7.8 -		 * alternate means (that is, not through gameinfo.txt.
     7.9 -		 *
    7.10 -		 * @return				True if loaded, false otherwise.
    7.11 -		 */
    7.12 -		virtual bool IsAlternatelyLoaded() =0;
    7.13 -
    7.14 -		/**
    7.15  		 * @brief Processes a VDF plugin file.
    7.16  		 *
    7.17  		 */
     8.1 --- a/core/provider/provider_ep2.cpp	Sat Nov 15 21:54:46 2008 -0600
     8.2 +++ b/core/provider/provider_ep2.cpp	Sat Nov 15 23:46:27 2008 -0600
     8.3 @@ -395,11 +395,6 @@
     8.4  	return &g_VspListener;
     8.5  }
     8.6  
     8.7 -bool BaseProvider::IsAlternatelyLoaded()
     8.8 -{
     8.9 -	return g_VspListener.IsRootLoadMethod();
    8.10 -}
    8.11 -
    8.12  bool BaseProvider::ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len)
    8.13  {
    8.14  	if (baseFs == NULL)
     9.1 --- a/core/provider/provider_ep2.h	Sat Nov 15 21:54:46 2008 -0600
     9.2 +++ b/core/provider/provider_ep2.h	Sat Nov 15 23:46:27 2008 -0600
     9.3 @@ -78,7 +78,6 @@
     9.4  	virtual int FindUserMessage(const char *name, int *size=NULL);
     9.5  	virtual const char *GetUserMessage(int index, int *size=NULL);
     9.6  	virtual int DetermineSourceEngine(const char *game);
     9.7 -	virtual bool IsAlternatelyLoaded();
     9.8  	virtual bool ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len);
     9.9  };
    9.10  
    10.1 --- a/core/provider/vsp_listener.cpp	Sat Nov 15 21:54:46 2008 -0600
    10.2 +++ b/core/provider/vsp_listener.cpp	Sat Nov 15 23:46:27 2008 -0600
    10.3 @@ -36,28 +36,12 @@
    10.4  #include "svn_version.h"
    10.5  #include "provider_ep2.h"
    10.6  
    10.7 -SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
    10.8 -
    10.9  using namespace SourceMM;
   10.10  
   10.11 -ConCommand *g_plugin_unload = NULL;
   10.12 -bool g_bIsTryingToUnload;
   10.13 -
   10.14 -void InterceptPluginUnloads(const CCommand &args)
   10.15 -{
   10.16 -	g_bIsTryingToUnload = true;
   10.17 -}
   10.18 -
   10.19 -void InterceptPluginUnloads_Post(const CCommand &args)
   10.20 -{
   10.21 -	g_bIsTryingToUnload = false;
   10.22 -}
   10.23 -
   10.24  VSPListener::VSPListener()
   10.25  {
   10.26  	m_bLoaded = false;
   10.27  	m_bLoadable = false;
   10.28 -	m_bIsRootLoadMethod = false;
   10.29  }
   10.30  
   10.31  void VSPListener::ClientActive(edict_t *pEntity)
   10.32 @@ -131,6 +115,7 @@
   10.33  
   10.34  void VSPListener::Unload()
   10.35  {
   10.36 +	#if 0
   10.37  	if (g_bIsTryingToUnload)
   10.38  	{
   10.39  		Error("Metamod:Source cannot be unloaded from VSP mode.  Use \"meta unload\" to unload specific plugins.\n");
   10.40 @@ -146,9 +131,9 @@
   10.41  		}
   10.42  		UnloadMetamod();
   10.43  	}
   10.44 +	#endif
   10.45  	m_bLoaded = false;
   10.46  	m_bLoadable = true;
   10.47 -	m_bIsRootLoadMethod = false;
   10.48  }
   10.49  
   10.50  void VSPListener::SetLoadable(bool set)
   10.51 @@ -158,77 +143,10 @@
   10.52  
   10.53  bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
   10.54  {
   10.55 -	if (!g_Metamod.IsLoadedAsGameDLL())
   10.56 -	{
   10.57 -		CGlobalVars *pGlobals;
   10.58 -		IPlayerInfoManager *playerInfoManager;
   10.59 -
   10.60 -		playerInfoManager = (IPlayerInfoManager *)gameServerFactory("PlayerInfoManager002", NULL);
   10.61 -		if (playerInfoManager == NULL)
   10.62 -		{
   10.63 -			Msg("Metamod:Source requires gameinfo.txt modification to load on this game.\n");
   10.64 -			return false;
   10.65 -		}
   10.66 -
   10.67 -		pGlobals = playerInfoManager->GetGlobalVars();
   10.68 -
   10.69 -		char gamedll_iface[] = "ServerGameDLL000";
   10.70 -		for (unsigned int i = 5; i <= 50; i++)
   10.71 -		{
   10.72 -			gamedll_iface[15] = '0' + i;
   10.73 -			if ((server = (IServerGameDLL *)gameServerFactory(gamedll_iface, NULL)) != NULL)
   10.74 -			{
   10.75 -				g_Metamod.SetGameDLLInfo(gameServerFactory, i);
   10.76 -				break;
   10.77 -			}
   10.78 -		}
   10.79 -
   10.80 -		if (server == NULL)
   10.81 -		{
   10.82 -			Msg("Metamod:Source could not load (GameDLL version not compatible).\n");
   10.83 -			return false;
   10.84 -		}
   10.85 -
   10.86 -		char gameclients_iface[] = "ServerGameClients000";
   10.87 -		for (unsigned int i = 3; i <= 4; i++)
   10.88 -		{
   10.89 -			gameclients_iface[19] = '0' + i;
   10.90 -			if ((gameclients = (IServerGameClients *)gameServerFactory(gameclients_iface, NULL)) == NULL)
   10.91 -			{
   10.92 -				break;
   10.93 -			}
   10.94 -		}
   10.95 -
   10.96 -		if (!DetectGameInformation())
   10.97 -		{
   10.98 -			Msg("Metamod:Source failed to detect game paths; cannot load.\n");
   10.99 -			return false;
  10.100 -		}
  10.101 -
  10.102 -		m_bIsRootLoadMethod = true;
  10.103 -		m_bLoaded = true;
  10.104 -		SetLoadable(false);
  10.105 -
  10.106 -		InitializeForLoad();
  10.107 -		InitializeGlobals(interfaceFactory, interfaceFactory, interfaceFactory, pGlobals);
  10.108 -		StartupMetamod(true);
  10.109 -		
  10.110 -		g_plugin_unload = icvar->FindCommand("plugin_unload");
  10.111 -
  10.112 -		if (g_plugin_unload != NULL)
  10.113 -		{
  10.114 -			SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads, false);
  10.115 -			SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
  10.116 -		}
  10.117 -	}
  10.118 -
  10.119  	m_bLoaded = true;
  10.120  	SetLoadable(false);
  10.121  
  10.122 -	if (!m_bIsRootLoadMethod)
  10.123 -	{
  10.124 -		g_Metamod.NotifyVSPListening(this);
  10.125 -	}
  10.126 +	g_Metamod.NotifyVSPListening(this);
  10.127  
  10.128  	return true;
  10.129  }
  10.130 @@ -237,7 +155,3 @@
  10.131  {
  10.132  }
  10.133  
  10.134 -bool VSPListener::IsRootLoadMethod()
  10.135 -{
  10.136 -	return m_bIsRootLoadMethod;
  10.137 -}
    11.1 --- a/core/provider/vsp_listener.h	Sat Nov 15 21:54:46 2008 -0600
    11.2 +++ b/core/provider/vsp_listener.h	Sat Nov 15 23:46:27 2008 -0600
    11.3 @@ -63,12 +63,10 @@
    11.4  	virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue );
    11.5  public:
    11.6  	bool IsLoaded();
    11.7 -	bool IsRootLoadMethod();
    11.8  	void SetLoadable(bool loadable);
    11.9  private:
   11.10  	bool m_bLoaded;
   11.11  	bool m_bLoadable;
   11.12 -	bool m_bIsRootLoadMethod;
   11.13  };
   11.14  
   11.15  #endif //_INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
    12.1 --- a/core/svn_version.h	Sat Nov 15 21:54:46 2008 -0600
    12.2 +++ b/core/svn_version.h	Sat Nov 15 23:46:27 2008 -0600
    12.3 @@ -3,11 +3,11 @@
    12.4  #ifndef _INCLUDE_SVN_VERSION_H_
    12.5  #define _INCLUDE_SVN_VERSION_H_
    12.6  
    12.7 -#define SVN_PRODUCT_VERSION		"1.6.2"
    12.8 +#define SVN_PRODUCT_VERSION		"1.7.0"
    12.9  
   12.10  #define SVN_REVISION			703
   12.11  #define SVN_REVISION_STRING		"703"
   12.12 -#define SVN_FILE_VERSION		1,6,2,703
   12.13 -#define SVN_FILE_VERSION_STRING	"1.6.2.703"
   12.14 +#define SVN_FILE_VERSION		1,7,0,703
   12.15 +#define SVN_FILE_VERSION_STRING	"1.7.0.703"
   12.16  
   12.17  #endif //_INCLUDE_SVN_VERSION_H_