ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/rng.h
(Generate patch)

Comparing deliantra/server/include/rng.h (file contents):
Revision 1.13 by root, Wed Nov 16 23:42:01 2016 UTC vs.
Revision 1.14 by root, Sat Nov 17 23:33:18 2018 UTC

170 } 170 }
171 171
172 // uniform distribution, [0 .. num - 1] 172 // uniform distribution, [0 .. num - 1]
173 uint32_t operator ()(uint32_t num) 173 uint32_t operator ()(uint32_t num)
174 { 174 {
175 return !is_constant (num) ? get_range (num) // non-constant 175 return !ecb_is_constant (num) ? get_range (num) // non-constant
176 : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two 176 : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two
177 : this->next () & (num - 1); // constant, power-of-two 177 : this->next () & (num - 1); // constant, power-of-two
178 } 178 }
179 179
180 // return a number within the closed interval [min .. max], max can be >, < or == min. 180 // return a number within the closed interval [min .. max], max can be >, < or == min.
181 int operator () (int r_min, int r_max) 181 int operator () (int r_min, int r_max)
182 { 182 {
183 return is_constant (r_min <= r_max) && r_min <= r_max 183 return ecb_is_constant (r_min <= r_max) && r_min <= r_max
184 ? r_min + operator ()(r_max - r_min + 1) 184 ? r_min + operator ()(r_max - r_min + 1)
185 : get_range (r_min, r_max); 185 : get_range (r_min, r_max);
186 } 186 }
187 187
188 uint32_t get_u32 (); 188 uint32_t get_u32 ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines