Skip to content

Commit 1847eb4

Browse files
committed
fix(menus): Command not getting arguments
1 parent 0cccad5 commit 1847eb4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/server/menus/MenuRenderer.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,19 @@ void MenuRenderer::PerformMenuAction(std::string button)
241241
CCommand tokenizedArgs;
242242
tokenizedArgs.Tokenize(cmd.c_str());
243243

244-
std::vector<std::string> cmdString = TokenizeCommand(cmd);
245-
cmdString.erase(cmdString.begin());
244+
std::string commandName = (tokenizedArgs[0] + 3);
246245

247-
std::string commandName = replace(tokenizedArgs[0], "sw_", "");
246+
std::vector<std::string> argsplit = TokenizeCommand(cmd.c_str());
247+
argsplit.erase(argsplit.begin());
248248

249-
Command* cmd = g_commandsManager->FetchCommand(commandName);
250-
if (cmd)
251-
cmd->Execute(m_player->GetSlot().Get(), cmdString, true, "sw_");
249+
if (g_commandsManager->FetchCommand(commandName) == nullptr)
250+
return;
251+
252+
Command* command = g_commandsManager->FetchCommand(commandName);
253+
if (!command)
254+
return;
255+
256+
command->Execute(m_player->GetSlot().Get(), argsplit, true, "sw_");
252257
}
253258
else if (cmd != "")
254259
m_player->PerformCommand(cmd);

0 commit comments

Comments
 (0)