Skip to content

Commit caeb8f9

Browse files
committed
Fix core command handling (Fixes #3629)
1 parent f8d6022 commit caeb8f9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Client/core/CCommands.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
125125

126126
// Grab the command
127127
tagCOMMANDENTRY* pEntry = Get(szCommand);
128+
bool wasHandled = false;
128129
if (pEntry)
129130
{
130131
// If its a core command, or if its enabled
@@ -133,13 +134,16 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
133134
// Execute it
134135
if (!bIsScriptedBind || pEntry->bAllowScriptedBind)
135136
ExecuteHandler(pEntry->pfnCmdFunc, szParameters);
137+
138+
wasHandled = true;
136139
}
137140
}
138141

139142
// Recompose the original command text
140143
std::string val = std::string(szCommand) + " " + std::string(szParameters ? szParameters : "");
141144

142145
// Is it a cvar? (syntax: cvar[ = value])
146+
if (!wasHandled)
143147
{
144148
// Check to see if '=' exists
145149
unsigned int nOpIndex = val.find('=');
@@ -187,7 +191,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
187191

188192
// HACK: if its a 'nick' command, save it here
189193
bool bIsNickCommand = !stricmp(szCommand, "nick");
190-
if (bIsNickCommand && szParameters && !bIsScriptedBind)
194+
if (!wasHandled && bIsNickCommand && szParameters && !bIsScriptedBind)
191195
{
192196
if (CCore::GetSingleton().IsValidNick(szParameters))
193197
{
@@ -208,10 +212,13 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
208212
if (m_pfnExecuteHandler)
209213
{
210214
bool bAllowScriptedBind = (!pEntry || pEntry->bAllowScriptedBind);
211-
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, (pEntry != NULL), bIsScriptedBind, bAllowScriptedBind))
215+
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, wasHandled, bIsScriptedBind, bAllowScriptedBind))
212216
return true;
213217
}
214218

219+
if (wasHandled)
220+
return true;
221+
215222
// Unknown command
216223
val = _("Unknown command or cvar: ") + szCommand;
217224
if (!bIsScriptedBind && !bIsNickCommand && pEntry == nullptr)

0 commit comments

Comments
 (0)