From 95c8d8a6085a7ba523ef42522cadfe0e7268fafa Mon Sep 17 00:00:00 2001 From: Northspring Date: Sat, 23 Aug 2014 02:55:23 +0200 Subject: [PATCH] Roll dice chatbar command: Re-added check for invalid modifier types --- indra/newview/chatbar_as_cmdline.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 4e29cd71af..2e4cd5e674 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -1225,18 +1225,29 @@ bool cmd_line_chat(const std::string& revised_text, EChatType type, bool from_ge // For viewer performance - max 100 dice and 1000 faces per die at once S32 modifier = 0; S32 successes = 0; + S32 modifier_error = 0; if (i >> modifier_type && i >> modifier) { // 2d20+5, 2d20-5 / 2d20>5, 2d20<5 / 2d20!>5, 2d20!<5, 2d20!5 / 2d20r>5, 2d20r<5, 2d20r5 if (modifier < -1000 || modifier > 1000 || (modifier_type != "+" && modifier_type != "-" && modifier_type != "<" && modifier_type != ">" && modifier_type != "!>" && modifier_type != "!<" && modifier_type != "!" && modifier_type != "r" && modifier_type != "r>" && modifier_type != "r<")) { - LLStringUtil::format_map_t args; - args["COMMAND"] = llformat("%s", std::string(sFSCmdLineRollDice).c_str()); - reportToNearbyChat(LLTrans::getString("FSCmdLineRollDiceModifiersInvalid", args)); - return false; + modifier_error = 1; } } + else if (modifier_type != "") + { + // Modifier type invalid + modifier_error = 1; + } + + if (modifier_error == 1) + { + LLStringUtil::format_map_t args; + args["COMMAND"] = llformat("%s", std::string(sFSCmdLineRollDice).c_str()); + reportToNearbyChat(LLTrans::getString("FSCmdLineRollDiceModifiersInvalid", args)); + return false; + } S32 result_per_die = 0; S32 die_iter = 1;