core/sourcemod.cpp
author David Anderson <dvander@alliedmods.net>
Fri Dec 26 23:26:21 2008 -0500 (2008-12-26)
changeset 2474 1f4345fb0f75
parent 2411 8dfaa3d730b5
child 2545 9cb1a1fefc2c
permissions -rw-r--r--
Another gamedata cleanup sponsored by an r=pred (bug 3351).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 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 "LibrarySys.h"
    36 #include <sh_string.h>
    37 #include "PluginSys.h"
    38 #include "ShareSys.h"
    39 #include "CoreConfig.h"
    40 #include "Logger.h"
    41 #include "ExtensionSys.h"
    42 #include "AdminCache.h"
    43 #include "sm_stringutil.h"
    44 #include "PlayerManager.h"
    45 #include "Translator.h"
    46 #include "ForwardSys.h"
    47 #include "TimerSys.h"
    48 #include "GameConfigs.h"
    49 #include "DebugReporter.h"
    50 #include "Profiler.h"
    51 
    52 SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
    53 SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
    54 SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, false, bool);
    55 SH_DECL_HOOK1_void(IVEngineServer, ServerCommand, SH_NOATTRIB, false, const char *);
    56 
    57 SourceModBase g_SourceMod;
    58 
    59 ILibrary *g_pJIT = NULL;
    60 SourceHook::String g_BaseDir;
    61 ISourcePawnEngine *g_pSourcePawn = NULL;
    62 ISourcePawnEngine2 *g_pSourcePawn2 = NULL;
    63 IdentityToken_t *g_pCoreIdent = NULL;
    64 IForward *g_pOnMapEnd = NULL;
    65 bool g_Loaded = false;
    66 bool sm_show_debug_spew = false;
    67 
    68 typedef ISourcePawnEngine *(*GET_SP_V1)();
    69 typedef ISourcePawnEngine2 *(*GET_SP_V2)();
    70 typedef void (*NOTIFYSHUTDOWN)();
    71 
    72 void ShutdownJIT()
    73 {
    74 	NOTIFYSHUTDOWN notify = (NOTIFYSHUTDOWN)g_pJIT->GetSymbolAddress("NotifyShutdown");
    75 	if (notify)
    76 	{
    77 		notify();
    78 	}
    79 
    80 	if (g_pSourcePawn2 != NULL)
    81 	{
    82 		g_pSourcePawn2->Shutdown();
    83 	}
    84 
    85 	g_pJIT->CloseLibrary();
    86 }
    87 
    88 SourceModBase::SourceModBase()
    89 {
    90 	m_IsMapLoading = false;
    91 	m_ExecPluginReload = false;
    92 	m_GotBasePath = false;
    93 }
    94 
    95 ConfigResult SourceModBase::OnSourceModConfigChanged(const char *key, 
    96 									  const char *value, 
    97 									  ConfigSource source, 
    98 									  char *error, 
    99 									  size_t maxlength)
   100 {
   101 	if (strcasecmp(key, "BasePath") == 0)
   102 	{
   103 		if (source == ConfigSource_Console)
   104 		{
   105 			UTIL_Format(error, maxlength, "Cannot be set at runtime");
   106 			return ConfigResult_Reject;
   107 		}
   108 
   109 		if (!m_GotBasePath)
   110 		{
   111 			g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), value);
   112 			g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), value);
   113 
   114 			m_GotBasePath = true;
   115 		}
   116 
   117 		return ConfigResult_Accept;
   118 	}
   119 	else if (strcasecmp(key, "DebugSpew") == 0)
   120 	{
   121 		sm_show_debug_spew = (strcasecmp(value, "yes") == 0) ? true : false;
   122 
   123 		return ConfigResult_Accept;
   124 	}
   125 
   126 	return ConfigResult_Ignore;
   127 }
   128 
   129 bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late)
   130 {
   131 	const char *gamepath = g_SMAPI->GetBaseDir();
   132 
   133 	/* Store full path to game */
   134 	g_BaseDir.assign(gamepath);
   135 
   136 	/* Store name of game directory by itself */
   137 	size_t len = strlen(gamepath);
   138 	for (size_t i = len - 1; i >= 0; i--)
   139 	{
   140 		if (gamepath[i] == PLATFORM_SEP_CHAR)
   141 		{
   142 			strncopy(m_ModDir, &gamepath[++i], sizeof(m_ModDir));
   143 			break;
   144 		}
   145 	}
   146 
   147 	/* Initialize CoreConfig so we can get SourceMod base path properly - this basically parses core.cfg */
   148 	g_CoreConfig.Initialize();
   149 
   150 	/* This shouldn't happen, but can't hurt to be safe */
   151 	if (!g_LibSys.PathExists(m_SMBaseDir) || !m_GotBasePath)
   152 	{
   153 		g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/addons/sourcemod", g_BaseDir.c_str());
   154 		g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "addons/sourcemod");
   155 		m_GotBasePath = true;
   156 	}
   157 
   158 	/* Attempt to load the JIT! */
   159 	char file[PLATFORM_MAX_PATH];
   160 	char myerror[255];
   161 	g_SMAPI->PathFormat(file, sizeof(file), "%s/bin/sourcepawn.jit.x86.%s",
   162 		GetSourceModPath(),
   163 		PLATFORM_LIB_EXT
   164 		);
   165 
   166 	g_pJIT = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
   167 	if (!g_pJIT)
   168 	{
   169 		if (error && maxlength)
   170 		{
   171 			snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)", 
   172 				myerror,
   173 				PLATFORM_LIB_EXT);
   174 		}
   175 		return false;
   176 	}
   177 
   178 	GET_SP_V1 getv1 = (GET_SP_V1)g_pJIT->GetSymbolAddress("GetSourcePawnEngine1");
   179 	GET_SP_V2 getv2 = (GET_SP_V2)g_pJIT->GetSymbolAddress("GetSourcePawnEngine2");
   180 
   181 	if (getv1 == NULL)
   182 	{
   183 		if (error && maxlength)
   184 		{
   185 			snprintf(error, maxlength, "JIT is too old; upgrade SourceMod");
   186 		}
   187 		ShutdownJIT();
   188 		return false;
   189 	}
   190 	else if (getv2 == NULL)
   191 	{
   192 		if (error && maxlength)
   193 		{
   194 			snprintf(error, maxlength, "JIT is too old; upgrade SourceMod");
   195 		}
   196 		ShutdownJIT();
   197 		return false;
   198 	}
   199 
   200 	g_pSourcePawn = getv1();
   201 	g_pSourcePawn2 = getv2();
   202 
   203 	if (g_pSourcePawn2->GetAPIVersion() < 2)
   204 	{
   205 		g_pSourcePawn2 = NULL;
   206 		if (error && maxlength)
   207 		{
   208 			snprintf(error, maxlength, "JIT version is out of date");
   209 		}
   210 		return false;
   211 	}
   212 
   213 	if (!g_pSourcePawn2->Initialize())
   214 	{
   215 		g_pSourcePawn2 = NULL;
   216 		if (error && maxlength)
   217 		{
   218 			snprintf(error, maxlength, "JIT could not be initialized");
   219 		}
   220 		return false;
   221 	}
   222 
   223 	g_pSourcePawn2->SetDebugListener(&g_DbgReporter);
   224 	g_pSourcePawn2->SetProfiler(&g_Profiler);
   225 
   226 	/* Hook this now so we can detect startup without calling StartSourceMod() */
   227 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   228 
   229 	/* Only load if we're not late */
   230 	if (!late)
   231 	{
   232 		StartSourceMod(false);
   233 	}
   234 
   235 	return true;
   236 }
   237 
   238 void SourceModBase::StartSourceMod(bool late)
   239 {
   240 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   241 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   242 
   243 	enginePatch = SH_GET_CALLCLASS(engine);
   244 	gamedllPatch = SH_GET_CALLCLASS(gamedll);
   245 
   246 	g_ShareSys.Initialize();
   247 
   248 	/* Make the global core identity */
   249 	g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
   250 
   251 	/* Notify! */
   252 	SMGlobalClass *pBase = SMGlobalClass::head;
   253 	while (pBase)
   254 	{
   255 		pBase->OnSourceModStartup(false);
   256 		pBase = pBase->m_pGlobalClassNext;
   257 	}
   258 
   259 	/* Notify! */
   260 	pBase = SMGlobalClass::head;
   261 	while (pBase)
   262 	{
   263 		pBase->OnSourceModAllInitialized();
   264 		pBase = pBase->m_pGlobalClassNext;
   265 	}
   266 
   267 	/* Notify! */
   268 	pBase = SMGlobalClass::head;
   269 	while (pBase)
   270 	{
   271 		pBase->OnSourceModAllInitialized_Post();
   272 		pBase = pBase->m_pGlobalClassNext;
   273 	}
   274 
   275 	/* Add us now... */
   276 	g_ShareSys.AddInterface(NULL, this);
   277 
   278 	/* We're loaded! */
   279 	g_Loaded = true;
   280 
   281 	/* Initialize VSP stuff */
   282 	if (vsp_interface != NULL)
   283 	{
   284 		g_SourceMod_Core.OnVSPListening(vsp_interface);
   285 	}
   286 }
   287 
   288 static bool g_LevelEndBarrier = false;
   289 bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
   290 {
   291 	/* If we're not loaded... */
   292 	if (!g_Loaded)
   293 	{
   294 		/* Do all global initialization now */
   295 		StartSourceMod(true);
   296 	}
   297 
   298 	m_IsMapLoading = true;
   299 	m_ExecPluginReload = true;
   300 
   301 	/* Notify! */
   302 	SMGlobalClass *pBase = SMGlobalClass::head;
   303 	while (pBase)
   304 	{
   305 		pBase->OnSourceModLevelChange(pMapName);
   306 		pBase = pBase->m_pGlobalClassNext;
   307 	}
   308 
   309 	DoGlobalPluginLoads();
   310 
   311 	m_IsMapLoading = false;
   312 
   313 	/* Notify! */
   314 	pBase = SMGlobalClass::head;
   315 	while (pBase)
   316 	{
   317 		pBase->OnSourceModPluginsLoaded();
   318 		pBase = pBase->m_pGlobalClassNext;
   319 	}
   320 
   321 	if (!g_pOnMapEnd)
   322 	{
   323 		g_pOnMapEnd = g_Forwards.CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
   324 	}
   325 
   326 	g_LevelEndBarrier = true;
   327 
   328 	RETURN_META_VALUE(MRES_IGNORED, true);
   329 }
   330 
   331 void SourceModBase::LevelShutdown()
   332 {
   333 	if (g_LevelEndBarrier)
   334 	{
   335 		SMGlobalClass *next = SMGlobalClass::head;
   336 		while (next)
   337 		{
   338 			next->OnSourceModLevelEnd();
   339 			next = next->m_pGlobalClassNext;
   340 		}
   341 		
   342 		if (g_pOnMapEnd != NULL)
   343 		{
   344 			g_pOnMapEnd->Execute(NULL);
   345 		}
   346 
   347 		g_Timers.RemoveMapChangeTimers();
   348 
   349 		g_LevelEndBarrier = false;
   350 	}
   351 
   352 	g_OnMapStarted = false;
   353 
   354 	if (m_ExecPluginReload)
   355 	{
   356 		g_PluginSys.ReloadOrUnloadPlugins();
   357 		m_ExecPluginReload = false;
   358 	}
   359 }
   360 
   361 bool SourceModBase::IsMapLoading() const
   362 {
   363 	return m_IsMapLoading;
   364 }
   365 
   366 void SourceModBase::DoGlobalPluginLoads()
   367 {
   368 	char config_path[PLATFORM_MAX_PATH];
   369 	char plugins_path[PLATFORM_MAX_PATH];
   370 
   371 	BuildPath(Path_SM, config_path, 
   372 		sizeof(config_path),
   373 		"configs/plugin_settings.cfg");
   374 	BuildPath(Path_SM, plugins_path,
   375 		sizeof(plugins_path),
   376 		"plugins");
   377 
   378 	/* Load any auto extensions */
   379 	g_Extensions.TryAutoload();
   380 
   381 	/* Fire the extensions ready message */
   382 	g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);	
   383 
   384 	/* Load any game extension */
   385 	const char *game_ext;
   386 	if ((game_ext = g_pGameConf->GetKeyValue("GameExtension")) != NULL)
   387 	{
   388 		char path[PLATFORM_MAX_PATH];
   389 		UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext);
   390 		g_Extensions.LoadAutoExtension(path);
   391 	}
   392 
   393 	/* Run the first pass */
   394 	g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
   395 
   396 	/* Mark any extensions as loaded */
   397 	g_Extensions.MarkAllLoaded();
   398 
   399 	/* No modules yet, it's safe to call this from here */
   400 	g_PluginSys.LoadAll_SecondPass();
   401 
   402 	/* Re-mark any extensions as loaded */
   403 	g_Extensions.MarkAllLoaded();
   404 
   405 	/* Call OnAllPluginsLoaded */
   406 	g_PluginSys.AllPluginsLoaded();
   407 }
   408 
   409 size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...)
   410 {
   411 	char _buffer[PLATFORM_MAX_PATH];
   412 	va_list ap;
   413 
   414 	va_start(ap, format);
   415 	vsnprintf(_buffer, PLATFORM_MAX_PATH, format, ap);
   416 	va_end(ap);
   417 
   418 	/* If we get a "file://" notation, strip off the file:// part so we're left 
   419 	 * with an absolute path.  Note that the absolute path gets returned, so 
   420 	 * usage with relative paths here is completely invalid.
   421 	 */
   422 	if (type != Path_SM_Rel && strncmp(_buffer, "file://", 7) == 0)
   423 	{
   424 		return g_LibSys.PathFormat(buffer, maxlength, "%s", &_buffer[7]);
   425 	}
   426 
   427 	const char *base = NULL;
   428 	if (type == Path_Game)
   429 	{
   430 		base = GetGamePath();
   431 	}
   432 	else if (type == Path_SM)
   433 	{
   434 		base = GetSourceModPath();
   435 	}
   436 	else if (type == Path_SM_Rel)
   437 	{
   438 		base = m_SMRelDir;
   439 	}
   440 
   441 	if (base)
   442 	{
   443 		return g_LibSys.PathFormat(buffer, maxlength, "%s/%s", base, _buffer);
   444 	}
   445 	else
   446 	{
   447 		return g_LibSys.PathFormat(buffer, maxlength, "%s", _buffer);
   448 	}
   449 }
   450 
   451 void SourceModBase::CloseSourceMod()
   452 {
   453 	/* Force a level end */
   454 	LevelShutdown();
   455 
   456 	/* Unload plugins */
   457 	g_PluginSys.Shutdown();
   458 
   459 	/* Unload extensions */
   460 	g_Extensions.Shutdown();
   461 
   462 	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   463 
   464 	if (g_Loaded)
   465 	{
   466 		if (g_pOnMapEnd)
   467 		{
   468 			g_Forwards.ReleaseForward(g_pOnMapEnd);
   469 		}
   470 	
   471 		/* Notify! */
   472 		SMGlobalClass *pBase = SMGlobalClass::head;
   473 		while (pBase)
   474 		{
   475 			pBase->OnSourceModShutdown();
   476 			pBase = pBase->m_pGlobalClassNext;
   477 		}
   478 	
   479 		/* Delete all data packs */
   480 		CStack<CDataPack *>::iterator iter;
   481 		CDataPack *pd;
   482 		for (iter=m_freepacks.begin(); iter!=m_freepacks.end(); iter++)
   483 		{
   484 			pd = (*iter);
   485 			delete pd;
   486 		}
   487 		m_freepacks.popall();
   488 	
   489 		/* Notify! */
   490 		pBase = SMGlobalClass::head;
   491 		while (pBase)
   492 		{
   493 			pBase->OnSourceModAllShutdown();
   494 			pBase = pBase->m_pGlobalClassNext;
   495 		}
   496 	
   497 		if (enginePatch)
   498 		{
   499 			SH_RELEASE_CALLCLASS(enginePatch);
   500 			enginePatch = NULL;
   501 		}
   502 	
   503 		if (gamedllPatch)
   504 		{
   505 			SH_RELEASE_CALLCLASS(gamedllPatch);
   506 			gamedllPatch = NULL;
   507 		}
   508 
   509 		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   510 		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   511 	}
   512 
   513 	/* Rest In Peace */
   514 	ShutdownJIT();
   515 }
   516 
   517 void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
   518 {
   519 	IExtensionInterface *pAPI = pExt->GetAPI();
   520 	const char *tag = pAPI->GetExtensionTag();
   521 	char buffer[2048];
   522 	va_list ap;
   523 
   524 	va_start(ap, format);
   525 	vsnprintf(buffer, sizeof(buffer), format, ap);
   526 	va_end(ap);
   527 
   528 	if (tag)
   529 	{
   530 		g_Logger.LogMessage("[%s] %s", tag, buffer);
   531 	} else {
   532 		g_Logger.LogMessage("%s", buffer);
   533 	}
   534 }
   535 
   536 void SourceModBase::LogError(IExtension *pExt, const char *format, ...)
   537 {
   538 	IExtensionInterface *pAPI = pExt->GetAPI();
   539 	const char *tag = pAPI->GetExtensionTag();
   540 	char buffer[2048];
   541 	va_list ap;
   542 
   543 	va_start(ap, format);
   544 	vsnprintf(buffer, sizeof(buffer), format, ap);
   545 	va_end(ap);
   546 
   547 	if (tag)
   548 	{
   549 		g_Logger.LogError("[%s] %s", tag, buffer);
   550 	} else {
   551 		g_Logger.LogError("%s", buffer);
   552 	}
   553 }
   554 
   555 size_t SourceModBase::FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param)
   556 {
   557 	char *fmt;
   558 
   559 	pContext->LocalToString(params[param], &fmt);
   560 
   561 	int lparam = ++param;
   562 
   563 	return atcprintf(buffer, maxlength, fmt, pContext, params, &lparam);
   564 }
   565 
   566 const char *SourceModBase::GetSourceModPath() const
   567 {
   568 	return m_SMBaseDir;
   569 }
   570 
   571 const char *SourceModBase::GetGamePath() const
   572 {
   573 	return g_BaseDir.c_str();
   574 }
   575 
   576 unsigned int SourceModBase::SetGlobalTarget(unsigned int index)
   577 {
   578 	unsigned int old = m_target;
   579 	m_target = index;
   580 	return old;
   581 }
   582 
   583 unsigned int SourceModBase::GetGlobalTarget() const
   584 {
   585 	return m_target;
   586 }
   587 
   588 IDataPack *SourceModBase::CreateDataPack()
   589 {
   590 	CDataPack *pack;
   591 	if (m_freepacks.empty())
   592 	{
   593 		pack = new CDataPack;
   594 	} else {
   595 		pack = m_freepacks.front();
   596 		m_freepacks.pop();
   597 		pack->Initialize();
   598 	}
   599 	return pack;
   600 }
   601 
   602 void SourceModBase::FreeDataPack(IDataPack *pack)
   603 {
   604 	m_freepacks.push(static_cast<CDataPack *>(pack));
   605 }
   606 
   607 Handle_t SourceModBase::GetDataPackHandleType(bool readonly)
   608 {
   609 	//:TODO:
   610 	return 0;
   611 }
   612 
   613 const char *SourceModBase::GetGameFolderName() const
   614 {
   615 	return m_ModDir;
   616 }
   617 
   618 ISourcePawnEngine *SourceModBase::GetScriptingEngine()
   619 {
   620 	return g_pSourcePawn;
   621 }
   622 
   623 IVirtualMachine *SourceModBase::GetScriptingVM()
   624 {
   625 	return NULL;
   626 }
   627 
   628 void SourceModBase::AllPluginsLoaded()
   629 {
   630 	SMGlobalClass *base = SMGlobalClass::head;
   631 	while (base)
   632 	{
   633 		base->OnSourceModGameInitialized();
   634 		base = base->m_pGlobalClassNext;
   635 	}
   636 }
   637 
   638 time_t SourceModBase::GetAdjustedTime()
   639 {
   640 	return ::GetAdjustedTime();
   641 }
   642 
   643 void SourceModBase::AddGameFrameHook(GAME_FRAME_HOOK hook)
   644 {
   645 	m_frame_hooks.push_back(hook);
   646 }
   647 
   648 void SourceModBase::RemoveGameFrameHook(GAME_FRAME_HOOK hook)
   649 {
   650 	for (size_t i = 0; i < m_frame_hooks.size(); i++)
   651 	{
   652 		if (m_frame_hooks[i] == hook)
   653 		{
   654 			m_frame_hooks.erase(m_frame_hooks.iterAt(i));
   655 			return;
   656 		}
   657 	}
   658 }
   659 
   660 void SourceModBase::ProcessGameFrameHooks(bool simulating)
   661 {
   662 	if (m_frame_hooks.size() == 0)
   663 	{
   664 		return;
   665 	}
   666 
   667 	for (size_t i = 0; i < m_frame_hooks.size(); i++)
   668 	{
   669 		m_frame_hooks[i](simulating);
   670 	}
   671 }
   672 
   673 SMGlobalClass *SMGlobalClass::head = NULL;
   674 
   675 SMGlobalClass::SMGlobalClass()
   676 {
   677 	m_pGlobalClassNext = SMGlobalClass::head;
   678 	SMGlobalClass::head = this;
   679 }