From 43b1c2dba4eb59047756ff1f76817fbba1f33256 Mon Sep 17 00:00:00 2001 From: silinoron Date: Fri, 20 Aug 2010 12:42:14 -0700 Subject: * Remove support for map-based random number generation (which seems unused). * Re-add in support for the old mersenne twister for those whose processors don't support SSE2. * Toggling whether or not you are using SFMT is as easy as checking a CMake flag, USE_SFMT, which defaults to 0. --HG-- branch : trunk --- src/server/shared/Utilities/Util.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/server/shared/Utilities/Util.cpp') diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index ab59fdd6598..68f25138a6a 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -22,9 +22,14 @@ #include "socket_include.h" #include "utf8.h" +#ifdef USE_SFMT_FOR_RNG #include "SFMT.h" +#else +#include "MersenneTwister.h" +#endif #include +#ifdef USE_SFMT_FOR_RNG typedef ACE_TSS SFMTRandTSS; static SFMTRandTSS sfmtRand; @@ -52,6 +57,35 @@ double rand_chance (void) { return sfmtRand->Random() * 100.0; } +#else +typedef ACE_TSS MTRandTSS; +static MTRandTSS mtRand; + +int32 irand(int32 min, int32 max) +{ + return int32(mtRand->randInt (max - min)) + min; +} + +uint32 urand(uint32 min, uint32 max) +{ + return mtRand->randInt (max - min) + min; +} + +int32 rand32() +{ + return mtRand->randInt (); +} + +double rand_norm(void) +{ + return mtRand->randExc(); +} + +double rand_chance(void) +{ + return mtRand->randExc(100.0); +} +#endif Tokens StrSplit(const std::string &src, const std::string &sep) { -- cgit v1.2.3