forked from speed-dreams/speed-dreams-code
Initialize the random generator only once, in tgf::gfInit
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3137 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: dac252be1bcf1b826d1ca0ceca4a4f8789740bb6 Former-commit-id: eb861a6d560f2342905cce2ca1f014c5923fc9c0
This commit is contained in:
parent
f4fa156640
commit
19935cfa55
3 changed files with 5 additions and 2 deletions
|
@ -21,7 +21,7 @@ static const float PI = 3.1415927f;
|
||||||
|
|
||||||
void setRandomSeed(unsigned int seed)
|
void setRandomSeed(unsigned int seed)
|
||||||
{
|
{
|
||||||
srand(seed);
|
//srand(seed); // Already done in tgf::gfInit (needed only once in the process life time)
|
||||||
}
|
}
|
||||||
|
|
||||||
real urandom()
|
real urandom()
|
||||||
|
|
|
@ -501,7 +501,7 @@ void ReCareerNew()
|
||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
stm = localtime(&t);
|
stm = localtime(&t);
|
||||||
srand((unsigned int)t);
|
//srand((unsigned int)t); // Already done in tgf::gfInit (needed only once in the process life time)
|
||||||
snprintf( buf, 1024, "%sresults/%s/%%s-%4d-%02d-%02d-%02d-%02d%%s%%s%%s.xml%%s", GetLocalDir(), ReInfo->_reFilename,
|
snprintf( buf, 1024, "%sresults/%s/%%s-%4d-%02d-%02d-%02d-%02d%%s%%s%%s.xml%%s", GetLocalDir(), ReInfo->_reFilename,
|
||||||
stm->tm_year + 1900, stm->tm_mon + 1, stm->tm_mday, stm->tm_hour, stm->tm_min );
|
stm->tm_year + 1900, stm->tm_mon + 1, stm->tm_mday, stm->tm_hour, stm->tm_min );
|
||||||
filename = strdup(buf); //Makes it possible to reuse buf
|
filename = strdup(buf); //Makes it possible to reuse buf
|
||||||
|
|
|
@ -441,6 +441,9 @@ void GfInit(void)
|
||||||
gfOsInit();
|
gfOsInit();
|
||||||
gfParamInit();
|
gfParamInit();
|
||||||
|
|
||||||
|
// Initialize random generator.
|
||||||
|
srand((unsigned)time(NULL));
|
||||||
|
|
||||||
// Initialize SDL subsystems usefull for TGF.
|
// Initialize SDL subsystems usefull for TGF.
|
||||||
if (SDL_Init(SDL_INIT_TIMER) < 0)
|
if (SDL_Init(SDL_INIT_TIMER) < 0)
|
||||||
GfLogFatal("Couldn't initialize SDL(timer) (%s)\n", SDL_GetError());
|
GfLogFatal("Couldn't initialize SDL(timer) (%s)\n", SDL_GetError());
|
||||||
|
|
Loading…
Reference in a new issue