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

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.49 by root, Sat Apr 21 22:57:15 2007 UTC vs.
Revision 1.50 by root, Sat Apr 21 23:03:54 2007 UTC

63 63
64 return state [0] ^ state [1] ^ state [2] ^ state [3]; 64 return state [0] ^ state [1] ^ state [2] ^ state [3];
65} 65}
66 66
67uint32_t 67uint32_t
68tausworthe_random_generator::get_range (uint32_t r_max) 68tausworthe_random_generator::get_range (uint32_t num)
69{ 69{
70 return (next () * (uint64_t)r_max) >> 32U; 70 return (next () * (uint64_t)num) >> 32U;
71} 71}
72 72
73// return a number within (min .. max) 73// return a number within (min .. max)
74int 74int
75tausworthe_random_generator::get_range (int r_min, int r_max) 75tausworthe_random_generator::get_range (int r_min, int r_max)
76{ 76{
77 return r_min + get_range (max (r_max - r_min + 1, 1)); 77 return r_min + get_range (max (r_max - r_min + 1, 0));
78} 78}
79 79
80/* 80/*
81 * The random functions here take luck into account when rolling random 81 * The random functions here take luck into account when rolling random
82 * dice or numbers. This function has less of an impact the larger the 82 * dice or numbers. This function has less of an impact the larger the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines