Skip to content

Commit 05ef041

Browse files
committed
update(commands): Changed arguments parsing
1 parent 0ace481 commit 05ef041

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/commands/CommandsManager.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ int CommandsManager::HandleCommands(CBasePlayerController *controller, std::stri
2727
bool isSilentCommand = (std::find(silentCommandPrefixes.begin(), silentCommandPrefixes.end(), std::string(1, text.at(0))) != silentCommandPrefixes.end());
2828
if (isCommand || isSilentCommand)
2929
{
30-
std::vector<std::string> cmdString = explode(text, " ");
31-
std::string commandName = cmdString[0];
32-
cmdString.erase(cmdString.begin());
30+
CCommand tokenizedArgs;
31+
tokenizedArgs.Tokenize(text.c_str());
32+
33+
std::vector<std::string> cmdString;
34+
for (int i = 1; i < tokenizedArgs.ArgC(); i++)
35+
cmdString.push_back(tokenizedArgs[i]);
36+
37+
std::string commandName = tokenizedArgs[0];
3338
commandName.erase(0, 1);
3439

3540
Command *cmd = g_commandsManager->FetchCommand(commandName);
@@ -86,9 +91,14 @@ bool CommandsManager::RegisterCommand(std::string plugin_name, std::string cmd,
8691

8792
static void commandsCallback(const CCommandContext &context, const CCommand &args)
8893
{
89-
std::vector<std::string> argsplit = explode(args.GetCommandString(), " ");
90-
std::string cmdName = (argsplit[0].c_str() + 3);
91-
argsplit.erase(argsplit.begin());
94+
CCommand tokenizedArgs;
95+
tokenizedArgs.Tokenize(args.GetCommandString());
96+
97+
std::string cmdName = (tokenizedArgs[0] + 3);
98+
std::vector<std::string> argsplit;
99+
for (int i = 1; i < tokenizedArgs.ArgC(); i++)
100+
argsplit.push_back(tokenizedArgs[i]);
101+
92102
if (g_commandsManager->FetchCommand(cmdName) == nullptr)
93103
return;
94104

0 commit comments

Comments
 (0)