aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/floaterdice.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2011-06-30 20:17:05 -0700
committerMcCabe Maxsted2011-06-30 20:18:36 -0700
commitf1b743e15a0f694fd800d2622b15d5285db8355c (patch)
treedacea6ba02c3b4038bad0f8bc7e977943f319620 /linden/indra/newview/floaterdice.cpp
parentCode from Singularity Viewer. Original author Shyotl. (diff)
downloadmeta-impy-f1b743e15a0f694fd800d2622b15d5285db8355c.zip
meta-impy-f1b743e15a0f694fd800d2622b15d5285db8355c.tar.gz
meta-impy-f1b743e15a0f694fd800d2622b15d5285db8355c.tar.bz2
meta-impy-f1b743e15a0f694fd800d2622b15d5285db8355c.tar.xz
Fixed dice rolling to use the right range
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/floaterdice.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/linden/indra/newview/floaterdice.cpp b/linden/indra/newview/floaterdice.cpp
index f16a6ca..203878c 100644
--- a/linden/indra/newview/floaterdice.cpp
+++ b/linden/indra/newview/floaterdice.cpp
@@ -37,7 +37,6 @@
37 37
38#include "llchat.h" 38#include "llchat.h"
39#include "llchatbar.h" 39#include "llchatbar.h"
40#include "llkeyboard.h"
41#include "llviewercontrol.h" 40#include "llviewercontrol.h"
42 41
43 42
@@ -75,13 +74,20 @@ void FloaterDice::onClickRoll(void* data)
75 { 74 {
76 S32 dice_total = 0; 75 S32 dice_total = 0;
77 std::ostringstream rolls; 76 std::ostringstream rolls;
78 for (S32 i = 0; i < dice_count; ++i) 77 S32 i = 0;
78 do
79 { 79 {
80 S32 roll = ll_rand(dice_sides); 80 // see the clamping rules for ll_rand
81 dice_total += roll; 81 S32 roll = ll_rand(dice_sides+1);
82 rolls << roll; 82 if (roll > 0)
83 if (i < dice_count - 1) rolls << ", "; 83 {
84 dice_total += roll;
85 rolls << roll;
86 if (i < dice_count - 1) rolls << ", ";
87 ++i;
88 }
84 } 89 }
90 while (i < dice_count);
85 91
86 std::string roll_text = llformat("/me rolled %dd%d for a total of %d", dice_count, dice_sides, dice_total); 92 std::string roll_text = llformat("/me rolled %dd%d for a total of %d", dice_count, dice_sides, dice_total);
87 if (dice_count > 1) 93 if (dice_count > 1)
@@ -92,17 +98,3 @@ void FloaterDice::onClickRoll(void* data)
92 } 98 }
93 } 99 }
94} 100}
95
96// virtual
97BOOL FloaterDice::handleKeyHere(KEY key, MASK mask)
98{
99 BOOL handled = FALSE;
100
101 if ((KEY_RETURN == key) && (mask == MASK_NONE))
102 {
103 onClickRoll(this);
104 handled = TRUE;
105 }
106
107 return handled;
108}