diff options
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/newview/floaterdice.cpp | 32 | ||||
-rw-r--r-- | linden/indra/newview/floaterdice.h | 1 |
2 files changed, 12 insertions, 21 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 | ||
97 | BOOL 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 | } | ||
diff --git a/linden/indra/newview/floaterdice.h b/linden/indra/newview/floaterdice.h index 57a664b..5f36a80 100644 --- a/linden/indra/newview/floaterdice.h +++ b/linden/indra/newview/floaterdice.h | |||
@@ -44,7 +44,6 @@ public: | |||
44 | private: | 44 | private: |
45 | 45 | ||
46 | static void onClickRoll(void* data); | 46 | static void onClickRoll(void* data); |
47 | virtual BOOL handleKeyHere(KEY key, MASK mask); | ||
48 | }; | 47 | }; |
49 | 48 | ||
50 | #endif //floaterdice_h | 49 | #endif //floaterdice_h |