mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-19 08:52:34 +01:00
Added OnUnlinkConCommandBase to IMetamodListener to notify when Metamod:Source is about remove a concommand or convar.
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40419
This commit is contained in:
parent
98caa6168f
commit
e00aa3cbd4
@ -605,12 +605,12 @@ 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) );
|
||||
g_SMConVarAccessor.Unregister(pl->m_Id, (*i) );
|
||||
|
||||
pl->m_Cvars.clear();
|
||||
|
||||
for (i=pl->m_Cmds.begin(); i!=pl->m_Cmds.end(); i++)
|
||||
g_SMConVarAccessor.Unregister( (*i) );
|
||||
g_SMConVarAccessor.Unregister(pl->m_Id, (*i) );
|
||||
|
||||
pl->m_Cmds.clear();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void CSmmAPI::UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
|
||||
g_PluginMngr.RemovePluginCvar(plugin, pCommand);
|
||||
}
|
||||
|
||||
g_SMConVarAccessor.Unregister(pCommand);
|
||||
g_SMConVarAccessor.Unregister(g_PluginMngr.FindByAPI(plugin)->m_Id, pCommand);
|
||||
}
|
||||
|
||||
void CSmmAPI::ConPrint(const char *fmt)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <sourcehook/sourcehook.h>
|
||||
#include "ISmmAPI.h"
|
||||
|
||||
#define PLAPI_VERSION 11
|
||||
#define PLAPI_VERSION 12
|
||||
#define PLAPI_NAME "ISmmPlugin"
|
||||
|
||||
class ISmmAPI;
|
||||
@ -313,9 +313,15 @@ public:
|
||||
* @param iface Interface pointer. If NULL, then the VSP listening construct
|
||||
* failed to initialize and is not available.
|
||||
*/
|
||||
virtual void OnVSPListening(IServerPluginCallbacks *iface)
|
||||
{
|
||||
}
|
||||
virtual void OnVSPListening(IServerPluginCallbacks *iface) { }
|
||||
|
||||
/* @brief Called when Metamod:Source is about to remove a concommand or convar.
|
||||
* This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin.
|
||||
*
|
||||
* @param id Id of the plugin that created the concommand or convar.
|
||||
* @param pCommand Pointer to concommand or convar that is being removed.
|
||||
*/
|
||||
virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand) { }
|
||||
};
|
||||
|
||||
#define PL_EXPOSURE CreateInterface
|
||||
|
@ -8,7 +8,9 @@
|
||||
instance pointer rather than a callclass pointer.
|
||||
- Added API for getting highest supported IServerPluginCallbacks interface
|
||||
version.
|
||||
|
||||
- Added OnUnlinkConCommandBase to IMetamodListner to notify when Metamod:Source
|
||||
is about to remove a concommand or convar.
|
||||
|
||||
2007/06/26 1.4.2:
|
||||
- Fixed a bug where unloading all plugins could crash if one plugin had child
|
||||
plugins.
|
||||
|
@ -57,18 +57,44 @@ void SMConVarAccessor::MarkCommandsAsGameDLL()
|
||||
}
|
||||
}
|
||||
|
||||
void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
|
||||
void SMConVarAccessor::Unregister(PluginId id, ConCommandBase *pCommand)
|
||||
{
|
||||
/* Notify via IMetamodListener */
|
||||
PluginIter iter;
|
||||
SourceMM::CPluginManager::CPlugin *pPlugin;
|
||||
SourceHook::List<IMetamodListener *>::iterator event;
|
||||
IMetamodListener *pML;
|
||||
for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++)
|
||||
{
|
||||
pPlugin = (*iter);
|
||||
if (pPlugin->m_Status < Pl_Paused)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Only valid for plugins >= 12 (v1:6, SourceMM 1.5) */
|
||||
if (pPlugin->m_API->GetApiVersion() < 12)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (event=pPlugin->m_Events.begin();
|
||||
event!=pPlugin->m_Events.end();
|
||||
event++)
|
||||
{
|
||||
pML = (*event);
|
||||
pML->OnUnlinkConCommandBase(id, pCommand);
|
||||
}
|
||||
}
|
||||
|
||||
ICvar *cv = g_Engine.icvar;
|
||||
ConCommandBase *ptr = cv->GetCommands();
|
||||
|
||||
if (ptr == pCommand)
|
||||
{
|
||||
//first in list
|
||||
/* First in list */
|
||||
g_EternalCommand.BringToFront();
|
||||
g_EternalCommand.SetNext(const_cast<ConCommandBase *>(pCommand->GetNext()));
|
||||
} else {
|
||||
//find us and unregister us
|
||||
/* Find us and unregister us */
|
||||
ConCommandBase *pPrev = NULL;
|
||||
while (ptr)
|
||||
{
|
||||
@ -91,10 +117,10 @@ void SMConVarAccessor::UnregisterGameDLLCommands()
|
||||
ConCommandBase *prev = NULL;
|
||||
while (iter)
|
||||
{
|
||||
// watch out for the ETERNAL COMMAND!
|
||||
/* Watch out for the ETERNAL COMMAND! */
|
||||
if (iter != &g_EternalCommand && iter->IsBitSet(FCVAR_GAMEDLL))
|
||||
{
|
||||
// Remove it!
|
||||
/* Remove it! */
|
||||
if (iter == begin)
|
||||
{
|
||||
g_EternalCommand.BringToFront();
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual bool RegisterConCommandBase(ConCommandBase *pCommand);
|
||||
bool Register(ConCommandBase *pCommand);
|
||||
void MarkCommandsAsGameDLL();
|
||||
void Unregister(ConCommandBase *pCommand);
|
||||
void Unregister(PluginId id, ConCommandBase *pCommand);
|
||||
void UnregisterGameDLLCommands();
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user