--- deliantra/server/common/utils.C 2010/03/26 01:04:44 1.95 +++ deliantra/server/common/utils.C 2011/04/23 04:56:47 1.98 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the @@ -42,7 +42,6 @@ refcnt_base::refcnt_t refcnt_dummy; ssize_t slice_alloc; -rand_gen rndm, rmg_rndm; #if !GCC_VERSION(3,4) int least_significant_bit (uint32_t x) @@ -61,47 +60,6 @@ } #endif -void -tausworthe_random_generator::seed (uint32_t seed) -{ - state [0] = seed * 69069U; if (state [0] < 2U) state [0] += 2U; - state [1] = state [0] * 69069U; if (state [0] < 8U) state [0] += 8U; - state [2] = state [1] * 69069U; if (state [0] < 16U) state [0] += 16U; - state [3] = state [2] * 69069U; if (state [0] < 128U) state [0] += 128U; - - for (int i = 11; --i; ) - next (); -} - -uint32_t -tausworthe_random_generator::next () -{ - state [0] = ((state [0] & 0xFFFFFFFEU) << 18U) ^ (((state [0] << 6U) ^ state [0]) >> 13U); - state [1] = ((state [1] & 0xFFFFFFF8U) << 2U) ^ (((state [1] << 2U) ^ state [1]) >> 27U); - state [2] = ((state [2] & 0xFFFFFFF0U) << 7U) ^ (((state [2] << 13U) ^ state [2]) >> 21U); - state [3] = ((state [3] & 0xFFFFFF80U) << 13U) ^ (((state [3] << 3U) ^ state [3]) >> 12U); - - return state [0] ^ state [1] ^ state [2] ^ state [3]; -} - -template -uint32_t -random_number_generator::get_range (uint32_t num) -{ - return (this->next () * (uint64_t)num) >> 32U; -} - -// return a number within (min .. max) -template -int -random_number_generator::get_range (int r_min, int r_max) -{ - return r_min + get_range (max (r_max - r_min + 1, 0)); -} - -template struct random_number_generator; -template struct random_number_generator; - /******************************************************************************/ /* Checks a player-provided string which will become the msg property of @@ -268,7 +226,12 @@ char * vformat (const char *format, va_list ap) { - static dynbuf_text buf; buf.clear (); + static dynbuf_text bufs[8]; + static int bufidx; + + dynbuf_text &buf = bufs [++bufidx & 7]; + + buf.clear (); buf.vprintf (format, ap); return buf; }