core/sourcemod.cpp
author Scott Ehlert <ds@alliedmods.net>
Fri Mar 28 06:21:34 2008 +0000 (2008-03-28)
branchsourcemod-1.1.0
changeset 1951 c7b4237fff50
parent 1715 f9ecab642e25
child 1721 d54c379f7171
permissions -rw-r--r--
Changed env var used in include paths: SOURCEMM -> SORCEMM16
Removed some unneccessary build configuartations in some project files
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include <stdio.h>
    33 #include "sourcemod.h"
    34 #include "sourcemm_api.h"
    35 #include "systems/LibrarySys.h"
    36 #include "vm/sp_vm_engine.h"
    37 #include <sh_string.h>
    38 #include "PluginSys.h"
    39 #include "ShareSys.h"
    40 #include "CoreConfig.h"
    41 #include "Logger.h"
    42 #include "ExtensionSys.h"
    43 #include "AdminCache.h"
    44 #include "sm_stringutil.h"
    45 #include "PlayerManager.h"
    46 #include "Translator.h"
    47 #include "ForwardSys.h"
    48 #include "TimerSys.h"
    49 #include "GameConfigs.h"
    50 
    51 SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
    52 SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
    53 SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, false, bool);
    54 SH_DECL_HOOK1_void(IVEngineServer, ServerCommand, SH_NOATTRIB, false, const char *);
    55 
    56 SourcePawnEngine g_SourcePawn;
    57 SourceModBase g_SourceMod;
    58 
    59 ILibrary *g_pJIT = NULL;
    60 SourceHook::String g_BaseDir;
    61 ISourcePawnEngine *g_pSourcePawn = &g_SourcePawn;
    62 IVirtualMachine *g_pVM;
    63 IdentityToken_t *g_pCoreIdent = NULL;
    64 IForward *g_pOnMapEnd = NULL;
    65 bool g_Loaded = false;
    66 
    67 typedef int (*GIVEENGINEPOINTER)(ISourcePawnEngine *);
    68 typedef int (*GIVEENGINEPOINTER2)(ISourcePawnEngine *, unsigned int api_version);
    69 typedef unsigned int (*GETEXPORTCOUNT)();
    70 typedef IVirtualMachine *(*GETEXPORT)(unsigned int);
    71 typedef void (*NOTIFYSHUTDOWN)();
    72 
    73 void ShutdownJIT()
    74 {
    75 	NOTIFYSHUTDOWN notify = (NOTIFYSHUTDOWN)g_pJIT->GetSymbolAddress("NotifyShutdown");
    76 	if (notify)
    77 	{
    78 		notify();
    79 	}
    80 
    81 	g_pJIT->CloseLibrary();
    82 }
    83 
    84 SourceModBase::SourceModBase()
    85 {
    86 	m_IsMapLoading = false;
    87 	m_ExecPluginReload = false;
    88 	m_ExecOnMapEnd = false;
    89 	m_GotBasePath = false;
    90 }
    91 
    92 ConfigResult SourceModBase::OnSourceModConfigChanged(const char *key, 
    93 									  const char *value, 
    94 									  ConfigSource source, 
    95 									  char *error, 
    96 									  size_t maxlength)
    97 {
    98 	if (strcasecmp(key, "BasePath") == 0)
    99 	{
   100 		if (source == ConfigSource_Console)
   101 		{
   102 			UTIL_Format(error, maxlength, "Cannot be set at runtime");
   103 			return ConfigResult_Reject;
   104 		}
   105 
   106 		if (!m_GotBasePath)
   107 		{
   108 			g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), value);
   109 			g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), value);
   110 
   111 			m_GotBasePath = true;
   112 		}
   113 
   114 		return ConfigResult_Accept;
   115 	}
   116 
   117 	return ConfigResult_Ignore;
   118 }
   119 
   120 bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late)
   121 {
   122 	const char *gamepath = g_SMAPI->GetBaseDir();
   123 
   124 	/* Store full path to game */
   125 	g_BaseDir.assign(gamepath);
   126 
   127 	/* Store name of game directory by itself */
   128 	size_t len = strlen(gamepath);
   129 	for (size_t i = len - 1; i >= 0; i--)
   130 	{
   131 		if (gamepath[i] == PLATFORM_SEP_CHAR)
   132 		{
   133 			strncopy(m_ModDir, &gamepath[++i], sizeof(m_ModDir));
   134 			break;
   135 		}
   136 	}
   137 
   138 	/* Initialize CoreConfig so we can get SourceMod base path properly - this basically parses core.cfg */
   139 	g_CoreConfig.Initialize();
   140 
   141 	/* This shouldn't happen, but can't hurt to be safe */
   142 	if (!g_LibSys.PathExists(m_SMBaseDir) || !m_GotBasePath)
   143 	{
   144 		g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/addons/sourcemod", g_BaseDir.c_str());
   145 		g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "addons/sourcemod");
   146 		m_GotBasePath = true;
   147 	}
   148 
   149 	/* Attempt to load the JIT! */
   150 	char file[PLATFORM_MAX_PATH];
   151 	char myerror[255];
   152 	g_SMAPI->PathFormat(file, sizeof(file), "%s/bin/sourcepawn.jit.x86.%s",
   153 		GetSourceModPath(),
   154 		PLATFORM_LIB_EXT
   155 		);
   156 
   157 	g_pJIT = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
   158 	if (!g_pJIT)
   159 	{
   160 		if (error && maxlength)
   161 		{
   162 			snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)", 
   163 				myerror,
   164 				PLATFORM_LIB_EXT);
   165 		}
   166 		return false;
   167 	}
   168 
   169 	int err;
   170 	
   171 	GIVEENGINEPOINTER2 jit_init2 = (GIVEENGINEPOINTER2)g_pJIT->GetSymbolAddress("GiveEnginePointer2");
   172 	if (!jit_init2)
   173 	{
   174 		GIVEENGINEPOINTER jit_init = (GIVEENGINEPOINTER)g_pJIT->GetSymbolAddress("GiveEnginePointer");
   175 		if (!jit_init)
   176 		{
   177 			ShutdownJIT();
   178 			if (error && maxlength)
   179 			{
   180 				snprintf(error, maxlength, "Failed to find GiveEnginePointer in JIT!");
   181 			}
   182 			return false;
   183 		}
   184 
   185 		if ((err=jit_init(g_pSourcePawn)) != 0)
   186 		{
   187 			ShutdownJIT();
   188 			if (error && maxlength)
   189 			{
   190 				snprintf(error, maxlength, "GiveEnginePointer returned %d in the JIT", err);
   191 			}
   192 			return false;
   193 		}
   194 	} else {
   195 		/* On version bumps, we should check for older versions as well, if the new version fails.
   196 		 * We can then check the exports to see if any VM versions will be sufficient.
   197 		 */
   198 		if ((err=jit_init2(g_pSourcePawn, SOURCEPAWN_ENGINE_API_VERSION)) != SP_ERROR_NONE)
   199 		{
   200 			ShutdownJIT();
   201 			if (error && maxlength)
   202 			{
   203 				snprintf(error, maxlength, "JIT incompatible with SourceMod version");
   204 			}
   205 			return false;
   206 		}
   207 	}
   208 
   209 	GETEXPORTCOUNT jit_getnum = (GETEXPORTCOUNT)g_pJIT->GetSymbolAddress("GetExportCount");
   210 	GETEXPORT jit_get = (GETEXPORT)g_pJIT->GetSymbolAddress("GetExport");
   211 	if (!jit_get)
   212 	{
   213 		ShutdownJIT();
   214 		if (error && maxlength)
   215 		{
   216 			snprintf(error, maxlength, "JIT is missing a necessary export!");
   217 		}
   218 		return false;
   219 	}
   220 
   221 	unsigned int num = jit_getnum();
   222 	if (!num)
   223 	{
   224 		ShutdownJIT();
   225 		if (error && maxlength)
   226 		{
   227 			snprintf(error, maxlength, "JIT did not export any virtual machines!");
   228 		}
   229 		return false;
   230 	}
   231 
   232 	unsigned int api_version;
   233 	for (unsigned int i=0; i<num; i++)
   234 	{
   235 		 if ((g_pVM=jit_get(i)) == NULL)
   236 		 {
   237 			 if (error && maxlength)
   238 			 {
   239 				 snprintf(error, maxlength, "JIT did not export any virtual machines!");
   240 			 }
   241 			 continue;
   242 		 }
   243 		/* Refuse any API that we might not be able to deal with.
   244 		 * Also refuse anything < 3 because we need fake natives.
   245 		 */
   246 		 api_version = g_pVM->GetAPIVersion();
   247 		 if (api_version < 3 || api_version > SOURCEPAWN_VM_API_VERSION)
   248 		 {
   249 			 if (error && maxlength)
   250 			 {
   251 				 snprintf(error, maxlength, "JIT is not a compatible version");
   252 			 }
   253 			 g_pVM = NULL;
   254 			 continue;
   255 		 }
   256 		 break;
   257 	}
   258 
   259 	if (!g_pVM)
   260 	{
   261 		ShutdownJIT();
   262 		return false;
   263 	}
   264 
   265 	/* Hook this now so we can detect startup without calling StartSourceMod() */
   266 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   267 
   268 	/* Only load if we're not late */
   269 	if (!late)
   270 	{
   271 		StartSourceMod(false);
   272 	}
   273 
   274 	return true;
   275 }
   276 
   277 void SourceModBase::StartSourceMod(bool late)
   278 {
   279 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   280 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   281 
   282 	enginePatch = SH_GET_CALLCLASS(engine);
   283 	gamedllPatch = SH_GET_CALLCLASS(gamedll);
   284 
   285 	/* Notify! */
   286 	SMGlobalClass *pBase = SMGlobalClass::head;
   287 	while (pBase)
   288 	{
   289 		pBase->OnSourceModStartup(false);
   290 		pBase = pBase->m_pGlobalClassNext;
   291 	}
   292 
   293 	/* Make the global core identity */
   294 	g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
   295 
   296 	/* Notify! */
   297 	pBase = SMGlobalClass::head;
   298 	while (pBase)
   299 	{
   300 		pBase->OnSourceModAllInitialized();
   301 		pBase = pBase->m_pGlobalClassNext;
   302 	}
   303 
   304 	/* Add us now... */
   305 	g_ShareSys.AddInterface(NULL, this);
   306 
   307 	/* We're loaded! */
   308 	g_Loaded = true;
   309 
   310 	/* Initialize VSP stuff */
   311 	if (vsp_interface != NULL)
   312 	{
   313 		g_SourceMod_Core.OnVSPListening(vsp_interface);
   314 	}
   315 }
   316 
   317 static bool g_LevelEndBarrier = false;
   318 bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
   319 {
   320 	/* If we're not loaded... */
   321 	if (!g_Loaded)
   322 	{
   323 		/* Do all global initialization now */
   324 		StartSourceMod(true);
   325 	}
   326 
   327 	m_IsMapLoading = true;
   328 	m_ExecPluginReload = true;
   329 	m_ExecOnMapEnd = true;
   330 
   331 	/* Notify! */
   332 	SMGlobalClass *pBase = SMGlobalClass::head;
   333 	while (pBase)
   334 	{
   335 		pBase->OnSourceModLevelChange(pMapName);
   336 		pBase = pBase->m_pGlobalClassNext;
   337 	}
   338 
   339 	DoGlobalPluginLoads();
   340 
   341 	m_IsMapLoading = false;
   342 
   343 	/* Notify! */
   344 	pBase = SMGlobalClass::head;
   345 	while (pBase)
   346 	{
   347 		pBase->OnSourceModPluginsLoaded();
   348 		pBase = pBase->m_pGlobalClassNext;
   349 	}
   350 
   351 	if (!g_pOnMapEnd)
   352 	{
   353 		g_pOnMapEnd = g_Forwards.CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
   354 	}
   355 
   356 	g_LevelEndBarrier = true;
   357 
   358 	RETURN_META_VALUE(MRES_IGNORED, true);
   359 }
   360 
   361 void SourceModBase::LevelShutdown()
   362 {
   363 	if (g_LevelEndBarrier)
   364 	{
   365 		SMGlobalClass *next = SMGlobalClass::head;
   366 		while (next)
   367 		{
   368 			next->OnSourceModLevelEnd();
   369 			next = next->m_pGlobalClassNext;
   370 		}
   371 		g_LevelEndBarrier = false;
   372 	}
   373 
   374 	if (g_pOnMapEnd && m_ExecOnMapEnd)
   375 	{
   376 		g_pOnMapEnd->Execute(NULL);
   377 		m_ExecOnMapEnd = false;
   378 	}
   379 
   380 	g_OnMapStarted = false;
   381 
   382 	if (m_ExecPluginReload)
   383 	{
   384 		g_PluginSys.ReloadOrUnloadPlugins();
   385 		m_ExecPluginReload = false;
   386 	}
   387 }
   388 
   389 bool SourceModBase::IsMapLoading() const
   390 {
   391 	return m_IsMapLoading;
   392 }
   393 
   394 void SourceModBase::DoGlobalPluginLoads()
   395 {
   396 	char config_path[PLATFORM_MAX_PATH];
   397 	char plugins_path[PLATFORM_MAX_PATH];
   398 
   399 	BuildPath(Path_SM, config_path, 
   400 		sizeof(config_path),
   401 		"configs/plugin_settings.cfg");
   402 	BuildPath(Path_SM, plugins_path,
   403 		sizeof(plugins_path),
   404 		"plugins");
   405 
   406 	/* Load any auto extensions */
   407 	g_Extensions.TryAutoload();
   408 
   409 	/* Fire the extensions ready message */
   410 	g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);	
   411 
   412 	/* Load any game extension */
   413 	const char *game_ext;
   414 	if ((game_ext = g_pGameConf->GetKeyValue("GameExtension")) != NULL)
   415 	{
   416 		char path[PLATFORM_MAX_PATH];
   417 		UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext);
   418 		g_Extensions.LoadAutoExtension(path);
   419 	}
   420 
   421 	/* Run the first pass */
   422 	g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
   423 
   424 	/* Mark any extensions as loaded */
   425 	g_Extensions.MarkAllLoaded();
   426 
   427 	/* No modules yet, it's safe to call this from here */
   428 	g_PluginSys.LoadAll_SecondPass();
   429 
   430 	/* Re-mark any extensions as loaded */
   431 	g_Extensions.MarkAllLoaded();
   432 
   433 	/* Call OnAllPluginsLoaded */
   434 	g_PluginSys.AllPluginsLoaded();
   435 }
   436 
   437 size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...)
   438 {
   439 	char _buffer[PLATFORM_MAX_PATH];
   440 	va_list ap;
   441 
   442 	va_start(ap, format);
   443 	vsnprintf(_buffer, PLATFORM_MAX_PATH, format, ap);
   444 	va_end(ap);
   445 
   446 	const char *base = NULL;
   447 	if (type == Path_Game)
   448 	{
   449 		base = GetGamePath();
   450 	} else if (type == Path_SM) {
   451 		base = GetSourceModPath();
   452 	} else if (type == Path_SM_Rel) {
   453 		base = m_SMRelDir;
   454 	}
   455 
   456 	if (base)
   457 	{
   458 		return g_LibSys.PathFormat(buffer, maxlength, "%s/%s", base, _buffer);
   459 	} else {
   460 		return g_LibSys.PathFormat(buffer, maxlength, "%s", _buffer);
   461 	}
   462 }
   463 
   464 void SourceModBase::CloseSourceMod()
   465 {
   466 	/* Force a level end */
   467 	LevelShutdown();
   468 
   469 	/* Unload plugins */
   470 	g_PluginSys.Shutdown();
   471 
   472 	/* Unload extensions */
   473 	g_Extensions.Shutdown();
   474 
   475 	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   476 
   477 	if (g_Loaded)
   478 	{
   479 		if (g_pOnMapEnd)
   480 		{
   481 			g_Forwards.ReleaseForward(g_pOnMapEnd);
   482 		}
   483 	
   484 		/* Notify! */
   485 		SMGlobalClass *pBase = SMGlobalClass::head;
   486 		while (pBase)
   487 		{
   488 			pBase->OnSourceModShutdown();
   489 			pBase = pBase->m_pGlobalClassNext;
   490 		}
   491 	
   492 		/* Delete all data packs */
   493 		CStack<CDataPack *>::iterator iter;
   494 		CDataPack *pd;
   495 		for (iter=m_freepacks.begin(); iter!=m_freepacks.end(); iter++)
   496 		{
   497 			pd = (*iter);
   498 			delete pd;
   499 		}
   500 		m_freepacks.popall();
   501 	
   502 		/* Notify! */
   503 		pBase = SMGlobalClass::head;
   504 		while (pBase)
   505 		{
   506 			pBase->OnSourceModAllShutdown();
   507 			pBase = pBase->m_pGlobalClassNext;
   508 		}
   509 	
   510 		if (enginePatch)
   511 		{
   512 			SH_RELEASE_CALLCLASS(enginePatch);
   513 			enginePatch = NULL;
   514 		}
   515 	
   516 		if (gamedllPatch)
   517 		{
   518 			SH_RELEASE_CALLCLASS(gamedllPatch);
   519 			gamedllPatch = NULL;
   520 		}
   521 
   522 		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   523 		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   524 	}
   525 
   526 	/* Rest In Peace */
   527 	ShutdownJIT();
   528 }
   529 
   530 void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
   531 {
   532 	IExtensionInterface *pAPI = pExt->GetAPI();
   533 	const char *tag = pAPI->GetExtensionTag();
   534 	char buffer[2048];
   535 	va_list ap;
   536 
   537 	va_start(ap, format);
   538 	vsnprintf(buffer, sizeof(buffer), format, ap);
   539 	va_end(ap);
   540 
   541 	if (tag)
   542 	{
   543 		g_Logger.LogMessage("[%s] %s", tag, buffer);
   544 	} else {
   545 		g_Logger.LogMessage("%s", buffer);
   546 	}
   547 }
   548 
   549 void SourceModBase::LogError(IExtension *pExt, const char *format, ...)
   550 {
   551 	IExtensionInterface *pAPI = pExt->GetAPI();
   552 	const char *tag = pAPI->GetExtensionTag();
   553 	char buffer[2048];
   554 	va_list ap;
   555 
   556 	va_start(ap, format);
   557 	vsnprintf(buffer, sizeof(buffer), format, ap);
   558 	va_end(ap);
   559 
   560 	if (tag)
   561 	{
   562 		g_Logger.LogError("[%s] %s", tag, buffer);
   563 	} else {
   564 		g_Logger.LogError("%s", buffer);
   565 	}
   566 }
   567 
   568 size_t SourceModBase::FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param)
   569 {
   570 	char *fmt;
   571 
   572 	pContext->LocalToString(params[param], &fmt);
   573 
   574 	int lparam = ++param;
   575 
   576 	return atcprintf(buffer, maxlength, fmt, pContext, params, &lparam);
   577 }
   578 
   579 const char *SourceModBase::GetSourceModPath() const
   580 {
   581 	return m_SMBaseDir;
   582 }
   583 
   584 const char *SourceModBase::GetGamePath() const
   585 {
   586 	return g_BaseDir.c_str();
   587 }
   588 
   589 unsigned int SourceModBase::SetGlobalTarget(unsigned int index)
   590 {
   591 	unsigned int old = m_target;
   592 	m_target = index;
   593 	return old;
   594 }
   595 
   596 unsigned int SourceModBase::GetGlobalTarget() const
   597 {
   598 	return m_target;
   599 }
   600 
   601 IDataPack *SourceModBase::CreateDataPack()
   602 {
   603 	CDataPack *pack;
   604 	if (m_freepacks.empty())
   605 	{
   606 		pack = new CDataPack;
   607 	} else {
   608 		pack = m_freepacks.front();
   609 		m_freepacks.pop();
   610 		pack->Initialize();
   611 	}
   612 	return pack;
   613 }
   614 
   615 void SourceModBase::FreeDataPack(IDataPack *pack)
   616 {
   617 	m_freepacks.push(static_cast<CDataPack *>(pack));
   618 }
   619 
   620 Handle_t SourceModBase::GetDataPackHandleType(bool readonly)
   621 {
   622 	//:TODO:
   623 	return 0;
   624 }
   625 
   626 const char *SourceModBase::GetGameFolderName() const
   627 {
   628 	return m_ModDir;
   629 }
   630 
   631 ISourcePawnEngine *SourceModBase::GetScriptingEngine()
   632 {
   633 	return g_pSourcePawn;
   634 }
   635 
   636 IVirtualMachine *SourceModBase::GetScriptingVM()
   637 {
   638 	return g_pVM;
   639 }
   640 
   641 void SourceModBase::AllPluginsLoaded()
   642 {
   643 	SMGlobalClass *base = SMGlobalClass::head;
   644 	while (base)
   645 	{
   646 		base->OnSourceModGameInitialized();
   647 		base = base->m_pGlobalClassNext;
   648 	}
   649 }
   650 
   651 time_t SourceModBase::GetAdjustedTime()
   652 {
   653 	return GetAdjustedTime();
   654 }
   655 
   656 SMGlobalClass *SMGlobalClass::head = NULL;
   657 
   658 SMGlobalClass::SMGlobalClass()
   659 {
   660 	m_pGlobalClassNext = SMGlobalClass::head;
   661 	SMGlobalClass::head = this;
   662 }