ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/compat.C
(Generate patch)

Comparing deliantra/server/common/compat.C (file contents):
Revision 1.11 by root, Thu Apr 29 15:59:09 2010 UTC vs.
Revision 1.12 by root, Thu Apr 29 17:43:26 2010 UTC

98 * for exp loss calculations for players changing religions. 98 * for exp loss calculations for players changing religions.
99 */ 99 */
100sint64 100sint64
101random_roll64 (sint64 r_min, sint64 r_max, const object *op, bool prefer_high) 101random_roll64 (sint64 r_min, sint64 r_max, const object *op, bool prefer_high)
102{ 102{
103 sint64 omin = r_min;
104 sint64 range = max (0, r_max - r_min + 1); 103 sint64 range = max (0, r_max - r_min + 1);
105 int base = range > 2 ? 20 : 50; /* d2 and d3 are corner cases */ 104 int base = range > 2 ? 20 : 50; /* d2 and d3 are corner cases */
106 105
107 /* 106 /*
108 * Make a call to get two 32 bit unsigned random numbers, and just do 107 * Make a call to get two 32 bit unsigned random numbers, and just do
119 /* we have a winner */ 118 /* we have a winner */
120 luck = luck > 0 ? 1 : -1; 119 luck = luck > 0 ? 1 : -1;
121 120
122 range -= luck; 121 range -= luck;
123 if (range < 1) 122 if (range < 1)
124 return omin; /*check again */ 123 return r_min; /*check again */
125 124
126 if (prefer_high) 125 if (prefer_high)
127 r_min += luck; 126 r_min += luck;
128 127
129 return clamp (ran % range + r_min, omin, r_max); 128 return clamp (ran % range + r_min, r_min, r_max);
130 } 129 }
131 } 130 }
132 131
133 return ran % range + r_min; 132 return ran % range + r_min;
134} 133}
150 luck = total = gotlucky = 0; 149 luck = total = gotlucky = 0;
151 int base = diff > 2 ? 20 : 50; /* d2 and d3 are corner cases */ 150 int base = diff > 2 ? 20 : 50; /* d2 and d3 are corner cases */
152 151
153 if (size < 2 || diff < 1) 152 if (size < 2 || diff < 1)
154 { 153 {
155 LOG (llevError, "Calling die_roll with num=%d size=%d\n", num, size); 154 LOG (llevError | logBacktrace, "Calling die_roll with num=%d size=%d\n", num, size);
156 return num; /* avoids a float exception */ 155 return num; /* avoids a float exception */
157 } 156 }
158 157
159 if (op->type == PLAYER) 158 if (op->type == PLAYER)
160 luck = op->stats.luck; 159 luck = op->stats.luck;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines