diff options
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r-- | src/server/game/Chat/Chat.cpp | 14 |
1 files changed, 8 insertions, 6 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(); |