File tree 5 files changed +29
-4
lines changed
addons/source-python/packages/source-python/cvars
5 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 8
8
# Source.Python Imports
9
9
# Cvars
10
10
from _cvars import ConVar
11
+ from _cvars import SP_CVAR_DLL_IDENTIFIER
11
12
from _cvars import _Cvar
12
13
from cvars .flags import ConVarFlags
13
14
24
25
# >> ALL DECLARATION
25
26
# =============================================================================
26
27
__all__ = ('ConVar' ,
28
+ 'SP_CVAR_DLL_IDENTIFIER' ,
27
29
'cvar' ,
28
30
)
Original file line number Diff line number Diff line change 42
42
43
43
#include " commands_say.h"
44
44
#include " commands.h"
45
+ #include " modules/cvars/cvars.h"
45
46
46
47
47
48
// -----------------------------------------------------------------------------
@@ -191,8 +192,12 @@ SayConCommand::~SayConCommand()
191
192
// Get the ConCommand instance
192
193
ConCommand* pConCommand = g_pCVar->FindCommand (m_Name);
193
194
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
+ }
196
201
197
202
// Was the command registered before we registered it?
198
203
if ( m_pOldCommand )
Original file line number Diff line number Diff line change 38
38
39
39
#include " commands.h"
40
40
#include " commands_server.h"
41
+ #include " modules/cvars/cvars.h"
41
42
42
43
// -----------------------------------------------------------------------------
43
44
// Externs.
@@ -162,8 +163,12 @@ CServerCommandManager::~CServerCommandManager()
162
163
// Get the ConCommand instance
163
164
ConCommand* pConCommand = g_pCVar->FindCommand (m_Name);
164
165
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
+ }
167
172
168
173
// Was the command registered before we registered it?
169
174
if ( m_pOldCommand )
Original file line number Diff line number Diff line change 34
34
#include " utilities/sp_util.h"
35
35
36
36
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
+
37
47
// -----------------------------------------------------------------------------
38
48
// ConVar extension class.
39
49
// -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ DECLARE_SP_MODULE(_cvars)
63
63
export_convar_interface (_cvars);
64
64
export_convar (_cvars);
65
65
export_convar_flags (_cvars);
66
+
67
+ // Constants...
68
+ _cvars.attr (" SP_CVAR_DLL_IDENTIFIER" ) = object (CVarDLLIdentifier ());
66
69
}
67
70
68
71
You can’t perform that action at this time.
0 commit comments