Core: Fix the SFMT randgen-initbug

Signed-off-by: click <[email protected]>
This commit is contained in:
Elron103
2012-02-25 02:16:08 +01:00
committed by click
parent d505e8ccc9
commit 28310f0938
3 changed files with 13 additions and 1 deletions
+5
View File
@@ -31,6 +31,11 @@
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
static SFMTRandTSS sfmtRand;
void init_sfmt()
{
sfmtRand->RandomInit((int)(time(0)));
}
int32 irand(int32 min, int32 max)
{
return int32(sfmtRand->IRandom(min, max));
+5
View File
@@ -24,6 +24,11 @@
#include <string>
#include <vector>
#ifdef USE_SFMT_FOR_RNG
// Initialize SFMT before first use, if enabled.
void init_sfmt();
#endif
// Searcher for map of structs
template<typename T, class S> struct Finder
{
+3 -1
View File
@@ -139,7 +139,9 @@ int Master::Run()
#ifdef USE_SFMT_FOR_RNG
sLog->outString("\n");
sLog->outString("SFMT has been enabled as the random number generator, if worldserver");
sLog->outString("freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration");
sLog->outString("freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration.");
sLog->outString("Initializing SFMT before first use.");
init_sfmt();
sLog->outString("\n");
#endif //USE_SFMT_FOR_RNG