Core/ChatCommands: Fix a potential crash if a custom chat command does not have a specified help string

This commit is contained in:
Treeston
2020-10-08 16:45:20 +02:00
parent 5f001ddb2b
commit 3ec98bf241
3 changed files with 14 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
--
DELETE FROM `trinity_string` WHERE `entry`=196;
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
(196, 'There is no detailed usage information associated with \'%.*s\'.
This should never occur for stock TrinityCore commands - if it does, report this as a bug.
If this is a custom command, use `trinity_string` to specify it. Look at cs_achievement.cpp for example usage.');

View File

@@ -173,8 +173,13 @@ void Trinity::Impl::ChatCommands::ChatCommandNode::SendCommandHelp(ChatHandler&
{
if (std::holds_alternative<TrinityStrings>(_help))
handler.SendSysMessage(std::get<TrinityStrings>(_help));
else
else if (std::holds_alternative<std::string>(_help))
handler.SendSysMessage(std::get<std::string>(_help));
else
{
handler.PSendSysMessage(LANG_CMD_HELP_GENERIC, STRING_VIEW_FMT_ARG(_name));
handler.PSendSysMessage(LANG_CMD_NO_HELP_AVAILABLE, STRING_VIEW_FMT_ARG(_name));
}
}
bool header = false;

View File

@@ -229,7 +229,8 @@ enum TrinityStrings
LANG_SUBCMD_INVALID = 193,
LANG_CMD_AMBIGUOUS = 194,
LANG_CMD_HELP_GENERIC = 195,
// Room for more level 1 196-199 not used
LANG_CMD_NO_HELP_AVAILABLE = 196,
// Room for more level 1 197-199 not used
// level 2 chat
LANG_NO_SELECTION = 200,