core/ExtensionSys.cpp
author Asher Baker <asherkin@gmail.com>
Thu Apr 26 16:58:18 2012 +0100 (2012-04-26)
changeset 3488 bee90c8ef6c3
parent 3402 a459183ce707
child 3511 c9fd86b6bec3
permissions -rw-r--r--
Fixed client serials not being unique on Windows (bug 5285, r=psychonic).
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2010 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 <stdlib.h>
    33 #include "ExtensionSys.h"
    34 #include "LibrarySys.h"
    35 #include "ShareSys.h"
    36 #include "Logger.h"
    37 #include "sourcemm_api.h"
    38 #include "sm_srvcmds.h"
    39 #include "sm_stringutil.h"
    40 
    41 CExtensionManager g_Extensions;
    42 IdentityType_t g_ExtType;
    43 
    44 void CExtension::Initialize(const char *filename, const char *path)
    45 {
    46 	m_pAPI = NULL;
    47 	m_pIdentToken = NULL;
    48 	unload_code = 0;
    49 	m_bFullyLoaded = false;
    50 	m_File.assign(filename);
    51 	m_Path.assign(path);
    52 	char real_name[PLATFORM_MAX_PATH];
    53 	g_LibSys.GetFileFromPath(real_name, sizeof(real_name), m_Path.c_str());
    54 	m_RealFile.assign(real_name);
    55 }
    56 
    57 CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filename, const char *path)
    58 {
    59 	Initialize(filename, path);
    60 	m_pAPI = pAPI;
    61 }
    62 
    63 #if defined METAMOD_PLAPI_VERSION
    64 #if SOURCE_ENGINE == SE_LEFT4DEAD
    65 #define GAMEFIX "2.l4d"
    66 #elif SOURCE_ENGINE == SE_LEFT4DEAD2
    67 #define GAMEFIX "2.l4d2"
    68 #elif SOURCE_ENGINE == SE_ALIENSWARM
    69 #define GAMEFIX "2.swarm"
    70 #elif SOURCE_ENGINE == SE_ORANGEBOX
    71 #define GAMEFIX "2.ep2"
    72 #elif SOURCE_ENGINE == SE_BLOODYGOODTIME
    73 #define GAMEFIX "2.bgt"
    74 #elif SOURCE_ENGINE == SE_EYE
    75 #define GAMEFIX "2.eye"
    76 #elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
    77 #define GAMEFIX "2.ep2v"
    78 #elif SOURCE_ENGINE == SE_DARKMESSIAH
    79 #define GAMEFIX "2.darkm"
    80 #else
    81 #define GAMEFIX "2.ep1"
    82 #endif //(SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
    83 #else  //METAMOD_PLAPI_VERSION
    84 #define GAMEFIX "1.ep1"
    85 #endif //METAMOD_PLAPI_VERSION
    86 
    87 CLocalExtension::CLocalExtension(const char *filename)
    88 {
    89 	m_PlId = 0;
    90 	m_pLib = NULL;
    91 
    92 	char path[PLATFORM_MAX_PATH];
    93 
    94 	/* Special case for new bintools binary */
    95 	if (strcmp(filename, "bintools.ext") == 0)
    96 	{
    97 		goto normal;
    98 	}
    99 
   100 	/* Zeroth, see if there is an engine specific build in the new place. */
   101 	g_SourceMod.BuildPath(Path_SM,
   102 		path,
   103 		PLATFORM_MAX_PATH,
   104 		"extensions/%s." GAMEFIX "." PLATFORM_LIB_EXT,
   105 		filename);
   106 
   107 	if (g_LibSys.IsPathFile(path))
   108 	{
   109 		goto found;
   110 	}
   111 
   112 	/* First see if there is an engine specific build! */
   113 	g_SourceMod.BuildPath(Path_SM, 
   114 		path, 
   115 		PLATFORM_MAX_PATH,
   116 		"extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT,
   117 		filename);
   118 
   119 normal:
   120 	/* Try the "normal" version */
   121 	if (!g_LibSys.IsPathFile(path))
   122 	{
   123 		g_SourceMod.BuildPath(Path_SM,
   124 			path,
   125 			PLATFORM_MAX_PATH,
   126 			"extensions/%s." PLATFORM_LIB_EXT,
   127 			filename);
   128 	}
   129 
   130 found:
   131 	Initialize(filename, path);
   132 }
   133 
   134 bool CRemoteExtension::Load(char *error, size_t maxlength)
   135 {
   136 	if (!PerformAPICheck(error, maxlength))
   137 	{
   138 		m_pAPI = NULL;
   139 		return false;
   140 	}
   141 
   142 	if (!CExtension::Load(error, maxlength))
   143 	{
   144 		m_pAPI = NULL;
   145 		return false;
   146 	}
   147 
   148 	return true;
   149 }
   150 
   151 bool CLocalExtension::Load(char *error, size_t maxlength)
   152 {
   153 	m_pLib = g_LibSys.OpenLibrary(m_Path.c_str(), error, maxlength);
   154 
   155 	if (m_pLib == NULL)
   156 	{
   157 		return false;
   158 	}
   159 
   160 	typedef IExtensionInterface *(*GETAPI)();
   161 	GETAPI pfnGetAPI = NULL;
   162 
   163 	if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
   164 	{
   165 		m_pLib->CloseLibrary();
   166 		m_pLib = NULL;
   167 		snprintf(error, maxlength, "Unable to find extension entry point");
   168 		return false;
   169 	}
   170 
   171 	m_pAPI = pfnGetAPI();
   172 
   173 	/* Check pointer and version */
   174 	if (!PerformAPICheck(error, maxlength))
   175 	{
   176 		m_pLib->CloseLibrary();
   177 		m_pLib = NULL;
   178 		m_pAPI = NULL;
   179 		return false;
   180 	}
   181 
   182 	/* Load as MM:S */
   183 	if (m_pAPI->IsMetamodExtension())
   184 	{
   185 		bool already;
   186 		m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength);
   187 
   188 		// Check the plugin didn't refuse load
   189 		Pl_Status status;
   190 		
   191 #ifndef METAMOD_PLAPI_VERSION
   192 		const char *file;
   193 		PluginId source;
   194 #endif
   195 		
   196 		if (!m_PlId || (
   197 #ifndef METAMOD_PLAPI_VERSION
   198 			g_pMMPlugins->Query(m_PlId, file, status, source)
   199 #else
   200 			g_pMMPlugins->Query(m_PlId, NULL, &status, NULL)
   201 #endif			
   202 			&& status < Pl_Paused))
   203 		{
   204 			m_pLib->CloseLibrary();
   205 			m_pLib = NULL;
   206 			m_pAPI = NULL;
   207 			return false;
   208 		}
   209 	}
   210 
   211 	if (!CExtension::Load(error, maxlength))
   212 	{
   213 		if (m_pAPI->IsMetamodExtension())
   214 		{
   215 			if (m_PlId)
   216 			{
   217 				char dummy[255];
   218 				g_pMMPlugins->Unload(m_PlId, true, dummy, sizeof(dummy));
   219 				m_PlId = 0;
   220 			}
   221 		}
   222 		m_pLib->CloseLibrary();
   223 		m_pLib = NULL;
   224 		m_pAPI = NULL;
   225 		return false;
   226 	}
   227 
   228 	return true;
   229 }
   230 
   231 void CRemoteExtension::Unload()
   232 {
   233 }
   234 
   235 void CLocalExtension::Unload()
   236 {
   237 	if (m_pAPI != NULL && m_PlId)
   238 	{
   239 		char temp_buffer[255];
   240 		g_pMMPlugins->Unload(m_PlId, true, temp_buffer, sizeof(temp_buffer));
   241 		m_PlId = 0;
   242 	}
   243 
   244 	if (m_pLib != NULL)
   245 	{
   246 		m_pLib->CloseLibrary();
   247 		m_pLib = NULL;
   248 	}
   249 }
   250 
   251 bool CRemoteExtension::Reload(char *error, size_t maxlength)
   252 {
   253 	snprintf(error, maxlength, "Remote extensions do not support reloading");
   254 	return false;
   255 }
   256 
   257 bool CLocalExtension::Reload(char *error, size_t maxlength)
   258 {
   259 	if (m_pLib == NULL) // FIXME: just load it instead?
   260 		return false;
   261 	
   262 	m_pAPI->OnExtensionUnload();
   263 	Unload();
   264 	
   265 	return Load(error, maxlength);
   266 }
   267 
   268 bool CRemoteExtension::IsExternal()
   269 {
   270 	return true;
   271 }
   272 
   273 bool CLocalExtension::IsExternal()
   274 {
   275 	return false;
   276 }
   277 
   278 CExtension::~CExtension()
   279 {
   280 	DestroyIdentity();
   281 }
   282 
   283 bool CExtension::PerformAPICheck(char *error, size_t maxlength)
   284 {
   285 	if (!m_pAPI)
   286 	{
   287 		snprintf(error, maxlength, "No IExtensionInterface instance provided");
   288 		return false;
   289 	}
   290 	
   291 	if (m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
   292 	{
   293 		snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
   294 		return false;
   295 	}
   296 
   297 	return true;
   298 }
   299 
   300 bool CExtension::Load(char *error, size_t maxlength)
   301 {
   302 	CreateIdentity();
   303 	if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading()))
   304 	{
   305 		DestroyIdentity();
   306 		return false;
   307 	}
   308 	else
   309 	{
   310 		/* Check if we're past load time */
   311 		if (!g_SourceMod.IsMapLoading())
   312 		{
   313 			m_pAPI->OnExtensionsAllLoaded();
   314 		}
   315 	}
   316 
   317 	return true;
   318 }
   319 
   320 void CExtension::CreateIdentity()
   321 {
   322 	if (m_pIdentToken != NULL)
   323 	{
   324 		return;
   325 	}
   326 
   327 	m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType, this);
   328 }
   329 
   330 void CExtension::DestroyIdentity()
   331 {
   332 	if (m_pIdentToken == NULL)
   333 	{
   334 		return;
   335 	}
   336 
   337 	g_ShareSys.DestroyIdentity(m_pIdentToken);
   338 	m_pIdentToken = NULL;
   339 }
   340 
   341 void CExtension::MarkAllLoaded()
   342 {
   343 	assert(m_bFullyLoaded == false);
   344 	if (!m_bFullyLoaded)
   345 	{
   346 		m_bFullyLoaded = true;
   347 		m_pAPI->OnExtensionsAllLoaded();
   348 	}
   349 }
   350 
   351 void CExtension::AddPlugin(CPlugin *pPlugin)
   352 {
   353 	/* Unfortunately we have to do this :( */
   354 	if (m_Dependents.find(pPlugin) != m_Dependents.end())
   355 	{
   356 		m_Dependents.push_back(pPlugin);
   357 	}
   358 }
   359 
   360 void CExtension::SetError(const char *error)
   361 {
   362 	m_Error.assign(error);
   363 }
   364 
   365 IExtensionInterface *CExtension::GetAPI()
   366 {
   367 	return m_pAPI;
   368 }
   369 
   370 const char *CExtension::GetFilename()
   371 {
   372 	return m_RealFile.c_str();
   373 }
   374 
   375 const char *CExtension::GetPath() const
   376 {
   377 	return m_Path.c_str();
   378 }
   379 
   380 IdentityToken_t *CExtension::GetIdentity()
   381 {
   382 	return m_pIdentToken;
   383 }
   384 
   385 bool CRemoteExtension::IsLoaded()
   386 {
   387 	return (m_pAPI != NULL);
   388 }
   389 
   390 bool CLocalExtension::IsLoaded()
   391 {
   392 	return (m_pLib != NULL);
   393 }
   394 
   395 void CExtension::AddDependency(const IfaceInfo *pInfo)
   396 {
   397 	if (m_Deps.find(*pInfo) == m_Deps.end())
   398 	{
   399 		m_Deps.push_back(*pInfo);
   400 	}
   401 }
   402 
   403 bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
   404 {
   405 	return (i1.iface == i2.iface) && (i1.owner == i2.owner);
   406 }
   407 
   408 void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
   409 {
   410 	IfaceInfo info;
   411 	info.iface = iface;
   412 	info.owner = pOther;
   413 
   414 	List<IfaceInfo>::iterator iter;
   415 	for (iter = m_ChildDeps.begin();
   416 		 iter != m_ChildDeps.end();
   417 		 iter++)
   418 	{
   419 		IfaceInfo &other = (*iter);
   420 		if (other == info)
   421 		{
   422 			return;
   423 		}
   424 	}
   425 
   426 	m_ChildDeps.push_back(info);
   427 }
   428 
   429 ITERATOR *CExtension::FindFirstDependency(IExtension **pOwner, SMInterface **pInterface)
   430 {
   431 	List<IfaceInfo>::iterator iter = m_Deps.begin();
   432 
   433 	if (iter == m_Deps.end())
   434 	{
   435 		return NULL;
   436 	}
   437 
   438 	if (pOwner)
   439 	{
   440 		*pOwner = (*iter).owner;
   441 	}
   442 	if (pInterface)
   443 	{
   444 		*pInterface = (*iter).iface;
   445 	}
   446 
   447 	List<IfaceInfo>::iterator *pIter = new List<IfaceInfo>::iterator(iter);
   448 
   449 	return (ITERATOR *)pIter;
   450 }
   451 
   452 bool CExtension::FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface)
   453 {
   454 	List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
   455 	List<IfaceInfo>::iterator _iter;
   456 
   457 	if (_iter == m_Deps.end())
   458 	{
   459 		return false;
   460 	}
   461 
   462 	_iter++;
   463 
   464 	if (pOwner)
   465 	{
   466 		*pOwner = (*_iter).owner;
   467 	}
   468 	if (pInterface)
   469 	{
   470 		*pInterface = (*_iter).iface;
   471 	}
   472 
   473 	*pIter = _iter;
   474 
   475 	if (_iter == m_Deps.end())
   476 	{
   477 		return false;
   478 	}
   479 
   480 	return true;
   481 }
   482 
   483 void CExtension::FreeDependencyIterator(ITERATOR *iter)
   484 {
   485 	List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
   486 
   487 	delete pIter;
   488 }
   489 
   490 void CExtension::AddInterface(SMInterface *pInterface)
   491 {
   492 	m_Interfaces.push_back(pInterface);
   493 }
   494 
   495 bool CExtension::IsRunning(char *error, size_t maxlength)
   496 {
   497 	if (!IsLoaded())
   498 	{
   499 		if (error)
   500 		{
   501 			snprintf(error, maxlength, "%s", m_Error.c_str());
   502 		}
   503 		return false;
   504 	}
   505 
   506 	return m_pAPI->QueryRunning(error, maxlength);
   507 }
   508 
   509 void CExtension::AddLibrary(const char *library)
   510 {
   511 	m_Libraries.push_back(library);
   512 }
   513 
   514 /*********************
   515  * EXTENSION MANAGER *
   516  *********************/
   517 
   518 void CExtensionManager::OnSourceModAllInitialized()
   519 {
   520 	g_ExtType = g_ShareSys.CreateIdentType("EXTENSION");
   521 	g_PluginSys.AddPluginsListener(this);
   522 	g_RootMenu.AddRootConsoleCommand("exts", "Manage extensions", this);
   523 	g_ShareSys.AddInterface(NULL, this);
   524 }
   525 
   526 void CExtensionManager::OnSourceModShutdown()
   527 {
   528 	g_RootMenu.RemoveRootConsoleCommand("exts", this);
   529 	g_ShareSys.DestroyIdentType(g_ExtType);
   530 }
   531 
   532 void CExtensionManager::Shutdown()
   533 {
   534 	List<CExtension *>::iterator iter;
   535 
   536 	while ((iter = m_Libs.begin()) != m_Libs.end())
   537 	{
   538 		UnloadExtension((*iter));
   539 	}
   540 }
   541 
   542 void CExtensionManager::TryAutoload()
   543 {
   544 	char path[PLATFORM_MAX_PATH];
   545 
   546 	g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "extensions");
   547 
   548 	IDirectory *pDir = g_LibSys.OpenDirectory(path);
   549 	if (!pDir)
   550 	{
   551 		return;
   552 	}
   553 
   554 	const char *lfile;
   555 	size_t len;
   556 	while (pDir->MoreFiles())
   557 	{
   558 		if (pDir->IsEntryDirectory())
   559 		{
   560 			pDir->NextEntry();
   561 			continue;
   562 		}
   563 
   564 		lfile = pDir->GetEntryName();
   565 		len = strlen(lfile);
   566 		if (len <= 9) /* size of ".autoload" */
   567 		{
   568 			pDir->NextEntry();
   569 			continue;
   570 		}
   571 
   572 		if (strcmp(&lfile[len - 9], ".autoload") != 0)
   573 		{
   574 			pDir->NextEntry();
   575 			continue;
   576 		}
   577 
   578 		char file[PLATFORM_MAX_PATH];
   579 		len = UTIL_Format(file, sizeof(file), "%s", lfile);
   580 		strcpy(&file[len - 9], ".ext");
   581 
   582 		LoadAutoExtension(file);
   583 		
   584 		pDir->NextEntry();
   585 	}
   586 }
   587 
   588 IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing)
   589 {
   590 	/* Remove platform extension if it's there. Compat hack. */
   591 	const char *ext = g_LibSys.GetFileExtension(path);
   592 	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
   593 	{
   594 		char path2[PLATFORM_MAX_PATH];
   595 		UTIL_Format(path2, sizeof(path2), "%s", path);
   596 		path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
   597 		return LoadAutoExtension(path2, bErrorOnMissing);
   598 	}
   599 
   600 	IExtension *pAlready;
   601 	if ((pAlready=FindExtensionByFile(path)) != NULL)
   602 	{
   603 		return pAlready;
   604 	}
   605 
   606 	char error[256];
   607 	CExtension *p = new CLocalExtension(path);
   608 
   609 	/* We put us in the list beforehand so extensions that check for each other
   610 	 * won't recursively load each other.
   611 	 */
   612 	m_Libs.push_back(p);
   613 
   614 	if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
   615 	{
   616 		if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath()))
   617 		{
   618 			g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
   619 		}
   620 
   621 		p->SetError(error);
   622 	}
   623 
   624 	return p;
   625 }
   626 
   627 IExtension *CExtensionManager::FindExtensionByFile(const char *file)
   628 {
   629 	List<CExtension *>::iterator iter;
   630 	CExtension *pExt;
   631 
   632 	/* Chomp off the path */
   633 	char lookup[PLATFORM_MAX_PATH];
   634 	g_LibSys.GetFileFromPath(lookup, sizeof(lookup), file);
   635 
   636 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   637 	{
   638 		pExt = (*iter);
   639 		if (pExt->IsSameFile(lookup))
   640 		{
   641 			return pExt;
   642 		}
   643 	}
   644 
   645 	return NULL;
   646 }
   647 
   648 IExtension *CExtensionManager::FindExtensionByName(const char *ext)
   649 {
   650 	List<CExtension *>::iterator iter;
   651 	CExtension *pExt;
   652 	IExtensionInterface *pAPI;
   653 	const char *name;
   654 
   655 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   656 	{
   657 		pExt = (*iter);
   658 		if (!pExt->IsLoaded())
   659 		{
   660 			continue;
   661 		}
   662 		if ((pAPI = pExt->GetAPI()) == NULL)
   663 		{
   664 			continue;
   665 		}
   666 		name = pAPI->GetExtensionName();
   667 		if (!name)
   668 		{
   669 			continue;
   670 		}
   671 		if (strcmp(name, ext) == 0)
   672 		{
   673 			return pExt;
   674 		}
   675 	}
   676 
   677 	return NULL;
   678 }
   679 
   680 IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
   681 {
   682 	/* Remove platform extension if it's there. Compat hack. */
   683 	const char *ext = g_LibSys.GetFileExtension(file);
   684 	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
   685 	{
   686 		char path2[PLATFORM_MAX_PATH];
   687 		UTIL_Format(path2, sizeof(path2), "%s", file);
   688 		path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
   689 		return LoadExtension(path2, error, maxlength);
   690 	}
   691 
   692 	IExtension *pAlready;
   693 	if ((pAlready=FindExtensionByFile(file)) != NULL)
   694 	{
   695 		return pAlready;
   696 	}
   697 
   698 	CExtension *pExt = new CLocalExtension(file);
   699 
   700 	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
   701 	{
   702 		pExt->Unload();
   703 		delete pExt;
   704 		return NULL;
   705 	}
   706 
   707 	/* :TODO: do QueryRunning check if the map is loaded */
   708 
   709 	m_Libs.push_back(pExt);
   710 
   711 	return pExt;
   712 }
   713 
   714 void CExtensionManager::BindDependency(IExtension *pRequester, IfaceInfo *pInfo)
   715 {
   716 	CExtension *pExt = (CExtension *)pRequester;
   717 	CExtension *pOwner = (CExtension *)pInfo->owner;
   718 
   719 	pExt->AddDependency(pInfo);
   720 
   721 	IExtensionInterface *pAPI = pExt->GetAPI();
   722 	if (pAPI && !pAPI->QueryInterfaceDrop(pInfo->iface))
   723 	{
   724 		pOwner->AddChildDependent(pExt, pInfo->iface);
   725 	}
   726 }
   727 
   728 void CExtensionManager::AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface)
   729 {
   730 	CExtension *pExt = (CExtension *)ext;
   731 	CExtension *pOwner = GetExtensionFromIdent(other);
   732 
   733 	IfaceInfo info;
   734 
   735 	info.iface = (SMInterface *)iface;
   736 	info.owner = pOwner;
   737 
   738 	pExt->AddDependency(&info);
   739 	pOwner->AddChildDependent(pExt, (SMInterface *)iface);
   740 }
   741 
   742 void CExtensionManager::AddInterface(IExtension *pOwner, SMInterface *pInterface)
   743 {
   744 	CExtension *pExt = (CExtension *)pOwner;
   745 
   746 	pExt->AddInterface(pInterface);
   747 }
   748 
   749 void CExtensionManager::BindChildPlugin( IExtension *pParent, CPlugin *pPlugin )
   750 {
   751 	CExtension *pExt = (CExtension *)pParent;
   752 
   753 	pExt->AddPlugin(pPlugin);
   754 }
   755 
   756 void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
   757 {
   758 	List<CExtension *>::iterator iter;
   759 
   760 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   761 	{
   762 		(*iter)->DropRefsTo((CPlugin *)plugin);
   763 	}
   764 }
   765 
   766 CExtension *CExtensionManager::FindByOrder(unsigned int num)
   767 {
   768 	if (num < 1 || num > m_Libs.size())
   769 	{
   770 		return NULL;
   771 	}
   772 
   773 	List<CExtension *>::iterator iter = m_Libs.begin();
   774 
   775 	while (iter != m_Libs.end())
   776 	{
   777 		if (--num == 0)
   778 		{
   779 			return (*iter);
   780 		}
   781 		iter++;
   782 	}
   783 
   784 	return NULL;
   785 }
   786 
   787 bool CExtensionManager::UnloadExtension(IExtension *_pExt)
   788 {
   789 	if (!_pExt)
   790 	{
   791 		return false;
   792 	}
   793 
   794 	CExtension *pExt = (CExtension *)_pExt;
   795 
   796 	if (m_Libs.find(pExt) == m_Libs.end())
   797 	{
   798 		return false;
   799 	}
   800 
   801 	/* First remove us from internal lists */
   802 	g_ShareSys.RemoveInterfaces(_pExt);
   803 	m_Libs.remove(pExt);
   804 
   805 	List<CExtension *> UnloadQueue;
   806 
   807 	/* Handle dependencies */
   808 	if (pExt->IsLoaded())
   809 	{
   810 		/* Unload any dependent plugins */
   811 		List<CPlugin *>::iterator p_iter = pExt->m_Dependents.begin();
   812 		while (p_iter != pExt->m_Dependents.end())
   813 		{
   814 			/* We have to manually unlink ourselves here, since we're no longer being managed */
   815 			g_PluginSys.UnloadPlugin((*p_iter));
   816 			p_iter = pExt->m_Dependents.erase(p_iter);
   817 		}
   818 
   819 		List<String>::iterator s_iter;
   820 		for (s_iter = pExt->m_Libraries.begin();
   821 			 s_iter != pExt->m_Libraries.end();
   822 			 s_iter++)
   823 		{
   824 			g_PluginSys.OnLibraryAction((*s_iter).c_str(), false, true);
   825 		}
   826 
   827 		/* Notify and/or unload all dependencies */
   828 		List<CExtension *>::iterator c_iter;
   829 		CExtension *pDep;
   830 		IExtensionInterface *pAPI;
   831 		for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
   832 		{
   833 			pDep = (*c_iter);
   834 			if ((pAPI=pDep->GetAPI()) == NULL)
   835 			{
   836 				continue;
   837 			}
   838 			if (pDep == pExt)
   839 			{
   840 				continue;
   841 			}
   842 			/* Now, get its dependency list */
   843 			bool dropped = false;
   844 			List<IfaceInfo>::iterator i_iter = pDep->m_Deps.begin();
   845 			while (i_iter != pDep->m_Deps.end())
   846 			{
   847 				if ((*i_iter).owner == _pExt)
   848 				{
   849 					if (!pAPI->QueryInterfaceDrop((*i_iter).iface))
   850 					{
   851 						if (!dropped)
   852 						{
   853 							dropped = true;
   854 							UnloadQueue.push_back(pDep);
   855 						}
   856 					}
   857 					pAPI->NotifyInterfaceDrop((*i_iter).iface);
   858 					i_iter = pDep->m_Deps.erase(i_iter);
   859 				}
   860 				else
   861 				{
   862 					i_iter++;
   863 				}
   864 			}
   865 			/* Flush out any back references to this plugin */
   866 			i_iter = pDep->m_ChildDeps.begin();
   867 			while (i_iter != pDep->m_ChildDeps.end())
   868 			{
   869 				if ((*i_iter).owner == pExt)
   870 				{
   871 					i_iter = pDep->m_ChildDeps.erase(i_iter);
   872 				}
   873 				else
   874 				{
   875 					i_iter++;
   876 				}
   877 			}
   878 		}
   879 
   880 		/* Unbind our natives from Core */
   881 		pExt->DropEverything();
   882 	}
   883 
   884 	IdentityToken_t *pIdentity;
   885 	if ((pIdentity = pExt->GetIdentity()) != NULL)
   886 	{
   887 		SMGlobalClass *glob = SMGlobalClass::head;
   888 		while (glob)
   889 		{
   890 			glob->OnSourceModIdentityDropped(pIdentity);
   891 			glob = glob->m_pGlobalClassNext;
   892 		}
   893 	}
   894 
   895 	/* Tell it to unload */
   896 	if (pExt->IsLoaded())
   897 	{
   898 		IExtensionInterface *pAPI = pExt->GetAPI();
   899 		pAPI->OnExtensionUnload();
   900 	}
   901 
   902 	pExt->Unload();
   903 	delete pExt;
   904 
   905 	List<CExtension *>::iterator iter;
   906 	for (iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++)
   907 	{
   908 		/* NOTE: This is safe because the unload function backs out of anything not present */
   909 		UnloadExtension((*iter));
   910 	}
   911 
   912 	return true;
   913 }
   914 
   915 void CExtensionManager::MarkAllLoaded()
   916 {
   917 	List<CExtension *>::iterator iter;
   918 	CExtension *pExt;
   919 
   920 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   921 	{
   922 		pExt = (*iter);
   923 		if (!pExt->IsLoaded())
   924 		{
   925 			continue;
   926 		}
   927 		if (pExt->m_bFullyLoaded)
   928 		{
   929 			continue;
   930 		}
   931 		pExt->MarkAllLoaded();
   932 	}
   933 }
   934 
   935 void CExtensionManager::AddDependency(IExtension *pSource, const char *file, bool required, bool autoload)
   936 {
   937 	/* This function doesn't really need to do anything now.  We make sure the 
   938 	 * other extension is loaded, but handling of dependencies is really done 
   939 	 * by the interface fetcher.
   940 	 */
   941 	if (required || autoload)
   942 	{
   943 		LoadAutoExtension(file);
   944 	}
   945 }
   946 
   947 void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
   948 {
   949 	int argcount = command.ArgC();
   950 	if (argcount >= 3)
   951 	{
   952 		const char *cmd = command.Arg(2);
   953 		if (strcmp(cmd, "list") == 0)
   954 		{
   955 			List<CExtension *>::iterator iter;
   956 			CExtension *pExt;
   957 			unsigned int num = 1;
   958 			switch (m_Libs.size())
   959 			{
   960 			case 1:
   961 				{
   962 					g_RootMenu.ConsolePrint("[SM] Displaying 1 extension:");
   963 					break;
   964 				}
   965 			case 0:
   966 				{
   967 					g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
   968 					break;
   969 				}
   970 			default:
   971 				{
   972 					g_RootMenu.ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
   973 					break;
   974 				}
   975 			}
   976 			for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
   977 			{
   978 				pExt = (*iter);
   979 				if (pExt->IsLoaded())
   980 				{
   981 					char error[255];
   982 					if (!pExt->IsRunning(error, sizeof(error)))
   983 					{
   984 						g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
   985 					}
   986 					else
   987 					{
   988 						IExtensionInterface *pAPI = pExt->GetAPI();
   989 						const char *name = pAPI->GetExtensionName();
   990 						const char *version = pAPI->GetExtensionVerString();
   991 						const char *descr = pAPI->GetExtensionDescription();
   992 						g_RootMenu.ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
   993 					}
   994 				} else {
   995 					g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
   996 				}
   997 			}
   998 			return;
   999 		}
  1000 		else if (strcmp(cmd, "load") == 0)
  1001 		{
  1002 			if (argcount < 4)
  1003 			{
  1004 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts load <file>");
  1005 				return;
  1006 			}
  1007 
  1008 			const char *filename = command.Arg(3);
  1009 			char path[PLATFORM_MAX_PATH];
  1010 			char error[256];
  1011 
  1012 			UTIL_Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "",
  1013 				!strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : "");
  1014 			
  1015 			if (FindExtensionByFile(path) != NULL)
  1016 			{
  1017 				g_RootMenu.ConsolePrint("[SM] Extension %s is already loaded.", path);
  1018 				return;
  1019 			}
  1020 			
  1021 			if (LoadExtension(path, error, sizeof(error)))
  1022 			{
  1023 				g_RootMenu.ConsolePrint("[SM] Loaded extension %s successfully.", path);
  1024 			} else
  1025 			{
  1026 				g_RootMenu.ConsolePrint("[SM] Extension %s failed to load: %s", path, error);
  1027 			}
  1028 			
  1029 			return;
  1030 		}
  1031 		else if (strcmp(cmd, "info") == 0)
  1032 		{
  1033 			if (argcount < 4)
  1034 			{
  1035 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
  1036 				return;
  1037 			}
  1038 
  1039 			const char *sId = command.Arg(3);
  1040 			unsigned int id = atoi(sId);
  1041 			if (id <= 0)
  1042 			{
  1043 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
  1044 				return;
  1045 			}
  1046 
  1047 			if (m_Libs.size() == 0)
  1048 			{
  1049 				g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
  1050 				return;
  1051 			}
  1052 
  1053 			if (id > m_Libs.size())
  1054 			{
  1055 				g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
  1056 				return;
  1057 			}
  1058 
  1059 			List<CExtension *>::iterator iter = m_Libs.begin();
  1060 			CExtension *pExt = NULL;
  1061 			while (iter != m_Libs.end())
  1062 			{
  1063 				if (--id == 0)
  1064 				{
  1065 					pExt = (*iter);
  1066 					break;
  1067 				}
  1068 				iter++;
  1069 			}
  1070 			/* This should never happen */
  1071 			if (!pExt)
  1072 			{
  1073 				g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
  1074 				return;
  1075 			}
  1076 
  1077 			if (!pExt->IsLoaded())
  1078 			{
  1079 				g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1080 				g_RootMenu.ConsolePrint(" Loaded: No (%s)", pExt->m_Error.c_str());
  1081 			}
  1082 			else
  1083 			{
  1084 				char error[255];
  1085 				if (!pExt->IsRunning(error, sizeof(error)))
  1086 				{
  1087 					g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1088 					g_RootMenu.ConsolePrint(" Loaded: Yes");
  1089 					g_RootMenu.ConsolePrint(" Running: No (%s)", error);
  1090 				}
  1091 				else
  1092 				{
  1093 					IExtensionInterface *pAPI = pExt->GetAPI();
  1094 					g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1095 					g_RootMenu.ConsolePrint(" Loaded: Yes (version %s)", pAPI->GetExtensionVerString());
  1096 					g_RootMenu.ConsolePrint(" Name: %s (%s)", pAPI->GetExtensionName(), pAPI->GetExtensionDescription());
  1097 					g_RootMenu.ConsolePrint(" Author: %s (%s)", pAPI->GetExtensionAuthor(), pAPI->GetExtensionURL());
  1098 					g_RootMenu.ConsolePrint(" Binary info: API version %d (compiled %s)", pAPI->GetExtensionVersion(), pAPI->GetExtensionDateString());
  1099 
  1100 					if (pExt->IsExternal())
  1101 					{
  1102 						g_RootMenu.ConsolePrint(" Method: Loaded by Metamod:Source, attached to SourceMod");
  1103 					}
  1104 					else if (pAPI->IsMetamodExtension())
  1105 					{
  1106 						g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod, attached to Metamod:Source");
  1107 					}
  1108 					else
  1109 					{
  1110 						g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod");
  1111 					}
  1112 				}
  1113 			}
  1114 			return;
  1115 		}
  1116 		else if (strcmp(cmd, "unload") == 0)
  1117 		{
  1118 			if (argcount < 4)
  1119 			{
  1120 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts unload <#> [code]");
  1121 				return;
  1122 			}
  1123 
  1124 			const char *arg = command.Arg(3);
  1125 			unsigned int num = atoi(arg);
  1126 			CExtension *pExt = FindByOrder(num);
  1127 
  1128 			if (!pExt)
  1129 			{
  1130 				g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num);
  1131 				return;
  1132 			}
  1133 
  1134 			if (argcount > 4 && pExt->unload_code)
  1135 			{
  1136 				const char *unload = command.Arg(4);
  1137 				if (pExt->unload_code == (unsigned)atoi(unload))
  1138 				{
  1139 					char filename[PLATFORM_MAX_PATH];
  1140 					snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1141 					UnloadExtension(pExt);
  1142 					g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
  1143 				}
  1144 				else
  1145 				{
  1146 					g_RootMenu.ConsolePrint("[SM] Please try again, the correct unload code is \"%d\"", pExt->unload_code);
  1147 				}
  1148 				return;
  1149 			}
  1150 
  1151 			if (!pExt->IsLoaded() 
  1152 				|| (!pExt->m_ChildDeps.size() && !pExt->m_Dependents.size()))
  1153 			{
  1154 				char filename[PLATFORM_MAX_PATH];
  1155 				snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1156 				UnloadExtension(pExt);
  1157 				g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
  1158 				return;
  1159 			}
  1160 			else
  1161 			{
  1162 				List<CPlugin *> plugins;
  1163 				if (pExt->m_ChildDeps.size())
  1164 				{
  1165 					g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename());
  1166 					List<CExtension *>::iterator iter;
  1167 					CExtension *pOther;
  1168 					/* Get list of all extensions */
  1169 					for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
  1170 					{
  1171 						List<IfaceInfo>::iterator i_iter;
  1172 						pOther = (*iter);
  1173 						if (!pOther->IsLoaded() || pOther == pExt)
  1174 						{
  1175 							continue;
  1176 						}
  1177 						/* Get their dependencies */
  1178 						for (i_iter=pOther->m_Deps.begin();
  1179 							 i_iter!=pOther->m_Deps.end();
  1180 							 i_iter++)
  1181 						{
  1182 							/* Is this dependency to us? */
  1183 							if ((*i_iter).owner != pExt)
  1184 							{
  1185 								continue;
  1186 							}
  1187 							/* Will our dependent care? */
  1188 							if (!pExt->GetAPI()->QueryInterfaceDrop((*i_iter).iface))
  1189 							{
  1190 								g_RootMenu.ConsolePrint(" -> %s", pExt->GetFilename());
  1191 								/* Add to plugin unload list */
  1192 								List<CPlugin *>::iterator p_iter;
  1193 								for (p_iter=pOther->m_Dependents.begin();
  1194 									 p_iter!=pOther->m_Dependents.end();
  1195 									 p_iter++)
  1196 								{
  1197 									if (plugins.find((*p_iter)) == plugins.end())
  1198 									{
  1199 										plugins.push_back((*p_iter));
  1200 									}
  1201 								}
  1202 							}
  1203 						}
  1204 					}
  1205 				}
  1206 				if (pExt->m_Dependents.size())
  1207 				{
  1208 					g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename());
  1209 					List<CPlugin *>::iterator iter;
  1210 					CPlugin *pPlugin;
  1211 					for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++)
  1212 					{
  1213 						pPlugin = (*iter);
  1214 						if (plugins.find(pPlugin) == plugins.end())
  1215 						{
  1216 							plugins.push_back(pPlugin);
  1217 						}
  1218 					}
  1219 					for (iter = plugins.begin(); iter != plugins.end(); iter++)
  1220 					{
  1221 						pPlugin = (*iter);
  1222 						g_RootMenu.ConsolePrint(" -> %s", pPlugin->GetFilename());
  1223 					}
  1224 				}
  1225 				srand(static_cast<int>(time(NULL)));
  1226 				pExt->unload_code = (rand() % 877) + 123;	//123 to 999
  1227 				g_RootMenu.ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename());
  1228 				g_RootMenu.ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code);
  1229 
  1230 				return;
  1231 			}
  1232 		}
  1233 		else if (strcmp(cmd, "reload") == 0)
  1234 		{
  1235 			if (argcount < 4)
  1236 			{
  1237 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts reload <#>");
  1238 				return;
  1239 			}
  1240 			
  1241 			const char *arg = command.Arg(3);
  1242 			unsigned int num = atoi(arg);
  1243 			CExtension *pExt = FindByOrder(num);
  1244 
  1245 			if (!pExt)
  1246 			{
  1247 				g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num);
  1248 				return;
  1249 			}
  1250 			
  1251 			if (pExt->IsLoaded())
  1252 			{
  1253 				char filename[PLATFORM_MAX_PATH];
  1254 				char error[255];
  1255 				
  1256 				snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1257 				
  1258 				if (pExt->Reload(error, sizeof(error)))
  1259 				{
  1260 					g_RootMenu.ConsolePrint("[SM] Extension %s is now reloaded.", filename);
  1261 				}
  1262 				else
  1263 				{
  1264 					g_RootMenu.ConsolePrint("[SM] Extension %s failed to reload: %s", filename, error);
  1265 				}
  1266 					
  1267 				return;
  1268 			} 
  1269 			else
  1270 			{
  1271 				g_RootMenu.ConsolePrint("[SM] Extension %s is not loaded.", pExt->GetFilename());
  1272 				
  1273 				return;
  1274 			}
  1275 			
  1276 		}
  1277 	}
  1278 
  1279 	g_RootMenu.ConsolePrint("SourceMod Extensions Menu:");
  1280 	g_RootMenu.DrawGenericOption("info", "Extra extension information");
  1281 	g_RootMenu.DrawGenericOption("list", "List extensions");
  1282 	g_RootMenu.DrawGenericOption("load", "Load an extension");
  1283 	g_RootMenu.DrawGenericOption("reload", "Reload an extension");
  1284 	g_RootMenu.DrawGenericOption("unload", "Unload an extension");
  1285 }
  1286 
  1287 CExtension *CExtensionManager::GetExtensionFromIdent(IdentityToken_t *ptr)
  1288 {
  1289 	if (ptr->type == g_ExtType)
  1290 	{
  1291 		return (CExtension *)(ptr->ptr);
  1292 	}
  1293 
  1294 	return NULL;
  1295 }
  1296 
  1297 CExtensionManager::CExtensionManager()
  1298 {
  1299 }
  1300 
  1301 CExtensionManager::~CExtensionManager()
  1302 {
  1303 }
  1304 
  1305 void CExtensionManager::AddLibrary(IExtension *pSource, const char *library)
  1306 {
  1307 	CExtension *pExt = (CExtension *)pSource;
  1308 	pExt->AddLibrary(library);
  1309 	g_PluginSys.OnLibraryAction(library, false, false);
  1310 }
  1311 
  1312 bool CExtensionManager::LibraryExists(const char *library)
  1313 {
  1314 	CExtension *pExt;
  1315 
  1316 	for (List<CExtension *>::iterator iter = m_Libs.begin();
  1317 		 iter != m_Libs.end();
  1318 		 iter++)
  1319 	{
  1320 		pExt = (*iter);
  1321 		for (List<String>::iterator s_iter = pExt->m_Libraries.begin();
  1322 			 s_iter != pExt->m_Libraries.end();
  1323 			 s_iter++)
  1324 		{
  1325 			if ((*s_iter).compare(library) == 0)
  1326 			{
  1327 				return true;
  1328 			}
  1329 		}
  1330 	}
  1331 
  1332 	return false;
  1333 }
  1334 
  1335 IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface,
  1336 											const char *filepath,
  1337 											const char *filename,
  1338 											char *error,
  1339 											size_t maxlength)
  1340 {
  1341 	IExtension *pAlready;
  1342 	if ((pAlready=FindExtensionByFile(filename)) != NULL)
  1343 	{
  1344 		return pAlready;
  1345 	}
  1346 
  1347 	CExtension *pExt = new CRemoteExtension(pInterface, filename, filepath);
  1348 
  1349 	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
  1350 	{
  1351 		pExt->Unload();
  1352 		delete pExt;
  1353 		return NULL;
  1354 	}
  1355 
  1356 	m_Libs.push_back(pExt);
  1357 
  1358 	return pExt;
  1359 }
  1360 
  1361 void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
  1362 {
  1363 	IExtensionInterface *pAPI;
  1364 	List<CExtension *>::iterator iter;
  1365 
  1366 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
  1367 	{
  1368 		if ((pAPI = (*iter)->GetAPI()) == NULL)
  1369 		{
  1370 			continue;
  1371 		}
  1372 		if (pAPI->GetExtensionVersion() > 3)
  1373 		{
  1374 			pAPI->OnCoreMapStart(pEdictList, edictCount, clientMax);
  1375 		}
  1376 	}
  1377 }
  1378 
  1379 bool CLocalExtension::IsSameFile(const char *file)
  1380 {
  1381 	/* Only care about the shortened name. */
  1382 	return strcmp(file, m_File.c_str()) == 0;
  1383 }
  1384 
  1385 bool CRemoteExtension::IsSameFile(const char *file)
  1386 {
  1387 	/* :TODO: this could be better, but no one uses this API anyway. */
  1388 	return strcmp(file, m_Path.c_str()) == 0;
  1389 }
  1390