fixed a serious potential bug with swapping plugins to debug mode, leaving stale function pointers without plugin removal
2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
14 #ifndef _INCLUDE_SOURCEMOD_CCONVARMANAGER_H_
15 #define _INCLUDE_SOURCEMOD_CCONVARMANAGER_H_
17 #include "sm_globals.h"
18 #include "sourcemm_api.h"
21 #include <IPluginSys.h>
22 #include <IForwardSys.h>
23 #include <IHandleSys.h>
24 #include <IRootConsoleMenu.h>
26 using namespace SourceHook;
29 * Holds SourceMod-specific information about a convar
33 Handle_t handle; /**< Handle to convar */
34 bool sourceMod; /**< Determines whether or not convar was created by a SourceMod plugin */
35 IChangeableForward *changeForward; /**< Forward associated with convar */
36 FnChangeCallback origCallback; /**< The original callback function */
39 class CConVarManager :
41 public IHandleTypeDispatch,
42 public IPluginsListener,
43 public IRootConsoleCommand
48 public: // SMGlobalClass
49 void OnSourceModAllInitialized();
50 void OnSourceModShutdown();
51 public: // IHandleTypeDispatch
52 void OnHandleDestroy(HandleType_t type, void *object);
53 public: // IPluginsListener
54 void OnPluginDestroyed(IPlugin *plugin);
55 public: //IRootConsoleCommand
56 void OnRootConsoleCommand(const char *command, unsigned int argcount);
59 * Get the 'ConVar' handle type ID.
61 inline HandleType_t GetHandleType()
67 * Get the convar lookup trie.
69 inline Trie *GetConVarCache()
75 * Create a convar and return a handle to it.
77 Handle_t CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *helpText,
78 int flags, bool hasMin, float min, bool hasMax, float max);
81 * Searches for a convar and returns a handle to it
83 Handle_t FindConVar(const char* name);
86 * Add a function to call when the specified convar changes.
88 void HookConVarChange(IPluginContext *pContext, ConVar *cvar, funcid_t funcid);
91 * Remove a function from the forward that will be called when the specified convar changes.
93 void UnhookConVarChange(IPluginContext *pContext, ConVar *cvar, funcid_t funcid);
96 * Static callback that Valve's ConVar class executes when the convar's value changes.
98 static void OnConVarChanged(ConVar *cvar, const char *oldValue);
100 HandleType_t m_ConVarType;
101 List<ConVarInfo *> m_ConVars;
105 extern CConVarManager g_ConVarManager;
107 #endif // _INCLUDE_SOURCEMOD_CCONVARMANAGER_H_