27
27
// -----------------------------------------------------------------------------
28
28
// Includes
29
29
// -----------------------------------------------------------------------------
30
- // This is required for accessing m_nFlags without ing convar.h
31
- #define private public
32
-
33
30
#include " utilities/call_python.h"
34
31
35
32
#include " boost/unordered_map.hpp"
@@ -56,8 +53,12 @@ class CPluginConVarAccessor : public IConCommandBaseAccessor
56
53
public:
57
54
virtual bool RegisterConCommandBase (ConCommandBase* pCommand)
58
55
{
59
- g_pCVar->RegisterConCommand (pCommand);
60
- return true ;
56
+ if (!g_pCVar->FindCommandBase (pCommand->GetName ())) {
57
+ g_pCVar->RegisterConCommand (pCommand);
58
+ return true ;
59
+ }
60
+
61
+ return false ;
61
62
}
62
63
};
63
64
@@ -121,15 +122,17 @@ CServerCommandManager* CServerCommandManager::CreateCommand(const char* szName,
121
122
char * szHelpTextCopy = NULL ;
122
123
123
124
// FInd if the command already exists
124
- ConCommand * pConCommand = g_pCVar->FindCommand (szName);
125
+ ConCommandBase * pConCommand = g_pCVar->FindCommandBase (szName);
125
126
if ( pConCommand )
126
127
{
127
128
// Store the current command's help text and flags
128
129
szHelpTextCopy = strdup (pConCommand->GetHelpText ());
129
- iFlags = pConCommand-> m_nFlags ;
130
+ iFlags = GetConCommandFlags ( pConCommand) ;
130
131
131
132
// Unregister the old command
132
- g_pCVar->UnregisterConCommand (pConCommand);
133
+ if (pConCommand->IsRegistered ()) {
134
+ g_pCVar->UnregisterConCommand (pConCommand);
135
+ }
133
136
}
134
137
else if ( szHelpText != NULL )
135
138
{
@@ -144,7 +147,7 @@ CServerCommandManager* CServerCommandManager::CreateCommand(const char* szName,
144
147
// -----------------------------------------------------------------------------
145
148
// CServerCommandManager constructor.
146
149
// -----------------------------------------------------------------------------
147
- CServerCommandManager::CServerCommandManager (ConCommand * pConCommand,
150
+ CServerCommandManager::CServerCommandManager (ConCommandBase * pConCommand,
148
151
const char * szName, const char * szHelpText, int iFlags):
149
152
ConCommand(szName, (FnCommandCallback_t)NULL, szHelpText, iFlags),
150
153
m_pOldCommand(pConCommand)
@@ -163,8 +166,8 @@ CServerCommandManager::~CServerCommandManager()
163
166
// Get the ConCommand instance
164
167
ConCommand* pConCommand = g_pCVar->FindCommand (m_Name);
165
168
166
- // Was the command overwritten as a ConVar or by another DLL?
167
- if (pConCommand && pConCommand-> GetDLLIdentifier () == CVarDLLIdentifier () )
169
+ // Make sure we only unregister ourselves
170
+ if (pConCommand == this )
168
171
{
169
172
// Unregister the ConCommand
170
173
g_pCVar->UnregisterConCommand (pConCommand);
@@ -236,7 +239,12 @@ void CServerCommandManager::Dis( const CCommand& command )
236
239
// Was the command previously registered?
237
240
if (m_pOldCommand)
238
241
{
239
- m_pOldCommand->Dis (command);
242
+ if (m_pOldCommand->IsCommand ()) {
243
+ static_cast <ConCommand *>(m_pOldCommand)->Dis (command);
244
+ }
245
+ else {
246
+ static_cast <ConVar *>(m_pOldCommand)->SetValue (command.ArgS ());
247
+ }
240
248
}
241
249
242
250
// Post hook callbacks
0 commit comments