* 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
This commit is contained in:
silinoron
2010-08-20 12:42:14 -07:00
parent ca350b4758
commit 43b1c2dba4
9 changed files with 459 additions and 10 deletions

View File

@@ -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)
{