sourcemm/sourcemm.cpp
changeset 287 0492209c065f
parent 282 7a237e9ea5a1
child 296 ba7337defd34
     1.1 --- a/sourcemm/sourcemm.cpp	Mon Feb 19 13:17:07 2007 +0000
     1.2 +++ b/sourcemm/sourcemm.cpp	Wed Feb 21 01:51:54 2007 +0000
     1.3 @@ -32,6 +32,7 @@
     1.4  SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
     1.5  SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
     1.6  SH_DECL_HOOK0(IServerGameDLL, GameInit, SH_NOATTRIB, false, bool);
     1.7 +
     1.8  bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals);
     1.9  bool DLLInit_Post(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals);
    1.10  void DLLShutdown_handler();
    1.11 @@ -50,7 +51,7 @@
    1.12  bool gParsedGameInfo = false;
    1.13  bool bGameInit = false;
    1.14  SourceHook::List<GameDllInfo *> gamedll_list;
    1.15 -SourceHook::CallClass<IServerGameDLL> *dllExec;
    1.16 +SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
    1.17  int g_GameDllVersion = 0;
    1.18  
    1.19  void ClearGamedllList();
    1.20 @@ -145,12 +146,21 @@
    1.21  	//Initialize our console hooks
    1.22  	ConCommandBaseMgr::OneTimeInit(static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor));
    1.23  
    1.24 +	g_GameDllPatch = SH_GET_CALLCLASS(g_GameDll.pGameDLL);
    1.25 +
    1.26  	if (!g_SmmAPI.CacheCmds())
    1.27  	{
    1.28  		LogMessage("[META] Warning: Failed to initialize Con_Printf.  Defaulting to Msg().");
    1.29  		LogMessage("[META] Warning: Console messages will not be redirected to rcon console.");
    1.30  	}
    1.31  
    1.32 +	if (!g_SmmAPI.CacheUserMessages())
    1.33 +	{
    1.34 +		/* Don't know of a mod that has stripped out user messages completely, 
    1.35 +			but perhaps should do something different here? */
    1.36 +		LogMessage("[META] Warning: Failed to get list of user messages.");
    1.37 +		LogMessage("[META] Warning: The 'meta game' command will not display user messages.");
    1.38 +	}
    1.39  
    1.40  	const char *pluginFile = g_Engine.icvar->GetCommandLineValue("mm_pluginsfile");
    1.41  	if (!pluginFile) 
    1.42 @@ -165,8 +175,6 @@
    1.43  
    1.44  	bInFirstLevel = true;
    1.45  
    1.46 -	dllExec = SH_GET_CALLCLASS(g_GameDll.pGameDLL);
    1.47 -
    1.48  	RETURN_META_VALUE(MRES_IGNORED, true);
    1.49  }
    1.50  
    1.51 @@ -184,7 +192,7 @@
    1.52  
    1.53  	bGameInit = true;
    1.54  
    1.55 -	return true;
    1.56 +	RETURN_META_VALUE(MRES_IGNORED, true);
    1.57  }
    1.58  
    1.59  bool DLLInit_Post(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals)
    1.60 @@ -524,10 +532,10 @@
    1.61  	g_SMConVarAccessor.MarkCommandsAsGameDLL();
    1.62  	g_SMConVarAccessor.UnregisterGameDLLCommands();
    1.63  
    1.64 -	SH_CALL(dllExec, &IServerGameDLL::DLLShutdown)();
    1.65 +	SH_CALL(g_GameDllPatch, &IServerGameDLL::DLLShutdown)();
    1.66  
    1.67 -	SH_RELEASE_CALLCLASS(dllExec);
    1.68 -	dllExec = NULL;
    1.69 +	SH_RELEASE_CALLCLASS(g_GameDllPatch);
    1.70 +	g_GameDllPatch = NULL;
    1.71  
    1.72  	g_SourceHook.CompleteShutdown();
    1.73  
    1.74 @@ -724,7 +732,7 @@
    1.75  
    1.76  bool LevelInit_handler(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
    1.77  {
    1.78 -	if (!g_SmmAPI.CacheSuccessful())
    1.79 +	if (!g_SmmAPI.CmdCacheSuccessful())
    1.80  	{
    1.81  		LogMessage("[META] Warning: Failed to initialize Con_Printf.  Defaulting to Msg().");
    1.82  		LogMessage("[META] Warning: Console messages will not be redirected to rcon console.");