Added gamedll bridging to ep2/l4d provider (bug 3412).
authorDavid Anderson <dvander@alliedmods.net>
Sun Nov 23 23:22:33 2008 -0600 (2008-11-23)
changeset 5898e97a1e960a5
parent 588 41649fe12c7b
child 590 ab1251b273f9
Added gamedll bridging to ep2/l4d provider (bug 3412).
core/Makefile
core/gamedll_bridge.cpp
core/metamod.cpp
core/metamod.h
core/metamod_provider.h
core/metamod_util.cpp
core/metamod_util.h
core/msvc9/mm_core.vcproj
core/provider/provider_ep2.cpp
core/vsp_bridge.cpp
     1.1 --- a/core/Makefile	Sun Nov 23 22:36:06 2008 -0600
     1.2 +++ b/core/Makefile	Sun Nov 23 23:22:33 2008 -0600
     1.3 @@ -19,7 +19,8 @@
     1.4  		  provider/console.cpp 		\
     1.5  		  provider/provider_ep2.cpp \
     1.6  		  provider/vsp_listener.cpp	\
     1.7 -		  vsp_bridge.cpp
     1.8 +		  vsp_bridge.cpp			\
     1.9 +		  gamedll_bridge.cpp
    1.10  
    1.11  ##############################################
    1.12  ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/core/gamedll_bridge.cpp	Sun Nov 23 23:22:33 2008 -0600
     2.3 @@ -0,0 +1,64 @@
     2.4 +#include <assert.h>
     2.5 +#include "metamod.h"
     2.6 +#include "metamod_plugins.h"
     2.7 +#include "metamod_util.h"
     2.8 +#include <loader_bridge.h>
     2.9 +#include "provider/provider_ep2.h"
    2.10 +
    2.11 +using namespace SourceMM;
    2.12 +
    2.13 +class GameDllBridge : public IGameDllBridge
    2.14 +{
    2.15 +public:
    2.16 +	virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
    2.17 +	{
    2.18 +		if (!mm_DetectGameInformation())
    2.19 +		{
    2.20 +			UTIL_Format(buffer, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
    2.21 +			return false;
    2.22 +		}
    2.23 +
    2.24 +		server = (IServerGameDLL *)info->isgd;
    2.25 +		g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
    2.26 +								 info->dllVersion,
    2.27 +								 true);
    2.28 +		mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
    2.29 +							 (CreateInterfaceFn)info->physicsFactory,
    2.30 +							 (CreateInterfaceFn)info->fsFactory,
    2.31 +							 (CGlobalVars*)info->pGlobals);
    2.32 +		mm_InitializeForLoad();
    2.33 +		mm_StartupMetamod(false);
    2.34 +
    2.35 +		return true;
    2.36 +	}
    2.37 +	virtual void DLLInit_Post(int *isgdUnload)
    2.38 +	{
    2.39 +		SourceHook::MemFuncInfo mfi;
    2.40 +
    2.41 +		mfi.isVirtual = false;
    2.42 +		SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
    2.43 +		assert(mfi.isVirtual);
    2.44 +		assert(mfi.vtbloffs == 0);
    2.45 +		assert(mfi.thisptroffs == 0);
    2.46 +		*isgdUnload = mfi.vtblindex;
    2.47 +
    2.48 +		g_PluginMngr.SetAllLoaded();
    2.49 +	}
    2.50 +	virtual void *QueryInterface(const char *iface, int *ret)
    2.51 +	{
    2.52 +		return g_Metamod.GetServerFactory(true)(iface, ret);
    2.53 +	}
    2.54 +	virtual void Unload()
    2.55 +	{
    2.56 +		mm_UnloadMetamod();
    2.57 +	}
    2.58 +};
    2.59 +
    2.60 +GameDllBridge mm16_gamedll_bridge;
    2.61 +
    2.62 +SMM_API IGameDllBridge *
    2.63 +GetGameDllBridge()
    2.64 +{
    2.65 +	return &mm16_gamedll_bridge;
    2.66 +}
    2.67 +
     3.1 --- a/core/metamod.cpp	Sun Nov 23 22:36:06 2008 -0600
     3.2 +++ b/core/metamod.cpp	Sun Nov 23 23:22:33 2008 -0600
     3.3 @@ -45,26 +45,9 @@
     3.4   * @file sourcemm.cpp
     3.5   */
     3.6  
     3.7 -SH_DECL_MANUALHOOK4(SGD_DLLInit, 0, 0, 0, bool, CreateInterfaceFn, CreateInterfaceFn, CreateInterfaceFn, CGlobalVars *);
     3.8  SH_DECL_MANUALHOOK0(SGD_GameInit, 0, 0, 0, bool);
     3.9  SH_DECL_MANUALHOOK6(SGD_LevelInit, 0, 0, 0, bool, const char *, const char *, const char *, const char *, bool, bool);
    3.10  SH_DECL_MANUALHOOK0_void(SGD_LevelShutdown, 0, 0, 0);
    3.11 -SH_DECL_MANUALHOOK0_void(SGD_DLLShutdown, 0, 0, 0);
    3.12 -
    3.13 -static bool
    3.14 -Handler_DLLInit(CreateInterfaceFn engineFactory,
    3.15 -				CreateInterfaceFn physicsFactory,
    3.16 -				CreateInterfaceFn filesystemFactory,
    3.17 -				CGlobalVars *pGlobals);
    3.18 -
    3.19 -static bool
    3.20 -Handler_DLLInit_Post(CreateInterfaceFn engineFactory,
    3.21 -					 CreateInterfaceFn physicsFactory,
    3.22 -					 CreateInterfaceFn filesystemFactory,
    3.23 -					 CGlobalVars *pGlobals);
    3.24 -
    3.25 -static void
    3.26 -Handler_DLLShutdown();
    3.27  
    3.28  static void
    3.29  Handler_LevelShutdown();
    3.30 @@ -88,14 +71,12 @@
    3.31  
    3.32  struct game_dll_t
    3.33  {
    3.34 -	HINSTANCE lib;
    3.35  	CreateInterfaceFn factory;
    3.36  };
    3.37  
    3.38  static String mod_path;
    3.39  static String metamod_path;
    3.40  static String full_bin_path;
    3.41 -static bool parsed_game_info = false;
    3.42  static int vsp_version = 0;
    3.43  static int gamedll_version = 0;
    3.44  static int engine_build = SOURCE_ENGINE_UNKNOWN;
    3.45 @@ -125,9 +106,6 @@
    3.46  ISourceHook *g_SHPtr = &g_SourceHook;
    3.47  SourceMM::ISmmAPI *g_pMetamod = &g_Metamod;
    3.48  
    3.49 -static void
    3.50 -ClearGamedllList();
    3.51 -
    3.52  /* Helper Macro */
    3.53  #define	IFACE_MACRO(orig,nam) \
    3.54  	CPluginManager::CPlugin *pl; \
    3.55 @@ -182,14 +160,6 @@
    3.56  
    3.57  	SourceHook::MemFuncInfo info;
    3.58  
    3.59 -	if (!provider->GetHookInfo(ProvidedHook_DLLInit, &info))
    3.60 -	{
    3.61 -		provider->DisplayError("Metamod:Source could not find a valid hook for IServerGameDLL::DLLInit");
    3.62 -	}
    3.63 -	SH_MANUALHOOK_RECONFIGURE(SGD_DLLInit, info.vtblindex, info.vtbloffs, info.thisptroffs);
    3.64 -	SH_ADD_MANUALHOOK_STATICFUNC(SGD_DLLInit, server, Handler_DLLInit, false);
    3.65 -	SH_ADD_MANUALHOOK_STATICFUNC(SGD_DLLInit, server, Handler_DLLInit_Post, true);
    3.66 -
    3.67  	if (!provider->GetHookInfo(ProvidedHook_GameInit, &info))
    3.68  	{
    3.69  		provider->DisplayError("Metamod:Source could not find a valid hook for IServerGameDLL::GameInit");
    3.70 @@ -210,13 +180,6 @@
    3.71  	}
    3.72  	SH_MANUALHOOK_RECONFIGURE(SGD_LevelShutdown, info.vtblindex, info.vtbloffs, info.thisptroffs);
    3.73  	SH_ADD_MANUALHOOK_STATICFUNC(SGD_LevelShutdown, server, Handler_LevelShutdown, true);
    3.74 -
    3.75 -	if (!provider->GetHookInfo(ProvidedHook_DLLShutdown, &info))
    3.76 -	{
    3.77 -		provider->DisplayError("Metamod:Source could not find a valid hook for IServerGameDLL::DLLShutdown");
    3.78 -	}
    3.79 -	SH_MANUALHOOK_RECONFIGURE(SGD_DLLShutdown, info.vtblindex, info.vtbloffs, info.thisptroffs);
    3.80 -	SH_ADD_MANUALHOOK_STATICFUNC(SGD_DLLShutdown, server, Handler_DLLShutdown, false);
    3.81  }
    3.82  
    3.83  bool
    3.84 @@ -245,266 +208,12 @@
    3.85  	return true;
    3.86  }
    3.87  
    3.88 -/* This is where the magic happens */
    3.89 -SMM_API void *
    3.90 -CreateInterface(const char *iface, int *ret)
    3.91 +void *
    3.92 +ServerFactory(const char *iface, int *ret)
    3.93  {
    3.94 -	/* Prevent loading of self as a SourceMM plugin or Valve server plugin :x */
    3.95 -	if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
    3.96 -	{
    3.97 -		provider->DisplayWarning("Do not try loading Metamod:Source as a plugin.\n");
    3.98 -
    3.99 -		if (ret)
   3.100 -		{
   3.101 -			*ret = IFACE_FAILED;
   3.102 -		}
   3.103 -
   3.104 -		return NULL;
   3.105 -	}
   3.106 -
   3.107 -	if (!g_bIsVspBridged && strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
   3.108 -	{
   3.109 -		if (vsp_callbacks != NULL && atoi(&iface[22]) != vsp_version)
   3.110 -		{
   3.111 -			if (ret != NULL)
   3.112 -				*ret = IFACE_FAILED;
   3.113 -			return NULL;
   3.114 -		}
   3.115 -
   3.116 -		vsp_version = atoi(&iface[22]);
   3.117 -		vsp_callbacks = provider->GetVSPCallbacks(vsp_version);
   3.118 -
   3.119 -		if (ret)
   3.120 -			*ret = (vsp_callbacks != NULL) ? IFACE_OK : IFACE_FAILED;
   3.121 -
   3.122 -		if (vsp_callbacks == NULL)
   3.123 -			vsp_version = 0;
   3.124 -
   3.125 -		return vsp_callbacks;
   3.126 -	}
   3.127 -
   3.128 -	if (g_bIsVspBridged)
   3.129 -	{
   3.130 -		IFACE_MACRO(gamedll_info.factory, GameDLL);
   3.131 -	}
   3.132 -
   3.133 -	if (!parsed_game_info)
   3.134 -	{
   3.135 -		parsed_game_info = true;
   3.136 -
   3.137 -		if (!mm_DetectGameInformation())
   3.138 -		{
   3.139 -			provider->DisplayError("GetFileOfAddress() failed! Metamod cannot load.\n");
   3.140 -			return NULL;
   3.141 -		}
   3.142 -
   3.143 -		char temp_path[PATH_SIZE];
   3.144 -
   3.145 -		/* Path to gameinfo.txt */
   3.146 -		g_Metamod.PathFormat(temp_path, PATH_SIZE, "%s/%s", mod_path.c_str(), "gameinfo.txt");
   3.147 -
   3.148 -		FILE *fp = fopen(temp_path, "rt");
   3.149 -
   3.150 -		if (!fp)
   3.151 -		{
   3.152 -			provider->DisplayError("Unable to open gameinfo.txt!  Metamod cannot load.\n");
   3.153 -			return NULL;
   3.154 -		}
   3.155 -
   3.156 -		char buffer[255];
   3.157 -		char key[128], val[128];
   3.158 -		bool search = false;
   3.159 -		bool gamebin = false;
   3.160 -		char *ptr;
   3.161 -		const char *lptr;
   3.162 -		char cur_path[PATH_SIZE];
   3.163 -
   3.164 -		getcwd(cur_path, PATH_SIZE);
   3.165 -
   3.166 -		while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
   3.167 -		{
   3.168 -			UTIL_TrimComments(buffer);
   3.169 -			UTIL_TrimLeft(buffer);
   3.170 -			UTIL_TrimRight(buffer);
   3.171 -
   3.172 -			if (stricmp(buffer, "SearchPaths") == 0)
   3.173 -			{
   3.174 -				search = true;
   3.175 -			}
   3.176 -
   3.177 -			if (!search)
   3.178 -			{
   3.179 -				continue;
   3.180 -			}
   3.181 -
   3.182 -			UTIL_KeySplit(buffer, key, sizeof(key) - 1, val, sizeof(val) - 1);
   3.183 -			if (stricmp(key, "Game") == 0 || stricmp(key, "GameBin") == 0)
   3.184 -			{
   3.185 -				if (stricmp(key, "Game") == 0)
   3.186 -				{
   3.187 -					gamebin = false;
   3.188 -				}
   3.189 -				else
   3.190 -				{
   3.191 -					gamebin = true;
   3.192 -				}
   3.193 -
   3.194 -				if (strncmp(val, "|gameinfo_path|", sizeof("|gameinfo_path|") - 1) == 0)
   3.195 -				{
   3.196 -					ptr = &(val[sizeof("|gameinfo_path|") - 1]);
   3.197 -					if (ptr[0] == '.')
   3.198 -					{
   3.199 -						ptr++;
   3.200 -					}
   3.201 -					lptr = mod_path.c_str();
   3.202 -				} else {
   3.203 -					ptr = val;
   3.204 -					lptr = cur_path;
   3.205 -				}
   3.206 -
   3.207 -				size_t ptr_len = strlen(ptr);
   3.208 -				if (ptr[ptr_len] == '/' || ptr[ptr_len] == '\\')
   3.209 -				{
   3.210 -					ptr[--ptr_len] = '\0';
   3.211 -				}
   3.212 -
   3.213 -				/* No need to append "bin" if key is GameBin */
   3.214 -				if (gamebin)
   3.215 -				{
   3.216 -					g_Metamod.PathFormat(temp_path, PATH_SIZE, "%s/%s/%s", lptr, ptr, SERVER_DLL);
   3.217 -				}
   3.218 -				else if (!ptr[0])
   3.219 -				{
   3.220 -					g_Metamod.PathFormat(temp_path, PATH_SIZE, "%s/%s/%s", lptr, "bin", SERVER_DLL);
   3.221 -				}
   3.222 -				else
   3.223 -				{
   3.224 -					g_Metamod.PathFormat(temp_path, PATH_SIZE, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL);
   3.225 -				}
   3.226 -
   3.227 -				/* If not path to SourceMM... */
   3.228 -				if (!UTIL_PathCmp(metamod_path.c_str(), temp_path))
   3.229 -				{
   3.230 -					FILE *temp_fp = fopen(temp_path, "rb");
   3.231 -					if (!temp_fp)
   3.232 -					{
   3.233 -						continue;
   3.234 -					}
   3.235 -					fclose(temp_fp);
   3.236 -
   3.237 -					/* Search for a matching game dll */
   3.238 -					List<game_dll_t *>::iterator iter;
   3.239 -					game_dll_t *pCheck;
   3.240 -					bool found = false;
   3.241 -					for (iter = gamedll_list.begin(); iter != gamedll_list.end(); iter++)
   3.242 -					{
   3.243 -						pCheck = (*iter);
   3.244 -						if (GetFileOfAddress((void *)pCheck->factory, buffer, sizeof(buffer)))
   3.245 -						{
   3.246 -							if (UTIL_PathCmp(temp_path, buffer))
   3.247 -							{
   3.248 -								found = true;
   3.249 -								break;
   3.250 -							}
   3.251 -						}
   3.252 -					}
   3.253 -
   3.254 -					if (found)
   3.255 -					{
   3.256 -						continue;
   3.257 -					}
   3.258 -					
   3.259 -					HINSTANCE gamedll = dlmount(temp_path);
   3.260 -					if (gamedll == NULL)
   3.261 -					{
   3.262 -						continue;
   3.263 -					}
   3.264 -
   3.265 -					CreateInterfaceFn fn = (CreateInterfaceFn)dlsym(gamedll, "CreateInterface");
   3.266 -					if (fn == NULL)
   3.267 -					{
   3.268 -						dlclose(gamedll);
   3.269 -						continue;
   3.270 -					}
   3.271 -
   3.272 -					game_dll_t *pInfo = new game_dll_t;
   3.273 -					pInfo->factory = fn;
   3.274 -					pInfo->lib = gamedll;
   3.275 -					gamedll_list.push_back(pInfo);
   3.276 -					break;
   3.277 -				}
   3.278 -			}
   3.279 -		}
   3.280 -		fclose(fp);
   3.281 -	}
   3.282 -
   3.283 -	if (!is_gamedll_loaded)
   3.284 -	{
   3.285 -		if (strncmp(iface, "ServerGameDLL", 13) == 0)
   3.286 -		{
   3.287 -			List<game_dll_t *>::iterator iter;
   3.288 -			game_dll_t *pInfo;
   3.289 -			for (iter=gamedll_list.begin(); iter!=gamedll_list.end(); iter++)
   3.290 -			{
   3.291 -				pInfo = (*iter);
   3.292 -				if ((server = (IServerGameDLL *)((pInfo->factory)(iface, ret))) != NULL)
   3.293 -				{
   3.294 -					if ((gamedll_version = provider->TryServerGameDLL(iface)) != 0)
   3.295 -					{
   3.296 -						/* We have a match.  Erase us from the list and save our info. */
   3.297 -						gamedll_list.erase(iter);
   3.298 -						gamedll_info = *pInfo;
   3.299 -						delete pInfo;
   3.300 -						is_gamedll_loaded = true;
   3.301 -						break;
   3.302 -					}
   3.303 -					/* :TODO: error otherwise? */
   3.304 -				}
   3.305 -			}
   3.306 -
   3.307 -			if (is_gamedll_loaded)
   3.308 -			{
   3.309 -				ClearGamedllList();
   3.310 -				mm_InitializeForLoad();
   3.311 -			}
   3.312 -			else
   3.313 -			{
   3.314 -				if (ret)
   3.315 -				{
   3.316 -					*ret = IFACE_FAILED;
   3.317 -				}
   3.318 -				return NULL;
   3.319 -			}
   3.320 -		}
   3.321 -		else
   3.322 -		{
   3.323 -			/* wtf do we do... */
   3.324 -			/* :TODO: .. something a bit more intelligent? */
   3.325 -			provider->DisplayError("Engine requested unknown interface before GameDLL was known!\n");
   3.326 -			return NULL;
   3.327 -		}
   3.328 -	}
   3.329 -
   3.330 -	/* If we got here, there's definitely a GameDLL */
   3.331  	IFACE_MACRO(gamedll_info.factory, GameDLL);
   3.332  }
   3.333  
   3.334 -static void
   3.335 -ClearGamedllList()
   3.336 -{
   3.337 -	List<game_dll_t *>::iterator iter;
   3.338 -
   3.339 -	game_dll_t *pInfo;
   3.340 -	for (iter = gamedll_list.begin(); iter != gamedll_list.end(); iter++)
   3.341 -	{
   3.342 -		pInfo = (*iter);
   3.343 -		dlclose(pInfo->lib);
   3.344 -		delete pInfo;
   3.345 -	}
   3.346 -
   3.347 -	gamedll_list.clear();
   3.348 -}
   3.349 -
   3.350  int
   3.351  mm_LoadPluginsFromFile(const char *_file)
   3.352  {
   3.353 @@ -814,18 +523,6 @@
   3.354  }
   3.355  
   3.356  static bool
   3.357 -Handler_DLLInit(CreateInterfaceFn engineFactory,
   3.358 -				CreateInterfaceFn physicsFactory,
   3.359 -				CreateInterfaceFn filesystemFactory,
   3.360 -				CGlobalVars *pGlobals)
   3.361 -{
   3.362 -	mm_InitializeGlobals(engineFactory, physicsFactory, filesystemFactory, pGlobals);
   3.363 -	mm_StartupMetamod(false);
   3.364 -
   3.365 -	RETURN_META_VALUE(MRES_IGNORED, true);
   3.366 -}
   3.367 -
   3.368 -static bool
   3.369  Handler_GameInit()
   3.370  {
   3.371  	if (is_game_init)
   3.372 @@ -846,16 +543,6 @@
   3.373  	RETURN_META_VALUE(MRES_IGNORED, true);
   3.374  }
   3.375  
   3.376 -static bool
   3.377 -Handler_DLLInit_Post(CreateInterfaceFn engineFactory,
   3.378 -					 CreateInterfaceFn physicsFactory,
   3.379 -					 CreateInterfaceFn filesystemFactory,
   3.380 -					 CGlobalVars *pGlobals)
   3.381 -{
   3.382 -	g_PluginMngr.SetAllLoaded();
   3.383 -	RETURN_META_VALUE(MRES_IGNORED, true);
   3.384 -}
   3.385 -
   3.386  void
   3.387  mm_UnloadMetamod()
   3.388  {
   3.389 @@ -864,25 +551,7 @@
   3.390  
   3.391  	provider->Notify_DLLShutdown_Pre();
   3.392  
   3.393 -	if (is_gamedll_loaded)
   3.394 -	{
   3.395 -		SH_CALL(server, &IServerGameDLL::DLLShutdown)();
   3.396 -	}
   3.397 -
   3.398  	g_SourceHook.CompleteShutdown();
   3.399 -
   3.400 -	if (is_gamedll_loaded && gamedll_info.lib)
   3.401 -	{
   3.402 -		dlclose(gamedll_info.lib);
   3.403 -		is_gamedll_loaded = false;
   3.404 -	}
   3.405 -}
   3.406 -
   3.407 -static void
   3.408 -Handler_DLLShutdown()
   3.409 -{
   3.410 -	mm_UnloadMetamod();
   3.411 -	RETURN_META(MRES_SUPERCEDE);
   3.412  }
   3.413  
   3.414  static void
   3.415 @@ -973,7 +642,7 @@
   3.416  CreateInterfaceFn MetamodSource::GetServerFactory(bool syn/* =true */)
   3.417  {
   3.418  	if (syn)
   3.419 -		return CreateInterface;
   3.420 +		return ServerFactory;
   3.421  	return gamedll_info.factory;
   3.422  }
   3.423  
   3.424 @@ -1408,10 +1077,11 @@
   3.425  	return is_gamedll_loaded;
   3.426  }
   3.427  
   3.428 -void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, int version)
   3.429 +void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded)
   3.430  {
   3.431  	gamedll_info.factory = serverFactory;
   3.432  	gamedll_version = version;
   3.433 +	is_gamedll_loaded = loaded;
   3.434  }
   3.435  
   3.436  static void
     4.1 --- a/core/metamod.h	Sun Nov 23 22:36:06 2008 -0600
     4.2 +++ b/core/metamod.h	Sun Nov 23 23:22:33 2008 -0600
     4.3 @@ -98,7 +98,7 @@
     4.4  	const char *GetPluginsFile();
     4.5  	void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
     4.6  	void NotifyVSPListening(IServerPluginCallbacks *callbacks);
     4.7 -	void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version);
     4.8 +	void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded);
     4.9  };
    4.10  
    4.11  bool
     5.1 --- a/core/metamod_provider.h	Sun Nov 23 22:36:06 2008 -0600
     5.2 +++ b/core/metamod_provider.h	Sun Nov 23 23:22:33 2008 -0600
     5.3 @@ -41,8 +41,6 @@
     5.4  	{
     5.5  		ProvidedHook_LevelInit = 0,			/**< IServerGameDLL::LevelInit */
     5.6  		ProvidedHook_LevelShutdown = 1,		/**< IServerGameDLL::LevelShutdown */
     5.7 -		ProvidedHook_DLLInit = 2,			/**< IServerGameDLL::DLLInit */
     5.8 -		ProvidedHook_DLLShutdown = 3,		/**< IServerGameDLL::DLLShutdown */
     5.9  		ProvidedHook_GameInit = 4,			/**< IServerGameDLL::GameInit */
    5.10  	};
    5.11  
     6.1 --- a/core/metamod_util.cpp	Sun Nov 23 22:36:06 2008 -0600
     6.2 +++ b/core/metamod_util.cpp	Sun Nov 23 23:22:33 2008 -0600
     6.3 @@ -99,91 +99,6 @@
     6.4  	}
     6.5  }
     6.6  
     6.7 -/* :TODO: this should skip string literals */
     6.8 -void UTIL_TrimComments(char *buffer)
     6.9 -{
    6.10 -	int num_sc = 0;
    6.11 -	size_t len = strlen(buffer);
    6.12 -	if (buffer)
    6.13 -	{
    6.14 -		for (int i = len - 1; i >= 0; i--)
    6.15 -		{
    6.16 -			if (buffer[i] == '/')
    6.17 -			{
    6.18 -				if (++num_sc >= 2 && i==0)
    6.19 -				{
    6.20 -					buffer[i] = '\0';
    6.21 -					return;
    6.22 -				}
    6.23 -			} else {
    6.24 -				if (num_sc >= 2)
    6.25 -				{
    6.26 -					buffer[i] = '\0';
    6.27 -					return;
    6.28 -				}
    6.29 -				num_sc = 0;
    6.30 -			}
    6.31 -			/* size_t won't go below 0, manually break out */
    6.32 -			if (i == 0)
    6.33 -			{
    6.34 -				break;
    6.35 -			}
    6.36 -		}
    6.37 -	}
    6.38 -}
    6.39 -
    6.40 -void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2)
    6.41 -{
    6.42 -	size_t start;
    6.43 -	size_t len = strlen(str);
    6.44 -
    6.45 -	for (start = 0; start < len; start++)
    6.46 -	{
    6.47 -		if (!isspace(str[start]))
    6.48 -		{
    6.49 -			break;
    6.50 -		}
    6.51 -	}
    6.52 -
    6.53 -	size_t end;
    6.54 -	for (end = start; end < len; end++)
    6.55 -	{
    6.56 -		if (isspace(str[end]))
    6.57 -		{
    6.58 -			break;
    6.59 -		}
    6.60 -	}
    6.61 -	
    6.62 -	size_t i, c = 0;
    6.63 -	for (i = start; i < end; i++, c++)
    6.64 -	{
    6.65 -		if (c >= len1)
    6.66 -		{
    6.67 -			break;
    6.68 -		}
    6.69 -		buf1[c] = str[i];
    6.70 -	}
    6.71 -	buf1[c] = '\0';
    6.72 -
    6.73 -	for (start = end; start < len; start++)
    6.74 -	{
    6.75 -		if (!isspace(str[start]))
    6.76 -		{
    6.77 -			break;
    6.78 -		}
    6.79 -	}
    6.80 -
    6.81 -	for (c = 0; start < len; start++, c++)
    6.82 -	{
    6.83 -		if (c >= len2)
    6.84 -		{
    6.85 -			break;
    6.86 -		}
    6.87 -		buf2[c] = str[start];
    6.88 -	}
    6.89 -	buf2[c] = '\0';
    6.90 -}
    6.91 -
    6.92  bool UTIL_PathCmp(const char *path1, const char *path2)
    6.93  {
    6.94  	size_t pos1 = 0, pos2 = 0;
     7.1 --- a/core/metamod_util.h	Sun Nov 23 22:36:06 2008 -0600
     7.2 +++ b/core/metamod_util.h	Sun Nov 23 23:22:33 2008 -0600
     7.3 @@ -46,11 +46,6 @@
     7.4  const char *UTIL_GetExtension(const char *file);
     7.5  
     7.6  /**
     7.7 - * @brief Removes C-style comments from string.
     7.8 - */
     7.9 -void UTIL_TrimComments(char *buffer);
    7.10 -
    7.11 -/**
    7.12   * @brief Removes whitespace characters from left side of string.
    7.13   */
    7.14  void UTIL_TrimLeft(char *buffer);
    7.15 @@ -61,11 +56,6 @@
    7.16  void UTIL_TrimRight(char *buffer);
    7.17  
    7.18  /**
    7.19 - * @brief Breaks a string at the first space until it reaches a non-space.
    7.20 - */
    7.21 -void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
    7.22 -
    7.23 -/**
    7.24   * @brief Compares two file paths.
    7.25   */
    7.26  bool UTIL_PathCmp(const char *path1, const char *path2);
     8.1 --- a/core/msvc9/mm_core.vcproj	Sun Nov 23 22:36:06 2008 -0600
     8.2 +++ b/core/msvc9/mm_core.vcproj	Sun Nov 23 23:22:33 2008 -0600
     8.3 @@ -414,6 +414,10 @@
     8.4  					RelativePath="..\vsp_bridge.cpp"
     8.5  					>
     8.6  				</File>
     8.7 +				<File
     8.8 +					RelativePath="..\gamedll_bridge.cpp"
     8.9 +					>
    8.10 +				</File>
    8.11  			</Filter>
    8.12  			<Filter
    8.13  				Name="Header Files"
     9.1 --- a/core/provider/provider_ep2.cpp	Sun Nov 23 22:36:06 2008 -0600
     9.2 +++ b/core/provider/provider_ep2.cpp	Sun Nov 23 23:22:33 2008 -0600
     9.3 @@ -258,14 +258,6 @@
     9.4  	{
     9.5  		SourceHook::GetFuncInfo(&IServerGameDLL::GameInit, mfi);
     9.6  	}
     9.7 -	else if (hook == ProvidedHook_DLLShutdown)
     9.8 -	{
     9.9 -		SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
    9.10 -	}
    9.11 -	else if (hook == ProvidedHook_DLLInit)
    9.12 -	{
    9.13 -		SourceHook::GetFuncInfo(&IServerGameDLL::DLLInit, mfi);
    9.14 -	}
    9.15  
    9.16  	*pInfo = mfi;
    9.17  
    10.1 --- a/core/vsp_bridge.cpp	Sun Nov 23 22:36:06 2008 -0600
    10.2 +++ b/core/vsp_bridge.cpp	Sun Nov 23 23:22:33 2008 -0600
    10.3 @@ -47,7 +47,7 @@
    10.4  			gamedll_iface[15] = '0' + i;
    10.5  			if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface, NULL)) != NULL)
    10.6  			{
    10.7 -				g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, i);
    10.8 +				g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, i, false);
    10.9  				break;
   10.10  			}
   10.11  		}