File tree Expand file tree Collapse file tree 5 files changed +29
-4
lines changed
addons/source-python/packages/source-python/cvars Expand file tree Collapse file tree 5 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 88# Source.Python Imports
99# Cvars
1010from _cvars import ConVar
11+ from _cvars import SP_CVAR_DLL_IDENTIFIER
1112from _cvars import _Cvar
1213from cvars .flags import ConVarFlags
1314
2425# >> ALL DECLARATION
2526# =============================================================================
2627__all__ = ('ConVar' ,
28+ 'SP_CVAR_DLL_IDENTIFIER' ,
2729 'cvar' ,
2830 )
Original file line number Diff line number Diff line change 4242
4343#include " commands_say.h"
4444#include " commands.h"
45+ #include " modules/cvars/cvars.h"
4546
4647
4748// -----------------------------------------------------------------------------
@@ -191,8 +192,12 @@ SayConCommand::~SayConCommand()
191192 // Get the ConCommand instance
192193 ConCommand* pConCommand = g_pCVar->FindCommand (m_Name);
193194
194- // Unregister the ConCommand
195- g_pCVar->UnregisterConCommand (pConCommand);
195+ // Was the command overwritten as a ConVar or by another DLL?
196+ if (pConCommand && pConCommand->GetDLLIdentifier () == CVarDLLIdentifier ())
197+ {
198+ // Unregister the ConCommand
199+ g_pCVar->UnregisterConCommand (pConCommand);
200+ }
196201
197202 // Was the command registered before we registered it?
198203 if ( m_pOldCommand )
Original file line number Diff line number Diff line change 3838
3939#include " commands.h"
4040#include " commands_server.h"
41+ #include " modules/cvars/cvars.h"
4142
4243// -----------------------------------------------------------------------------
4344// Externs.
@@ -162,8 +163,12 @@ CServerCommandManager::~CServerCommandManager()
162163 // Get the ConCommand instance
163164 ConCommand* pConCommand = g_pCVar->FindCommand (m_Name);
164165
165- // Unregister the ConCommand
166- g_pCVar->UnregisterConCommand (pConCommand);
166+ // Was the command overwritten as a ConVar or by another DLL?
167+ if (pConCommand && pConCommand->GetDLLIdentifier () == CVarDLLIdentifier ())
168+ {
169+ // Unregister the ConCommand
170+ g_pCVar->UnregisterConCommand (pConCommand);
171+ }
167172
168173 // Was the command registered before we registered it?
169174 if ( m_pOldCommand )
Original file line number Diff line number Diff line change 3434#include " utilities/sp_util.h"
3535
3636
37+ // -----------------------------------------------------------------------------
38+ // Returns Source.Python's DLL identifier.
39+ // -----------------------------------------------------------------------------
40+ inline CVarDLLIdentifier_t CVarDLLIdentifier ()
41+ {
42+ static CVarDLLIdentifier_t s_nDLLIdentifier = ConCommandBase ().GetDLLIdentifier ();
43+ return s_nDLLIdentifier;
44+ }
45+
46+
3747// -----------------------------------------------------------------------------
3848// ConVar extension class.
3949// -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ DECLARE_SP_MODULE(_cvars)
6363 export_convar_interface (_cvars);
6464 export_convar (_cvars);
6565 export_convar_flags (_cvars);
66+
67+ // Constants...
68+ _cvars.attr (" SP_CVAR_DLL_IDENTIFIER" ) = object (CVarDLLIdentifier ());
6669}
6770
6871
You can’t perform that action at this time.
0 commit comments