aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Chat/Chat.cpp14
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp6
2 files changed, 11 insertions, 9 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 75acbffcbd3..ae2d0792f60 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -159,7 +159,7 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part)
while (true)
{
- if (!*part)
+ if (!*part || *part == ' ')
return true;
else if (!*name)
return false;
@@ -461,6 +461,10 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons
{
if (*cmd)
{
+ std::string subcmd;
+ if (size_t n = std::string_view(cmd).find(' '); n != std::string_view::npos)
+ subcmd.assign(cmd+n+1);
+
for (uint32 i = 0; i < table.size(); ++i)
{
// must be available (ignore handler existence to show command with possible available subcommands)
@@ -471,11 +475,9 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons
continue;
// have subcommand
- char const* subcmd = (*cmd) ? strtok(nullptr, " ") : "";
-
- if (!table[i].ChildCommands.empty() && subcmd && *subcmd)
+ if (!table[i].ChildCommands.empty() && !subcmd.empty())
{
- if (ShowHelpForCommand(table[i].ChildCommands, subcmd))
+ if (ShowHelpForCommand(table[i].ChildCommands, subcmd.c_str()))
return true;
}
@@ -483,7 +485,7 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons
SendSysMessage(table[i].Help.c_str());
if (!table[i].ChildCommands.empty())
- if (ShowHelpForSubCommands(table[i].ChildCommands, table[i].Name, subcmd ? subcmd : ""))
+ if (ShowHelpForSubCommands(table[i].ChildCommands, table[i].Name, subcmd.c_str()))
return true;
return !table[i].Help.empty();
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 99b507bb61c..b4e68d5a8c3 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -699,16 +699,16 @@ public:
return true;
}
- static bool HandleHelpCommand(ChatHandler* handler, Optional<std::string> cmdArg)
+ static bool HandleHelpCommand(ChatHandler* handler, Tail cmdArg)
{
- if (!cmdArg)
+ if (cmdArg.empty())
{
handler->ShowHelpForCommand(ChatHandler::getCommandTable(), "help");
handler->ShowHelpForCommand(ChatHandler::getCommandTable(), "");
}
else
{
- if (!handler->ShowHelpForCommand(ChatHandler::getCommandTable(), cmdArg->c_str()))
+ if (!handler->ShowHelpForCommand(ChatHandler::getCommandTable(), std::string(cmdArg).c_str()))
handler->SendSysMessage(LANG_NO_HELP_CMD);
}