From 232f344c419ddd6f1de0ba9a69e7007bccbc1968 Mon Sep 17 00:00:00 2001 From: David Anderson <dvander@alliedmods.net> Date: Fri, 11 Jul 2008 05:15:43 +0000 Subject: [PATCH] FindPluginByContext works again --HG-- branch : refac-jit extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/refac-jit%402398 --- core/systems/PluginSys.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index dcf842ad..c9196d68 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -111,6 +111,7 @@ void CPlugin::InitIdentity() m_ident = g_ShareSys.CreateIdentity(g_PluginIdent, this); m_handle = g_HandleSys.CreateHandle(g_PluginType, this, g_PluginSys.GetIdentity(), g_PluginSys.GetIdentity(), NULL); m_pRuntime->GetDefaultContext()->SetKey(1, m_ident); + m_pRuntime->GetDefaultContext()->SetKey(2, (IPlugin *)this); } } @@ -1563,16 +1564,14 @@ bool CPluginManager::UnloadPlugin(IPlugin *plugin) IPlugin *CPluginManager::FindPluginByContext(const sp_context_t *ctx) { - List<CPlugin *>::iterator iter; + IPlugin *pPlugin; + IPluginContext *pContext; - /* :TODO: :TODO: respeed this up somehow */ - for (iter = m_plugins.begin(); iter != m_plugins.end(); iter++) + pContext = reinterpret_cast<IPluginContext *>(const_cast<sp_context_t *>(ctx)); + + if (pContext->GetKey(2, (void **)&pPlugin)) { - CPlugin *pl = (*iter); - if (pl->m_pRuntime != NULL && pl->m_pRuntime->GetDefaultContext()->GetContext() == ctx) - { - return pl; - } + return pPlugin; } return NULL;