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

Comparing deliantra/server/include/util.h (file contents):
Revision 1.99 by root, Fri Apr 9 02:45:16 2010 UTC vs.
Revision 1.100 by root, Thu Apr 22 13:01:58 2010 UTC

470 return !is_constant (num) ? get_range (num) // non-constant 470 return !is_constant (num) ? get_range (num) // non-constant
471 : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two 471 : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two
472 : this->next () & (num - 1); // constant, power-of-two 472 : this->next () & (num - 1); // constant, power-of-two
473 } 473 }
474 474
475 // return a number within (min .. max) 475 // return a number within the closed interval [min .. max]
476 int operator () (int r_min, int r_max) 476 int operator () (int r_min, int r_max)
477 { 477 {
478 return is_constant (r_min) && is_constant (r_max) && r_min <= r_max 478 return is_constant (r_min) && is_constant (r_max) && r_min <= r_max
479 ? r_min + operator ()(r_max - r_min + 1) 479 ? r_min + operator ()(r_max - r_min + 1)
480 : get_range (r_min, r_max); 480 : get_range (r_min, r_max);
481 } 481 }
482 482
483 // return a number within the closed interval [0..1]
483 double operator ()() 484 double operator ()()
484 { 485 {
485 return this->next () / (double)0xFFFFFFFFU; 486 return this->next () / (double)0xFFFFFFFFU;
486 } 487 }
487 488

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines