core/sourcemod.cpp
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/core/sourcemod.cpp	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,662 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod
     1.8 - * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#include <stdio.h>
    1.36 -#include "sourcemod.h"
    1.37 -#include "sourcemm_api.h"
    1.38 -#include "systems/LibrarySys.h"
    1.39 -#include "vm/sp_vm_engine.h"
    1.40 -#include <sh_string.h>
    1.41 -#include "PluginSys.h"
    1.42 -#include "ShareSys.h"
    1.43 -#include "CoreConfig.h"
    1.44 -#include "Logger.h"
    1.45 -#include "ExtensionSys.h"
    1.46 -#include "AdminCache.h"
    1.47 -#include "sm_stringutil.h"
    1.48 -#include "PlayerManager.h"
    1.49 -#include "Translator.h"
    1.50 -#include "ForwardSys.h"
    1.51 -#include "TimerSys.h"
    1.52 -#include "GameConfigs.h"
    1.53 -
    1.54 -SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
    1.55 -SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
    1.56 -SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, false, bool);
    1.57 -SH_DECL_HOOK1_void(IVEngineServer, ServerCommand, SH_NOATTRIB, false, const char *);
    1.58 -
    1.59 -SourcePawnEngine g_SourcePawn;
    1.60 -SourceModBase g_SourceMod;
    1.61 -
    1.62 -ILibrary *g_pJIT = NULL;
    1.63 -SourceHook::String g_BaseDir;
    1.64 -ISourcePawnEngine *g_pSourcePawn = &g_SourcePawn;
    1.65 -IVirtualMachine *g_pVM;
    1.66 -IdentityToken_t *g_pCoreIdent = NULL;
    1.67 -IForward *g_pOnMapEnd = NULL;
    1.68 -bool g_Loaded = false;
    1.69 -
    1.70 -typedef int (*GIVEENGINEPOINTER)(ISourcePawnEngine *);
    1.71 -typedef int (*GIVEENGINEPOINTER2)(ISourcePawnEngine *, unsigned int api_version);
    1.72 -typedef unsigned int (*GETEXPORTCOUNT)();
    1.73 -typedef IVirtualMachine *(*GETEXPORT)(unsigned int);
    1.74 -typedef void (*NOTIFYSHUTDOWN)();
    1.75 -
    1.76 -void ShutdownJIT()
    1.77 -{
    1.78 -	NOTIFYSHUTDOWN notify = (NOTIFYSHUTDOWN)g_pJIT->GetSymbolAddress("NotifyShutdown");
    1.79 -	if (notify)
    1.80 -	{
    1.81 -		notify();
    1.82 -	}
    1.83 -
    1.84 -	g_pJIT->CloseLibrary();
    1.85 -}
    1.86 -
    1.87 -SourceModBase::SourceModBase()
    1.88 -{
    1.89 -	m_IsMapLoading = false;
    1.90 -	m_ExecPluginReload = false;
    1.91 -	m_ExecOnMapEnd = false;
    1.92 -	m_GotBasePath = false;
    1.93 -}
    1.94 -
    1.95 -ConfigResult SourceModBase::OnSourceModConfigChanged(const char *key, 
    1.96 -									  const char *value, 
    1.97 -									  ConfigSource source, 
    1.98 -									  char *error, 
    1.99 -									  size_t maxlength)
   1.100 -{
   1.101 -	if (strcasecmp(key, "BasePath") == 0)
   1.102 -	{
   1.103 -		if (source == ConfigSource_Console)
   1.104 -		{
   1.105 -			UTIL_Format(error, maxlength, "Cannot be set at runtime");
   1.106 -			return ConfigResult_Reject;
   1.107 -		}
   1.108 -
   1.109 -		if (!m_GotBasePath)
   1.110 -		{
   1.111 -			g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/%s", g_BaseDir.c_str(), value);
   1.112 -			g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), value);
   1.113 -
   1.114 -			m_GotBasePath = true;
   1.115 -		}
   1.116 -
   1.117 -		return ConfigResult_Accept;
   1.118 -	}
   1.119 -
   1.120 -	return ConfigResult_Ignore;
   1.121 -}
   1.122 -
   1.123 -bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late)
   1.124 -{
   1.125 -	const char *gamepath = g_SMAPI->GetBaseDir();
   1.126 -
   1.127 -	/* Store full path to game */
   1.128 -	g_BaseDir.assign(gamepath);
   1.129 -
   1.130 -	/* Store name of game directory by itself */
   1.131 -	size_t len = strlen(gamepath);
   1.132 -	for (size_t i = len - 1; i >= 0; i--)
   1.133 -	{
   1.134 -		if (gamepath[i] == PLATFORM_SEP_CHAR)
   1.135 -		{
   1.136 -			strncopy(m_ModDir, &gamepath[++i], sizeof(m_ModDir));
   1.137 -			break;
   1.138 -		}
   1.139 -	}
   1.140 -
   1.141 -	/* Initialize CoreConfig so we can get SourceMod base path properly - this basically parses core.cfg */
   1.142 -	g_CoreConfig.Initialize();
   1.143 -
   1.144 -	/* This shouldn't happen, but can't hurt to be safe */
   1.145 -	if (!g_LibSys.PathExists(m_SMBaseDir) || !m_GotBasePath)
   1.146 -	{
   1.147 -		g_LibSys.PathFormat(m_SMBaseDir, sizeof(m_SMBaseDir), "%s/addons/sourcemod", g_BaseDir.c_str());
   1.148 -		g_LibSys.PathFormat(m_SMRelDir, sizeof(m_SMRelDir), "addons/sourcemod");
   1.149 -		m_GotBasePath = true;
   1.150 -	}
   1.151 -
   1.152 -	/* Attempt to load the JIT! */
   1.153 -	char file[PLATFORM_MAX_PATH];
   1.154 -	char myerror[255];
   1.155 -	g_SMAPI->PathFormat(file, sizeof(file), "%s/bin/sourcepawn.jit.x86.%s",
   1.156 -		GetSourceModPath(),
   1.157 -		PLATFORM_LIB_EXT
   1.158 -		);
   1.159 -
   1.160 -	g_pJIT = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
   1.161 -	if (!g_pJIT)
   1.162 -	{
   1.163 -		if (error && maxlength)
   1.164 -		{
   1.165 -			snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)", 
   1.166 -				myerror,
   1.167 -				PLATFORM_LIB_EXT);
   1.168 -		}
   1.169 -		return false;
   1.170 -	}
   1.171 -
   1.172 -	int err;
   1.173 -	
   1.174 -	GIVEENGINEPOINTER2 jit_init2 = (GIVEENGINEPOINTER2)g_pJIT->GetSymbolAddress("GiveEnginePointer2");
   1.175 -	if (!jit_init2)
   1.176 -	{
   1.177 -		GIVEENGINEPOINTER jit_init = (GIVEENGINEPOINTER)g_pJIT->GetSymbolAddress("GiveEnginePointer");
   1.178 -		if (!jit_init)
   1.179 -		{
   1.180 -			ShutdownJIT();
   1.181 -			if (error && maxlength)
   1.182 -			{
   1.183 -				snprintf(error, maxlength, "Failed to find GiveEnginePointer in JIT!");
   1.184 -			}
   1.185 -			return false;
   1.186 -		}
   1.187 -
   1.188 -		if ((err=jit_init(g_pSourcePawn)) != 0)
   1.189 -		{
   1.190 -			ShutdownJIT();
   1.191 -			if (error && maxlength)
   1.192 -			{
   1.193 -				snprintf(error, maxlength, "GiveEnginePointer returned %d in the JIT", err);
   1.194 -			}
   1.195 -			return false;
   1.196 -		}
   1.197 -	} else {
   1.198 -		/* On version bumps, we should check for older versions as well, if the new version fails.
   1.199 -		 * We can then check the exports to see if any VM versions will be sufficient.
   1.200 -		 */
   1.201 -		if ((err=jit_init2(g_pSourcePawn, SOURCEPAWN_ENGINE_API_VERSION)) != SP_ERROR_NONE)
   1.202 -		{
   1.203 -			ShutdownJIT();
   1.204 -			if (error && maxlength)
   1.205 -			{
   1.206 -				snprintf(error, maxlength, "JIT incompatible with SourceMod version");
   1.207 -			}
   1.208 -			return false;
   1.209 -		}
   1.210 -	}
   1.211 -
   1.212 -	GETEXPORTCOUNT jit_getnum = (GETEXPORTCOUNT)g_pJIT->GetSymbolAddress("GetExportCount");
   1.213 -	GETEXPORT jit_get = (GETEXPORT)g_pJIT->GetSymbolAddress("GetExport");
   1.214 -	if (!jit_get)
   1.215 -	{
   1.216 -		ShutdownJIT();
   1.217 -		if (error && maxlength)
   1.218 -		{
   1.219 -			snprintf(error, maxlength, "JIT is missing a necessary export!");
   1.220 -		}
   1.221 -		return false;
   1.222 -	}
   1.223 -
   1.224 -	unsigned int num = jit_getnum();
   1.225 -	if (!num)
   1.226 -	{
   1.227 -		ShutdownJIT();
   1.228 -		if (error && maxlength)
   1.229 -		{
   1.230 -			snprintf(error, maxlength, "JIT did not export any virtual machines!");
   1.231 -		}
   1.232 -		return false;
   1.233 -	}
   1.234 -
   1.235 -	unsigned int api_version;
   1.236 -	for (unsigned int i=0; i<num; i++)
   1.237 -	{
   1.238 -		 if ((g_pVM=jit_get(i)) == NULL)
   1.239 -		 {
   1.240 -			 if (error && maxlength)
   1.241 -			 {
   1.242 -				 snprintf(error, maxlength, "JIT did not export any virtual machines!");
   1.243 -			 }
   1.244 -			 continue;
   1.245 -		 }
   1.246 -		/* Refuse any API that we might not be able to deal with.
   1.247 -		 * Also refuse anything < 3 because we need fake natives.
   1.248 -		 */
   1.249 -		 api_version = g_pVM->GetAPIVersion();
   1.250 -		 if (api_version < 3 || api_version > SOURCEPAWN_VM_API_VERSION)
   1.251 -		 {
   1.252 -			 if (error && maxlength)
   1.253 -			 {
   1.254 -				 snprintf(error, maxlength, "JIT is not a compatible version");
   1.255 -			 }
   1.256 -			 g_pVM = NULL;
   1.257 -			 continue;
   1.258 -		 }
   1.259 -		 break;
   1.260 -	}
   1.261 -
   1.262 -	if (!g_pVM)
   1.263 -	{
   1.264 -		ShutdownJIT();
   1.265 -		return false;
   1.266 -	}
   1.267 -
   1.268 -	/* Hook this now so we can detect startup without calling StartSourceMod() */
   1.269 -	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   1.270 -
   1.271 -	/* Only load if we're not late */
   1.272 -	if (!late)
   1.273 -	{
   1.274 -		StartSourceMod(false);
   1.275 -	}
   1.276 -
   1.277 -	return true;
   1.278 -}
   1.279 -
   1.280 -void SourceModBase::StartSourceMod(bool late)
   1.281 -{
   1.282 -	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   1.283 -	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   1.284 -
   1.285 -	enginePatch = SH_GET_CALLCLASS(engine);
   1.286 -	gamedllPatch = SH_GET_CALLCLASS(gamedll);
   1.287 -
   1.288 -	/* Notify! */
   1.289 -	SMGlobalClass *pBase = SMGlobalClass::head;
   1.290 -	while (pBase)
   1.291 -	{
   1.292 -		pBase->OnSourceModStartup(false);
   1.293 -		pBase = pBase->m_pGlobalClassNext;
   1.294 -	}
   1.295 -
   1.296 -	/* Make the global core identity */
   1.297 -	g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
   1.298 -
   1.299 -	/* Notify! */
   1.300 -	pBase = SMGlobalClass::head;
   1.301 -	while (pBase)
   1.302 -	{
   1.303 -		pBase->OnSourceModAllInitialized();
   1.304 -		pBase = pBase->m_pGlobalClassNext;
   1.305 -	}
   1.306 -
   1.307 -	/* Add us now... */
   1.308 -	g_ShareSys.AddInterface(NULL, this);
   1.309 -
   1.310 -	/* We're loaded! */
   1.311 -	g_Loaded = true;
   1.312 -
   1.313 -	/* Initialize VSP stuff */
   1.314 -	if (vsp_interface != NULL)
   1.315 -	{
   1.316 -		g_SourceMod_Core.OnVSPListening(vsp_interface);
   1.317 -	}
   1.318 -}
   1.319 -
   1.320 -static bool g_LevelEndBarrier = false;
   1.321 -bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
   1.322 -{
   1.323 -	/* If we're not loaded... */
   1.324 -	if (!g_Loaded)
   1.325 -	{
   1.326 -		/* Do all global initialization now */
   1.327 -		StartSourceMod(true);
   1.328 -	}
   1.329 -
   1.330 -	m_IsMapLoading = true;
   1.331 -	m_ExecPluginReload = true;
   1.332 -	m_ExecOnMapEnd = true;
   1.333 -
   1.334 -	/* Notify! */
   1.335 -	SMGlobalClass *pBase = SMGlobalClass::head;
   1.336 -	while (pBase)
   1.337 -	{
   1.338 -		pBase->OnSourceModLevelChange(pMapName);
   1.339 -		pBase = pBase->m_pGlobalClassNext;
   1.340 -	}
   1.341 -
   1.342 -	DoGlobalPluginLoads();
   1.343 -
   1.344 -	m_IsMapLoading = false;
   1.345 -
   1.346 -	/* Notify! */
   1.347 -	pBase = SMGlobalClass::head;
   1.348 -	while (pBase)
   1.349 -	{
   1.350 -		pBase->OnSourceModPluginsLoaded();
   1.351 -		pBase = pBase->m_pGlobalClassNext;
   1.352 -	}
   1.353 -
   1.354 -	if (!g_pOnMapEnd)
   1.355 -	{
   1.356 -		g_pOnMapEnd = g_Forwards.CreateForward("OnMapEnd", ET_Ignore, 0, NULL);
   1.357 -	}
   1.358 -
   1.359 -	g_LevelEndBarrier = true;
   1.360 -
   1.361 -	RETURN_META_VALUE(MRES_IGNORED, true);
   1.362 -}
   1.363 -
   1.364 -void SourceModBase::LevelShutdown()
   1.365 -{
   1.366 -	if (g_LevelEndBarrier)
   1.367 -	{
   1.368 -		SMGlobalClass *next = SMGlobalClass::head;
   1.369 -		while (next)
   1.370 -		{
   1.371 -			next->OnSourceModLevelEnd();
   1.372 -			next = next->m_pGlobalClassNext;
   1.373 -		}
   1.374 -		g_LevelEndBarrier = false;
   1.375 -	}
   1.376 -
   1.377 -	if (g_pOnMapEnd && m_ExecOnMapEnd)
   1.378 -	{
   1.379 -		g_pOnMapEnd->Execute(NULL);
   1.380 -		m_ExecOnMapEnd = false;
   1.381 -	}
   1.382 -
   1.383 -	g_OnMapStarted = false;
   1.384 -
   1.385 -	if (m_ExecPluginReload)
   1.386 -	{
   1.387 -		g_PluginSys.ReloadOrUnloadPlugins();
   1.388 -		m_ExecPluginReload = false;
   1.389 -	}
   1.390 -}
   1.391 -
   1.392 -bool SourceModBase::IsMapLoading() const
   1.393 -{
   1.394 -	return m_IsMapLoading;
   1.395 -}
   1.396 -
   1.397 -void SourceModBase::DoGlobalPluginLoads()
   1.398 -{
   1.399 -	char config_path[PLATFORM_MAX_PATH];
   1.400 -	char plugins_path[PLATFORM_MAX_PATH];
   1.401 -
   1.402 -	BuildPath(Path_SM, config_path, 
   1.403 -		sizeof(config_path),
   1.404 -		"configs/plugin_settings.cfg");
   1.405 -	BuildPath(Path_SM, plugins_path,
   1.406 -		sizeof(plugins_path),
   1.407 -		"plugins");
   1.408 -
   1.409 -	/* Load any auto extensions */
   1.410 -	g_Extensions.TryAutoload();
   1.411 -
   1.412 -	/* Fire the extensions ready message */
   1.413 -	g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);	
   1.414 -
   1.415 -	/* Load any game extension */
   1.416 -	const char *game_ext;
   1.417 -	if ((game_ext = g_pGameConf->GetKeyValue("GameExtension")) != NULL)
   1.418 -	{
   1.419 -		char path[PLATFORM_MAX_PATH];
   1.420 -		UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext);
   1.421 -		g_Extensions.LoadAutoExtension(path);
   1.422 -	}
   1.423 -
   1.424 -	/* Run the first pass */
   1.425 -	g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
   1.426 -
   1.427 -	/* Mark any extensions as loaded */
   1.428 -	g_Extensions.MarkAllLoaded();
   1.429 -
   1.430 -	/* No modules yet, it's safe to call this from here */
   1.431 -	g_PluginSys.LoadAll_SecondPass();
   1.432 -
   1.433 -	/* Re-mark any extensions as loaded */
   1.434 -	g_Extensions.MarkAllLoaded();
   1.435 -
   1.436 -	/* Call OnAllPluginsLoaded */
   1.437 -	g_PluginSys.AllPluginsLoaded();
   1.438 -}
   1.439 -
   1.440 -size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...)
   1.441 -{
   1.442 -	char _buffer[PLATFORM_MAX_PATH];
   1.443 -	va_list ap;
   1.444 -
   1.445 -	va_start(ap, format);
   1.446 -	vsnprintf(_buffer, PLATFORM_MAX_PATH, format, ap);
   1.447 -	va_end(ap);
   1.448 -
   1.449 -	const char *base = NULL;
   1.450 -	if (type == Path_Game)
   1.451 -	{
   1.452 -		base = GetGamePath();
   1.453 -	} else if (type == Path_SM) {
   1.454 -		base = GetSourceModPath();
   1.455 -	} else if (type == Path_SM_Rel) {
   1.456 -		base = m_SMRelDir;
   1.457 -	}
   1.458 -
   1.459 -	if (base)
   1.460 -	{
   1.461 -		return g_LibSys.PathFormat(buffer, maxlength, "%s/%s", base, _buffer);
   1.462 -	} else {
   1.463 -		return g_LibSys.PathFormat(buffer, maxlength, "%s", _buffer);
   1.464 -	}
   1.465 -}
   1.466 -
   1.467 -void SourceModBase::CloseSourceMod()
   1.468 -{
   1.469 -	/* Force a level end */
   1.470 -	LevelShutdown();
   1.471 -
   1.472 -	/* Unload plugins */
   1.473 -	g_PluginSys.Shutdown();
   1.474 -
   1.475 -	/* Unload extensions */
   1.476 -	g_Extensions.Shutdown();
   1.477 -
   1.478 -	SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
   1.479 -
   1.480 -	if (g_Loaded)
   1.481 -	{
   1.482 -		if (g_pOnMapEnd)
   1.483 -		{
   1.484 -			g_Forwards.ReleaseForward(g_pOnMapEnd);
   1.485 -		}
   1.486 -	
   1.487 -		/* Notify! */
   1.488 -		SMGlobalClass *pBase = SMGlobalClass::head;
   1.489 -		while (pBase)
   1.490 -		{
   1.491 -			pBase->OnSourceModShutdown();
   1.492 -			pBase = pBase->m_pGlobalClassNext;
   1.493 -		}
   1.494 -	
   1.495 -		/* Delete all data packs */
   1.496 -		CStack<CDataPack *>::iterator iter;
   1.497 -		CDataPack *pd;
   1.498 -		for (iter=m_freepacks.begin(); iter!=m_freepacks.end(); iter++)
   1.499 -		{
   1.500 -			pd = (*iter);
   1.501 -			delete pd;
   1.502 -		}
   1.503 -		m_freepacks.popall();
   1.504 -	
   1.505 -		/* Notify! */
   1.506 -		pBase = SMGlobalClass::head;
   1.507 -		while (pBase)
   1.508 -		{
   1.509 -			pBase->OnSourceModAllShutdown();
   1.510 -			pBase = pBase->m_pGlobalClassNext;
   1.511 -		}
   1.512 -	
   1.513 -		if (enginePatch)
   1.514 -		{
   1.515 -			SH_RELEASE_CALLCLASS(enginePatch);
   1.516 -			enginePatch = NULL;
   1.517 -		}
   1.518 -	
   1.519 -		if (gamedllPatch)
   1.520 -		{
   1.521 -			SH_RELEASE_CALLCLASS(gamedllPatch);
   1.522 -			gamedllPatch = NULL;
   1.523 -		}
   1.524 -
   1.525 -		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
   1.526 -		SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, &g_Timers, &TimerSystem::GameFrame, false);
   1.527 -	}
   1.528 -
   1.529 -	/* Rest In Peace */
   1.530 -	ShutdownJIT();
   1.531 -}
   1.532 -
   1.533 -void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
   1.534 -{
   1.535 -	IExtensionInterface *pAPI = pExt->GetAPI();
   1.536 -	const char *tag = pAPI->GetExtensionTag();
   1.537 -	char buffer[2048];
   1.538 -	va_list ap;
   1.539 -
   1.540 -	va_start(ap, format);
   1.541 -	vsnprintf(buffer, sizeof(buffer), format, ap);
   1.542 -	va_end(ap);
   1.543 -
   1.544 -	if (tag)
   1.545 -	{
   1.546 -		g_Logger.LogMessage("[%s] %s", tag, buffer);
   1.547 -	} else {
   1.548 -		g_Logger.LogMessage("%s", buffer);
   1.549 -	}
   1.550 -}
   1.551 -
   1.552 -void SourceModBase::LogError(IExtension *pExt, const char *format, ...)
   1.553 -{
   1.554 -	IExtensionInterface *pAPI = pExt->GetAPI();
   1.555 -	const char *tag = pAPI->GetExtensionTag();
   1.556 -	char buffer[2048];
   1.557 -	va_list ap;
   1.558 -
   1.559 -	va_start(ap, format);
   1.560 -	vsnprintf(buffer, sizeof(buffer), format, ap);
   1.561 -	va_end(ap);
   1.562 -
   1.563 -	if (tag)
   1.564 -	{
   1.565 -		g_Logger.LogError("[%s] %s", tag, buffer);
   1.566 -	} else {
   1.567 -		g_Logger.LogError("%s", buffer);
   1.568 -	}
   1.569 -}
   1.570 -
   1.571 -size_t SourceModBase::FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param)
   1.572 -{
   1.573 -	char *fmt;
   1.574 -
   1.575 -	pContext->LocalToString(params[param], &fmt);
   1.576 -
   1.577 -	int lparam = ++param;
   1.578 -
   1.579 -	return atcprintf(buffer, maxlength, fmt, pContext, params, &lparam);
   1.580 -}
   1.581 -
   1.582 -const char *SourceModBase::GetSourceModPath() const
   1.583 -{
   1.584 -	return m_SMBaseDir;
   1.585 -}
   1.586 -
   1.587 -const char *SourceModBase::GetGamePath() const
   1.588 -{
   1.589 -	return g_BaseDir.c_str();
   1.590 -}
   1.591 -
   1.592 -unsigned int SourceModBase::SetGlobalTarget(unsigned int index)
   1.593 -{
   1.594 -	unsigned int old = m_target;
   1.595 -	m_target = index;
   1.596 -	return old;
   1.597 -}
   1.598 -
   1.599 -unsigned int SourceModBase::GetGlobalTarget() const
   1.600 -{
   1.601 -	return m_target;
   1.602 -}
   1.603 -
   1.604 -IDataPack *SourceModBase::CreateDataPack()
   1.605 -{
   1.606 -	CDataPack *pack;
   1.607 -	if (m_freepacks.empty())
   1.608 -	{
   1.609 -		pack = new CDataPack;
   1.610 -	} else {
   1.611 -		pack = m_freepacks.front();
   1.612 -		m_freepacks.pop();
   1.613 -		pack->Initialize();
   1.614 -	}
   1.615 -	return pack;
   1.616 -}
   1.617 -
   1.618 -void SourceModBase::FreeDataPack(IDataPack *pack)
   1.619 -{
   1.620 -	m_freepacks.push(static_cast<CDataPack *>(pack));
   1.621 -}
   1.622 -
   1.623 -Handle_t SourceModBase::GetDataPackHandleType(bool readonly)
   1.624 -{
   1.625 -	//:TODO:
   1.626 -	return 0;
   1.627 -}
   1.628 -
   1.629 -const char *SourceModBase::GetGameFolderName() const
   1.630 -{
   1.631 -	return m_ModDir;
   1.632 -}
   1.633 -
   1.634 -ISourcePawnEngine *SourceModBase::GetScriptingEngine()
   1.635 -{
   1.636 -	return g_pSourcePawn;
   1.637 -}
   1.638 -
   1.639 -IVirtualMachine *SourceModBase::GetScriptingVM()
   1.640 -{
   1.641 -	return g_pVM;
   1.642 -}
   1.643 -
   1.644 -void SourceModBase::AllPluginsLoaded()
   1.645 -{
   1.646 -	SMGlobalClass *base = SMGlobalClass::head;
   1.647 -	while (base)
   1.648 -	{
   1.649 -		base->OnSourceModGameInitialized();
   1.650 -		base = base->m_pGlobalClassNext;
   1.651 -	}
   1.652 -}
   1.653 -
   1.654 -time_t SourceModBase::GetAdjustedTime()
   1.655 -{
   1.656 -	return GetAdjustedTime();
   1.657 -}
   1.658 -
   1.659 -SMGlobalClass *SMGlobalClass::head = NULL;
   1.660 -
   1.661 -SMGlobalClass::SMGlobalClass()
   1.662 -{
   1.663 -	m_pGlobalClassNext = SMGlobalClass::head;
   1.664 -	SMGlobalClass::head = this;
   1.665 -}