diff options
author | silinoron <none@none> | 2010-08-20 12:42:14 -0700 |
---|---|---|
committer | silinoron <none@none> | 2010-08-20 12:42:14 -0700 |
commit | 43b1c2dba4eb59047756ff1f76817fbba1f33256 (patch) | |
tree | 395cb523edfa7e6c668d62f9071619218b79a033 /src/server/shared/Utilities/Util.cpp | |
parent | ca350b4758fef6a2f0a277fb11a5e420887ae718 (diff) |
* 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
Diffstat (limited to 'src/server/shared/Utilities/Util.cpp')
-rw-r--r-- | src/server/shared/Utilities/Util.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 <ace/TSS_T.h> +#ifdef USE_SFMT_FOR_RNG typedef ACE_TSS<SFMTRand> SFMTRandTSS; static SFMTRandTSS sfmtRand; @@ -52,6 +57,35 @@ double rand_chance (void) { return sfmtRand->Random() * 100.0; } +#else +typedef ACE_TSS<MTRand> 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) { |