1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-18 07:52:32 +01:00

Backported OnUnlinkConCommandBase event from new API to legacy API (bug 4018, r=ds).

This commit is contained in:
David Anderson 2009-10-29 00:44:31 -07:00
parent 16ca8385a9
commit 0c4bc93f5a
5 changed files with 52 additions and 5 deletions

View File

@ -37,6 +37,26 @@ using namespace SourceMM;
CPluginManager g_PluginMngr;
void NotifyConCommandBaseDrop(PluginId id, ConCommandBase *base)
{
CPluginManager::CPlugin *pl;
SourceHook::List<CPluginEventHandler>::iterator event;
IMetamodListener *api;
for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++)
{
pl = (*iter);
if (pl->m_Status < Pl_Paused)
continue;
if (pl->m_API->GetApiVersion() < 11)
continue;
for (event = pl->m_Events.begin(); event != pl->m_Events.end(); event++)
{
api = (*event).event;
api->OnUnlinkConCommandBase(id, base);
}
}
}
CPluginManager::CPluginManager()
{
m_LastId = Pl_MinId;
@ -653,13 +673,19 @@ void CPluginManager::UnregAllConCmds(CPlugin *pl)
{
SourceHook::List<ConCommandBase *>::iterator i;
for (i=pl->m_Cvars.begin(); i!=pl->m_Cvars.end(); i++)
g_SMConVarAccessor.Unregister( (*i) );
for (i = pl->m_Cvars.begin(); i != pl->m_Cvars.end(); i++)
{
NotifyConCommandBaseDrop(pl->m_Id, (*i));
g_SMConVarAccessor.Unregister((*i));
}
pl->m_Cvars.clear();
for (i=pl->m_Cmds.begin(); i!=pl->m_Cmds.end(); i++)
g_SMConVarAccessor.Unregister( (*i) );
for (i = pl->m_Cmds.begin(); i != pl->m_Cmds.end(); i++)
{
NotifyConCommandBaseDrop(pl->m_Id, (*i));
g_SMConVarAccessor.Unregister((*i));
}
pl->m_Cmds.clear();
}

View File

@ -149,6 +149,8 @@ namespace SourceMM
};
};
void NotifyConCommandBaseDrop(PluginId id, ConCommandBase *base);
typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter;
/** @brief Singleton for plugin manager */

View File

@ -118,6 +118,11 @@ void CSmmAPI::UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
g_PluginMngr.RemovePluginCvar(plugin, pCommand);
}
CPluginManager::CPlugin *pPlugin = g_PluginMngr.FindByAPI(plugin);
PluginId id = (pPlugin != NULL) ? pPlugin->m_Id : Pl_BadLoad;
NotifyConCommandBaseDrop(id, pCommand);
g_SMConVarAccessor.Unregister(pCommand);
}

View File

@ -315,7 +315,7 @@ public: // Added in 1.4 (1:5)
* 1.2.2 Added API for printing to client console (with string formatting).
* 1.3 Added new interface search API.
* 1.4 Added VSP listener and user message API.
* 1.8 Added VP hooks to SH-legacy.
* 1.8 Added VP hooks to SH-legacy, new API for cvars.
*/
#endif //_INCLUDE_ISMM_API_H

View File

@ -316,6 +316,20 @@ public:
virtual void OnVSPListening(IServerPluginCallbacks *iface)
{
}
/**
* @brief Called when Metamod:Source knows that a specific ConCommandBase is
* about to be unregistered. This is only called for ConCommandBases
* registered by Metamod:Source plugins.
*
* This is only invoked on Metamod:Source 1.8 or higher (PLAPI_VERSION >= 11).
*
* @param plugin Plugin owning the ConCommandBase.
* @param base ConCommandBase that is being unlinked.
*/
virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *base)
{
}
};
#define PL_EXPOSURE CreateInterface