--- deliantra/server/common/utils.C 2007/01/18 22:19:59 1.41 +++ deliantra/server/common/utils.C 2007/01/19 15:15:49 1.42 @@ -39,9 +39,10 @@ #include -rand_gen rndm (time (0)); +rand_gen rndm; -tausworthe_random_generator::tausworthe_random_generator (uint32_t seed) +void +tausworthe_random_generator::seed (uint32_t seed) { state [0] = max ( 2, seed * 69069U); state [1] = max ( 8, state [0] * 69069U); @@ -63,6 +64,19 @@ return state [0] ^ state [1] ^ state [2] ^ state [3]; } +uint32_t +tausworthe_random_generator::get_range (uint32_t r_max) +{ + return next () % r_max; +} + +// return a number within (min .. max) +int +tausworthe_random_generator::get_range (int r_min, int r_max) +{ + return r_min + (*this) (max (r_max - r_min + 1, 1)); +} + /* * The random functions here take luck into account when rolling random * dice or numbers. This function has less of an impact the larger the