extensions can now be built for multiple engines, and will autoload from auto.X.Y folders
3 * =============================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * =============================================================================
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.
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
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/>.
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>.
33 #include "ExtensionSys.h"
34 #include "LibrarySys.h"
37 #include "sourcemm_api.h"
38 #include "sm_srvcmds.h"
39 #include "sm_stringutil.h"
41 CExtensionManager g_Extensions;
42 IdentityType_t g_ExtType;
44 CExtension::CExtension(const char *filename, char *error, size_t maxlength)
46 m_File.assign(filename);
51 m_FullyLoaded = false;
53 char path[PLATFORM_MAX_PATH];
55 /* First see if there is an engine specific build! */
56 g_SourceMod.BuildPath(Path_SM,
59 #if defined METAMOD_PLAPI_VERSION
60 #if defined ORANGEBOX_BUILD
61 "extensions/auto.2.ep2/%s",
63 "extensions/auto.2.ep1/%s",
64 #endif //ORANGEBOX_BUILD
65 #else //METAMOD_PLAPI_VERSION
66 "extensions/auto.1.ep1/%s",
67 #endif //METAMOD_PLAPI_VERSION
70 /* Try the "normal" version */
71 if (!g_LibSys.IsPathFile(path))
73 g_SourceMod.BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "extensions/%s", filename);
81 bool CExtension::Load(char *error, size_t maxlength)
83 m_pLib = g_LibSys.OpenLibrary(m_Path.c_str(), error, maxlength);
90 typedef IExtensionInterface *(*GETAPI)();
91 GETAPI pfnGetAPI = NULL;
93 if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
95 m_pLib->CloseLibrary();
97 snprintf(error, maxlength, "Unable to find extension entry point");
101 m_pAPI = pfnGetAPI();
102 if (!m_pAPI || m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
104 m_pLib->CloseLibrary();
106 snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
110 if (m_pAPI->IsMetamodExtension())
113 m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength);
116 m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType, this);
118 if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading()))
120 if (m_pAPI->IsMetamodExtension())
125 g_pMMPlugins->Unload(m_PlId, true, dummy, sizeof(dummy));
130 m_pLib->CloseLibrary();
132 g_ShareSys.DestroyIdentity(m_pIdentToken);
133 m_pIdentToken = NULL;
136 /* Check if we're past load time */
137 if (!g_SourceMod.IsMapLoading())
139 m_pAPI->OnExtensionsAllLoaded();
146 CExtension::~CExtension()
148 char temp_buffer[255];
154 g_pMMPlugins->Unload(m_PlId, true, temp_buffer, sizeof(temp_buffer));
160 g_ShareSys.DestroyIdentity(m_pIdentToken);
165 m_pLib->CloseLibrary();
169 void CExtension::MarkAllLoaded()
171 assert(m_FullyLoaded == false);
174 m_FullyLoaded = true;
175 m_pAPI->OnExtensionsAllLoaded();
179 void CExtension::AddPlugin(IPlugin *pPlugin)
181 /* Unfortunately we have to do this :( */
182 if (m_Plugins.find(pPlugin) != m_Plugins.end())
184 m_Plugins.push_back(pPlugin);
188 void CExtension::RemovePlugin(IPlugin *pPlugin)
190 m_Plugins.remove(pPlugin);
192 List<WeakNative>::iterator iter = m_WeakNatives.begin();
193 while (iter != m_WeakNatives.end())
195 if ((*iter).pl == pPlugin)
197 iter = m_WeakNatives.erase(iter);
204 void CExtension::SetError(const char *error)
206 m_Error.assign(error);
209 IExtensionInterface *CExtension::GetAPI()
214 const char *CExtension::GetFilename()
216 return m_File.c_str();
219 IdentityToken_t *CExtension::GetIdentity()
221 return m_pIdentToken;
224 bool CExtension::IsLoaded()
226 return (m_pLib != NULL);
229 void CExtension::AddDependency(IfaceInfo *pInfo)
231 if (m_Deps.find(*pInfo) == m_Deps.end())
233 m_Deps.push_back(*pInfo);
237 bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
239 return (i1.iface == i2.iface) && (i1.owner == i2.owner);
242 void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
248 List<IfaceInfo>::iterator iter;
249 for (iter = m_ChildDeps.begin();
250 iter != m_ChildDeps.end();
253 IfaceInfo &other = (*iter);
260 m_ChildDeps.push_back(info);
263 ITERATOR *CExtension::FindFirstDependency(IExtension **pOwner, SMInterface **pInterface)
265 List<IfaceInfo>::iterator iter = m_Deps.begin();
267 if (iter == m_Deps.end())
274 *pOwner = (*iter).owner;
278 *pInterface = (*iter).iface;
281 List<IfaceInfo>::iterator *pIter = new List<IfaceInfo>::iterator(iter);
283 return (ITERATOR *)pIter;
286 bool CExtension::FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface)
288 List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
289 List<IfaceInfo>::iterator _iter;
291 if (_iter == m_Deps.end())
300 *pOwner = (*_iter).owner;
304 *pInterface = (*_iter).iface;
309 if (_iter == m_Deps.end())
317 void CExtension::FreeDependencyIterator(ITERATOR *iter)
319 List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
324 void CExtension::AddInterface(SMInterface *pInterface)
326 m_Interfaces.push_back(pInterface);
329 bool CExtension::IsRunning(char *error, size_t maxlength)
335 snprintf(error, maxlength, "%s", m_Error.c_str());
340 return m_pAPI->QueryRunning(error, maxlength);
343 /*********************
344 * EXTENSION MANAGER *
345 *********************/
347 void CExtensionManager::OnSourceModAllInitialized()
349 g_ExtType = g_ShareSys.CreateIdentType("EXTENSION");
350 g_PluginSys.AddPluginsListener(this);
351 g_RootMenu.AddRootConsoleCommand("exts", "Manage extensions", this);
352 g_ShareSys.AddInterface(NULL, this);
355 void CExtensionManager::OnSourceModShutdown()
357 g_RootMenu.RemoveRootConsoleCommand("exts", this);
358 g_ShareSys.DestroyIdentType(g_ExtType);
361 void CExtensionManager::Shutdown()
363 List<CExtension *>::iterator iter;
365 while ((iter = m_Libs.begin()) != m_Libs.end())
367 UnloadExtension((*iter));
371 void CExtensionManager::TryAutoload()
373 char path[PLATFORM_MAX_PATH];
375 g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "extensions");
377 IDirectory *pDir = g_LibSys.OpenDirectory(path);
385 while (pDir->MoreFiles())
387 if (pDir->IsEntryDirectory())
393 lfile = pDir->GetEntryName();
395 if (len <= 9) /* size of ".autoload" */
401 if (strcmp(&lfile[len - 9], ".autoload") != 0)
407 char file[PLATFORM_MAX_PATH];
408 len = UTIL_Format(file, sizeof(file), "%s", lfile);
409 strcpy(&file[len - 9], ".ext." PLATFORM_LIB_EXT);
411 LoadAutoExtension(file);
417 IExtension *CExtensionManager::LoadAutoExtension(const char *path)
419 if (!strstr(path, "." PLATFORM_LIB_EXT))
421 char newpath[PLATFORM_MAX_PATH];
422 g_LibSys.PathFormat(newpath, sizeof(newpath), "%s.%s", path, PLATFORM_LIB_EXT);
423 return LoadAutoExtension(newpath);
426 IExtension *pAlready;
427 if ((pAlready=FindExtensionByFile(path)) != NULL)
433 CExtension *p = new CExtension(path, error, sizeof(error));
435 /* We put us in the list beforehand so extensions that check for each other
436 * won't recursively load each other.
440 if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
442 g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
449 IExtension *CExtensionManager::FindExtensionByFile(const char *file)
451 List<CExtension *>::iterator iter;
454 if (!strstr(file, "." PLATFORM_LIB_EXT))
456 char path[PLATFORM_MAX_PATH];
457 UTIL_Format(path, sizeof(path), "%s.%s", file, PLATFORM_LIB_EXT);
458 return FindExtensionByFile(path);
461 /* Chomp off the path */
462 char lookup[PLATFORM_MAX_PATH];
463 g_LibSys.GetFileFromPath(lookup, sizeof(lookup), file);
465 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
468 char short_file[PLATFORM_MAX_PATH];
469 g_LibSys.GetFileFromPath(short_file, sizeof(short_file), pExt->GetFilename());
470 if (strcmp(lookup, short_file) == 0)
479 IExtension *CExtensionManager::FindExtensionByName(const char *ext)
481 List<CExtension *>::iterator iter;
483 IExtensionInterface *pAPI;
486 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
489 if (!pExt->IsLoaded())
493 if ((pAPI = pExt->GetAPI()) == NULL)
497 name = pAPI->GetExtensionName();
502 if (strcmp(name, ext) == 0)
511 IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t maxlength)
513 IExtension *pAlready;
514 if ((pAlready=FindExtensionByFile(file)) != NULL)
519 CExtension *pExt = new CExtension(file, error, maxlength);
521 /* :NOTE: lifetime is currently ignored */
523 if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
529 /* :TODO: do QueryRunning check if the map is loaded */
531 m_Libs.push_back(pExt);
536 void CExtensionManager::BindDependency(IExtension *pRequester, IfaceInfo *pInfo)
538 CExtension *pExt = (CExtension *)pRequester;
539 CExtension *pOwner = (CExtension *)pInfo->owner;
541 pExt->AddDependency(pInfo);
543 IExtensionInterface *pAPI = pExt->GetAPI();
544 if (pAPI && !pAPI->QueryInterfaceDrop(pInfo->iface))
546 pOwner->AddChildDependent(pExt, pInfo->iface);
550 void CExtensionManager::AddInterface(IExtension *pOwner, SMInterface *pInterface)
552 CExtension *pExt = (CExtension *)pOwner;
554 pExt->AddInterface(pInterface);
557 void CExtensionManager::BindChildPlugin(IExtension *pParent, IPlugin *pPlugin)
559 CExtension *pExt = (CExtension *)pParent;
561 pExt->AddPlugin(pPlugin);
564 void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
566 List<CExtension *>::iterator iter;
568 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
570 (*iter)->RemovePlugin(plugin);
574 CExtension *CExtensionManager::FindByOrder(unsigned int num)
576 if (num < 1 || num > m_Libs.size())
581 List<CExtension *>::iterator iter = m_Libs.begin();
583 while (iter != m_Libs.end())
595 void CExtensionManager::BindAllNativesToPlugin(IPlugin *pPlugin)
597 IPluginContext *pContext = pPlugin->GetBaseContext();
599 List<CExtension *> exts;
601 uint32_t natives = pContext->GetNativesNum();
603 sm_extnative_t *x_native;
604 for (uint32_t i=0; i<natives; i++)
606 /* Make sure the native is valid */
607 if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
611 /* Make sure the native is not already bound */
612 if (native->status == SP_NATIVE_BOUND)
616 /* See if we've got this native in our cache */
617 if ((x_native = m_ExtNatives.retrieve(native->name)) == NULL)
621 /* Try and bind it */
622 if (pContext->BindNativeToIndex(i, x_native->info->func) != SP_ERROR_NONE)
626 /* See if it's optional */
627 if (native->flags & SP_NTVFLAG_OPTIONAL)
629 WeakNative wkn = WeakNative((CPlugin *)pPlugin, i);
630 x_native->owner->m_WeakNatives.push_back(wkn);
631 } else if (exts.find(x_native->owner) == exts.end()) {
632 exts.push_back(x_native->owner);
636 List<CExtension *>::iterator iter;
637 for (iter = exts.begin(); iter != exts.end(); iter++)
639 CExtension *pExt = (*iter);
640 if (pExt->m_Plugins.find(pPlugin) != pExt->m_Plugins.end())
644 pExt->m_Plugins.push_back(pPlugin);
648 bool CExtensionManager::UnloadExtension(IExtension *_pExt)
655 CExtension *pExt = (CExtension *)_pExt;
657 if (m_Libs.find(pExt) == m_Libs.end())
662 /* First remove us from internal lists */
663 g_ShareSys.RemoveInterfaces(_pExt);
666 List<CExtension *> UnloadQueue;
668 /* Handle dependencies */
669 if (pExt->IsLoaded())
671 /* Unload any dependent plugins */
672 List<IPlugin *>::iterator p_iter = pExt->m_Plugins.begin();
673 while (p_iter != pExt->m_Plugins.end())
675 /* We have to manually unlink ourselves here, since we're no longer being managed */
676 g_PluginSys.UnloadPlugin((*p_iter));
677 p_iter = pExt->m_Plugins.erase(p_iter);
680 /* Unbound weak natives */
681 List<WeakNative>::iterator wkn_iter;
682 for (wkn_iter=pExt->m_WeakNatives.begin(); wkn_iter!=pExt->m_WeakNatives.end(); wkn_iter++)
684 WeakNative & wkn = (*wkn_iter);
685 sp_context_t *ctx = wkn.pl->GetContext();
686 ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
689 /* Notify and/or unload all dependencies */
690 List<CExtension *>::iterator c_iter;
692 IExtensionInterface *pAPI;
693 for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
696 if ((pAPI=pDep->GetAPI()) == NULL)
704 /* Now, get its dependency list */
705 bool dropped = false;
706 List<IfaceInfo>::iterator i_iter = pDep->m_Deps.begin();
707 while (i_iter != pDep->m_Deps.end())
709 if ((*i_iter).owner == _pExt)
711 if (!pAPI->QueryInterfaceDrop((*i_iter).iface))
716 UnloadQueue.push_back(pDep);
719 pAPI->NotifyInterfaceDrop((*i_iter).iface);
720 i_iter = pDep->m_Deps.erase(i_iter);
725 /* Flush out any back references to this plugin */
726 i_iter = pDep->m_ChildDeps.begin();
727 while (i_iter != pDep->m_ChildDeps.end())
729 if ((*i_iter).owner == pExt)
731 i_iter = pDep->m_ChildDeps.erase(i_iter);
738 /* Unbind our natives from Core */
739 List<const sp_nativeinfo_t *>::iterator native_iter;
740 for (native_iter = pExt->m_Natives.begin();
741 native_iter != pExt->m_Natives.end();
744 const sp_nativeinfo_t *natives = (*native_iter);
745 sm_extnative_t *x_native;
746 for (unsigned int n = 0;
747 natives[n].name != NULL && natives[n].func != NULL;
750 x_native = m_ExtNatives.retrieve(natives[n].name);
751 if (x_native && x_native->owner == pExt)
753 m_ExtNatives.remove(natives[n].name);
758 /* Tell it to unload */
759 pAPI = pExt->GetAPI();
760 pAPI->OnExtensionUnload();
763 IdentityToken_t *pIdentity;
764 if ((pIdentity = pExt->GetIdentity()) != NULL)
766 SMGlobalClass *glob = SMGlobalClass::head;
769 glob->OnSourceModIdentityDropped(pIdentity);
770 glob = glob->m_pGlobalClassNext;
776 List<CExtension *>::iterator iter;
777 for (iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++)
779 /* NOTE: This is safe because the unload function backs out of anything not present */
780 UnloadExtension((*iter));
786 void CExtensionManager::AddNatives(IExtension *pOwner, const sp_nativeinfo_t *natives)
788 CExtension *pExt = (CExtension *)pOwner;
790 pExt->m_Natives.push_back(natives);
792 for (unsigned int i = 0; natives[i].func != NULL && natives[i].name != NULL; i++)
794 if (m_ExtNatives.retrieve(natives[i].name) != NULL)
798 sm_extnative_t x_native;
799 x_native.info = &natives[i];
800 x_native.owner = pExt;
801 m_ExtNatives.insert(natives[i].name, x_native);
805 void CExtensionManager::MarkAllLoaded()
807 List<CExtension *>::iterator iter;
810 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
813 if (!pExt->IsLoaded())
817 if (pExt->m_FullyLoaded)
821 pExt->MarkAllLoaded();
825 void CExtensionManager::AddDependency(IExtension *pSource, const char *file, bool required, bool autoload)
827 /* This function doesn't really need to do anything now. We make sure the
828 * other extension is loaded, but handling of dependencies is really done
829 * by the interface fetcher.
831 if (required || autoload)
833 LoadAutoExtension(file);
837 void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
839 int argcount = command.ArgC();
842 const char *cmd = command.Arg(2);
843 if (strcmp(cmd, "list") == 0)
845 List<CExtension *>::iterator iter;
847 unsigned int num = 1;
848 switch (m_Libs.size())
852 g_RootMenu.ConsolePrint("[SM] Displaying 1 extension:");
857 g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
862 g_RootMenu.ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
866 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
869 if (pExt->IsLoaded())
872 if (!pExt->IsRunning(error, sizeof(error)))
874 g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
876 IExtensionInterface *pAPI = pExt->GetAPI();
877 const char *name = pAPI->GetExtensionName();
878 const char *version = pAPI->GetExtensionVerString();
879 const char *descr = pAPI->GetExtensionDescription();
880 g_RootMenu.ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
883 g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
887 } else if (strcmp(cmd, "info") == 0) {
890 g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>");
894 const char *sId = command.Arg(3);
895 unsigned int id = atoi(sId);
898 g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>");
902 if (m_Libs.size() == 0)
904 g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
908 if (id > m_Libs.size())
910 g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
914 List<CExtension *>::iterator iter = m_Libs.begin();
915 CExtension *pExt = NULL;
916 while (iter != m_Libs.end())
925 /* This should never happen */
928 g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
932 if (!pExt->IsLoaded())
934 g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
935 g_RootMenu.ConsolePrint(" Loaded: No (%s)", pExt->m_Error.c_str());
938 if (!pExt->IsRunning(error, sizeof(error)))
940 g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
941 g_RootMenu.ConsolePrint(" Loaded: Yes");
942 g_RootMenu.ConsolePrint(" Running: No (%s)", error);
944 IExtensionInterface *pAPI = pExt->GetAPI();
945 g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
946 g_RootMenu.ConsolePrint(" Loaded: Yes (version %s)", pAPI->GetExtensionVerString());
947 g_RootMenu.ConsolePrint(" Name: %s (%s)", pAPI->GetExtensionName(), pAPI->GetExtensionDescription());
948 g_RootMenu.ConsolePrint(" Author: %s (%s)", pAPI->GetExtensionAuthor(), pAPI->GetExtensionURL());
949 g_RootMenu.ConsolePrint(" Binary info: API version %d (compiled %s)", pAPI->GetExtensionVersion(), pAPI->GetExtensionDateString());
950 g_RootMenu.ConsolePrint(" Metamod enabled: %s", pAPI->IsMetamodExtension() ? "yes" : "no");
954 } else if (strcmp(cmd, "unload") == 0) {
957 g_RootMenu.ConsolePrint("[SM] Usage: sm unload <#> [code]");
961 const char *arg = command.Arg(3);
962 unsigned int num = atoi(arg);
963 CExtension *pExt = FindByOrder(num);
967 g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num);
971 if (argcount > 4 && pExt->unload_code)
973 const char *unload = command.Arg(4);
974 if (pExt->unload_code == (unsigned)atoi(unload))
976 char filename[PLATFORM_MAX_PATH];
977 snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
978 UnloadExtension(pExt);
979 g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
983 g_RootMenu.ConsolePrint("[SM] Please try again, the correct unload code is \"%d\"", pExt->unload_code);
988 if (!pExt->IsLoaded()
989 || (!pExt->m_ChildDeps.size() && !pExt->m_Plugins.size()))
991 char filename[PLATFORM_MAX_PATH];
992 snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
993 UnloadExtension(pExt);
994 g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
999 List<IPlugin *> plugins;
1000 if (pExt->m_ChildDeps.size())
1002 g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename());
1003 List<CExtension *>::iterator iter;
1005 /* Get list of all extensions */
1006 for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
1008 List<IfaceInfo>::iterator i_iter;
1010 if (!pOther->IsLoaded() || pOther == pExt)
1014 /* Get their dependencies */
1015 for (i_iter=pOther->m_Deps.begin();
1016 i_iter!=pOther->m_Deps.end();
1019 /* Is this dependency to us? */
1020 if ((*i_iter).owner != pExt)
1024 /* Will our dependent care? */
1025 if (!pExt->GetAPI()->QueryInterfaceDrop((*i_iter).iface))
1027 g_RootMenu.ConsolePrint(" -> %s", pExt->GetFilename());
1028 /* Add to plugin unload list */
1029 List<IPlugin *>::iterator p_iter;
1030 for (p_iter=pOther->m_Plugins.begin();
1031 p_iter!=pOther->m_Plugins.end();
1034 if (plugins.find((*p_iter)) == plugins.end())
1036 plugins.push_back((*p_iter));
1043 if (pExt->m_Plugins.size())
1045 g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename());
1046 List<IPlugin *>::iterator iter;
1048 for (iter = pExt->m_Plugins.begin(); iter != pExt->m_Plugins.end(); iter++)
1051 if (plugins.find(pPlugin) == plugins.end())
1053 plugins.push_back(pPlugin);
1056 for (iter = plugins.begin(); iter != plugins.end(); iter++)
1059 g_RootMenu.ConsolePrint(" -> %s", pPlugin->GetFilename());
1062 srand(static_cast<int>(time(NULL)));
1063 pExt->unload_code = (rand() % 877) + 123; //123 to 999
1064 g_RootMenu.ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename());
1065 g_RootMenu.ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code);
1072 g_RootMenu.ConsolePrint("SourceMod Extensions Menu:");
1073 g_RootMenu.DrawGenericOption("info", "Extra extension information");
1074 g_RootMenu.DrawGenericOption("list", "List extensions");
1075 g_RootMenu.DrawGenericOption("unload", "Unload an extension");
1078 CExtension *CExtensionManager::GetExtensionFromIdent(IdentityToken_t *ptr)
1080 if (ptr->type == g_ExtType)
1082 return (CExtension *)(ptr->ptr);
1088 CExtensionManager::CExtensionManager()
1092 CExtensionManager::~CExtensionManager()