Strip sourcehook containers (#2578)
This commit is contained in:
+39
-54
@@ -356,7 +356,7 @@ void CExtension::MarkAllLoaded()
|
||||
void CExtension::AddPlugin(CPlugin *pPlugin)
|
||||
{
|
||||
/* Unfortunately we have to do this :( */
|
||||
if (m_Dependents.find(pPlugin) == m_Dependents.end())
|
||||
if (std::find(m_Dependents.begin(), m_Dependents.end(), pPlugin) == m_Dependents.end())
|
||||
{
|
||||
m_Dependents.push_back(pPlugin);
|
||||
}
|
||||
@@ -399,7 +399,7 @@ bool CLocalExtension::IsLoaded()
|
||||
|
||||
void CExtension::AddDependency(const IfaceInfo *pInfo)
|
||||
{
|
||||
if (m_Deps.find(*pInfo) == m_Deps.end())
|
||||
if (std::find(m_Deps.begin(), m_Deps.end(), *pInfo) == m_Deps.end())
|
||||
{
|
||||
m_Deps.push_back(*pInfo);
|
||||
}
|
||||
@@ -411,8 +411,7 @@ void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
|
||||
info.iface = iface;
|
||||
info.owner = pOther;
|
||||
|
||||
List<IfaceInfo>::iterator iter;
|
||||
for (iter = m_ChildDeps.begin();
|
||||
for (auto iter = m_ChildDeps.begin();
|
||||
iter != m_ChildDeps.end();
|
||||
iter++)
|
||||
{
|
||||
@@ -492,11 +491,9 @@ void CExtensionManager::OnSourceModShutdown()
|
||||
|
||||
void CExtensionManager::Shutdown()
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
|
||||
while ((iter = m_Libs.begin()) != m_Libs.end())
|
||||
while (m_Libs.begin() != m_Libs.end())
|
||||
{
|
||||
UnloadExtension((*iter));
|
||||
UnloadExtension((*m_Libs.begin()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,14 +582,13 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn
|
||||
|
||||
IExtension *CExtensionManager::FindExtensionByFile(const char *file)
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
CExtension *pExt;
|
||||
|
||||
/* Chomp off the path */
|
||||
char lookup[PLATFORM_MAX_PATH];
|
||||
libsys->GetFileFromPath(lookup, sizeof(lookup), file);
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
pExt = (*iter);
|
||||
if (pExt->IsSameFile(lookup))
|
||||
@@ -606,12 +602,11 @@ IExtension *CExtensionManager::FindExtensionByFile(const char *file)
|
||||
|
||||
IExtension *CExtensionManager::FindExtensionByName(const char *ext)
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
CExtension *pExt;
|
||||
IExtensionInterface *pAPI;
|
||||
const char *name;
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
pExt = (*iter);
|
||||
if (!pExt->IsLoaded())
|
||||
@@ -720,9 +715,7 @@ void CExtensionManager::BindChildPlugin(IExtension *pParent, SMPlugin *pPlugin)
|
||||
|
||||
void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
(*iter)->DropRefsTo(static_cast<CPlugin *>(plugin));
|
||||
}
|
||||
@@ -735,7 +728,7 @@ CExtension *CExtensionManager::FindByOrder(unsigned int num)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
List<CExtension *>::iterator iter = m_Libs.begin();
|
||||
auto iter = m_Libs.begin();
|
||||
|
||||
while (iter != m_Libs.end())
|
||||
{
|
||||
@@ -756,7 +749,8 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
|
||||
CExtension *pExt = (CExtension *)_pExt;
|
||||
|
||||
if (m_Libs.find(pExt) == m_Libs.end())
|
||||
auto iter = std::find(m_Libs.begin(), m_Libs.end(), pExt);
|
||||
if (iter == m_Libs.end())
|
||||
return false;
|
||||
|
||||
/* Tell it to unload */
|
||||
@@ -770,13 +764,13 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
g_ShareSys.RemoveInterfaces(_pExt);
|
||||
m_Libs.remove(pExt);
|
||||
|
||||
List<CExtension *> UnloadQueue;
|
||||
std::list<CExtension *> UnloadQueue;
|
||||
|
||||
/* Handle dependencies */
|
||||
if (pExt->IsLoaded())
|
||||
{
|
||||
/* Unload any dependent plugins */
|
||||
List<CPlugin *>::iterator p_iter = pExt->m_Dependents.begin();
|
||||
auto p_iter = pExt->m_Dependents.begin();
|
||||
while (p_iter != pExt->m_Dependents.end())
|
||||
{
|
||||
/* We have to manually unlink ourselves here, since we're no longer being managed */
|
||||
@@ -784,8 +778,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
p_iter = pExt->m_Dependents.erase(p_iter);
|
||||
}
|
||||
|
||||
List<String>::iterator s_iter;
|
||||
for (s_iter = pExt->m_Libraries.begin();
|
||||
for (auto s_iter = pExt->m_Libraries.begin();
|
||||
s_iter != pExt->m_Libraries.end();
|
||||
s_iter++)
|
||||
{
|
||||
@@ -793,10 +786,9 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
}
|
||||
|
||||
/* Notify and/or unload all dependencies */
|
||||
List<CExtension *>::iterator c_iter;
|
||||
CExtension *pDep;
|
||||
IExtensionInterface *pAPI;
|
||||
for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
|
||||
for (auto c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
|
||||
{
|
||||
pDep = (*c_iter);
|
||||
if ((pAPI=pDep->GetAPI()) == NULL)
|
||||
@@ -805,7 +797,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
continue;
|
||||
/* Now, get its dependency list */
|
||||
bool dropped = false;
|
||||
List<IfaceInfo>::iterator i_iter = pDep->m_Deps.begin();
|
||||
auto i_iter = pDep->m_Deps.begin();
|
||||
while (i_iter != pDep->m_Deps.end())
|
||||
{
|
||||
if ((*i_iter).owner == _pExt)
|
||||
@@ -860,8 +852,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
pExt->Unload();
|
||||
delete pExt;
|
||||
|
||||
List<CExtension *>::iterator iter;
|
||||
for (iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++)
|
||||
for (auto iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++)
|
||||
{
|
||||
/* NOTE: This is safe because the unload function backs out of anything not present */
|
||||
UnloadExtension((*iter));
|
||||
@@ -872,10 +863,9 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
||||
|
||||
void CExtensionManager::MarkAllLoaded()
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
CExtension *pExt;
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
pExt = (*iter);
|
||||
if (!pExt->IsLoaded())
|
||||
@@ -910,7 +900,6 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
const char *cmd = command->Arg(2);
|
||||
if (strcmp(cmd, "list") == 0)
|
||||
{
|
||||
List<CExtension *>::iterator iter;
|
||||
CExtension *pExt;
|
||||
unsigned int num = 1;
|
||||
|
||||
@@ -932,7 +921,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (iter = m_Libs.begin(); iter != m_Libs.end(); iter++,num++)
|
||||
for (auto iter = m_Libs.begin(); iter != m_Libs.end(); iter++,num++)
|
||||
{
|
||||
pExt = (*iter);
|
||||
if (pExt->IsLoaded())
|
||||
@@ -1021,7 +1010,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
return;
|
||||
}
|
||||
|
||||
List<CExtension *>::iterator iter = m_Libs.begin();
|
||||
auto iter = m_Libs.begin();
|
||||
CExtension *pExt = NULL;
|
||||
while (iter != m_Libs.end())
|
||||
{
|
||||
@@ -1124,23 +1113,21 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
}
|
||||
else
|
||||
{
|
||||
List<CPlugin *> plugins;
|
||||
std::list<CPlugin *> plugins;
|
||||
if (pExt->m_ChildDeps.size())
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename());
|
||||
List<CExtension *>::iterator iter;
|
||||
CExtension *pOther;
|
||||
/* Get list of all extensions */
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
List<IfaceInfo>::iterator i_iter;
|
||||
pOther = (*iter);
|
||||
if (!pOther->IsLoaded() || pOther == pExt)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Get their dependencies */
|
||||
for (i_iter=pOther->m_Deps.begin();
|
||||
for (auto i_iter=pOther->m_Deps.begin();
|
||||
i_iter!=pOther->m_Deps.end();
|
||||
i_iter++)
|
||||
{
|
||||
@@ -1154,12 +1141,12 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
{
|
||||
rootmenu->ConsolePrint(" -> %s", pOther->GetFilename());
|
||||
/* Add to plugin unload list */
|
||||
List<CPlugin *>::iterator p_iter;
|
||||
for (p_iter=pOther->m_Dependents.begin();
|
||||
for (auto p_iter=pOther->m_Dependents.begin();
|
||||
p_iter!=pOther->m_Dependents.end();
|
||||
p_iter++)
|
||||
{
|
||||
if (plugins.find((*p_iter)) == plugins.end())
|
||||
auto lookup = std::find(plugins.begin(), plugins.end(), (*p_iter));
|
||||
if (lookup == plugins.end())
|
||||
{
|
||||
plugins.push_back((*p_iter));
|
||||
}
|
||||
@@ -1171,17 +1158,17 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
|
||||
if (pExt->m_Dependents.size())
|
||||
{
|
||||
rootmenu->ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename());
|
||||
List<CPlugin *>::iterator iter;
|
||||
CPlugin *pPlugin;
|
||||
for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++)
|
||||
for (auto iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++)
|
||||
{
|
||||
pPlugin = (*iter);
|
||||
if (plugins.find(pPlugin) == plugins.end())
|
||||
auto lookup = std::find(plugins.begin(), plugins.end(), pPlugin);
|
||||
if (lookup == plugins.end())
|
||||
{
|
||||
plugins.push_back(pPlugin);
|
||||
}
|
||||
}
|
||||
for (iter = plugins.begin(); iter != plugins.end(); iter++)
|
||||
for (auto iter = plugins.begin(); iter != plugins.end(); iter++)
|
||||
{
|
||||
pPlugin = (*iter);
|
||||
rootmenu->ConsolePrint(" -> %s", pPlugin->GetFilename());
|
||||
@@ -1277,12 +1264,12 @@ bool CExtensionManager::LibraryExists(const char *library)
|
||||
{
|
||||
CExtension *pExt;
|
||||
|
||||
for (List<CExtension *>::iterator iter = m_Libs.begin();
|
||||
for (auto iter = m_Libs.begin();
|
||||
iter != m_Libs.end();
|
||||
iter++)
|
||||
{
|
||||
pExt = (*iter);
|
||||
for (List<String>::iterator s_iter = pExt->m_Libraries.begin();
|
||||
for (auto s_iter = pExt->m_Libraries.begin();
|
||||
s_iter != pExt->m_Libraries.end();
|
||||
s_iter++)
|
||||
{
|
||||
@@ -1325,9 +1312,8 @@ IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface,
|
||||
void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
IExtensionInterface *pAPI;
|
||||
List<CExtension *>::iterator iter;
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
if ((pAPI = (*iter)->GetAPI()) == NULL)
|
||||
{
|
||||
@@ -1343,9 +1329,8 @@ void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount,
|
||||
void CExtensionManager::CallOnCoreMapEnd()
|
||||
{
|
||||
IExtensionInterface *pAPI;
|
||||
List<CExtension *>::iterator iter;
|
||||
|
||||
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
|
||||
{
|
||||
if ((pAPI = (*iter)->GetAPI()) == NULL)
|
||||
{
|
||||
@@ -1358,17 +1343,17 @@ void CExtensionManager::CallOnCoreMapEnd()
|
||||
}
|
||||
}
|
||||
|
||||
const CVector<IExtension *> *CExtensionManager::ListExtensions()
|
||||
const std::vector<IExtension *> *CExtensionManager::ListExtensions()
|
||||
{
|
||||
CVector<IExtension *> *list = new CVector<IExtension *>();
|
||||
for (List<CExtension *>::iterator iter = m_Libs.begin(); iter != m_Libs.end(); iter++)
|
||||
std::vector<IExtension *> *list = new std::vector<IExtension *>();
|
||||
for (auto iter = m_Libs.begin(); iter != m_Libs.end(); iter++)
|
||||
list->push_back(*iter);
|
||||
return list;
|
||||
}
|
||||
|
||||
void CExtensionManager::FreeExtensionList(const CVector<IExtension *> *list)
|
||||
void CExtensionManager::FreeExtensionList(const std::vector<IExtension *> *list)
|
||||
{
|
||||
delete const_cast<CVector<IExtension *> *>(list);
|
||||
delete const_cast<std::vector<IExtension *> *>(list);
|
||||
}
|
||||
|
||||
bool CLocalExtension::IsSameFile(const char *file)
|
||||
|
||||
Reference in New Issue
Block a user