[Scummvm-devel] Re: RNG & get_msecs()

Max Horn max at quendi.de
Tue Oct 14 00:51:04 CEST 2003

Am Dienstag, 14.10.03 um 09:08 Uhr schrieb 
<Torbjorn.E.Andersson at tietoenator.com>:

> Max Horn wrote:
>> Modified Files:
>>        scummvm.cpp
>> Log Message:
>> init random seed with time
> At least on a fast computer, seeding the RNG with _system->get_msecs() 
> will
> simply mean seeding it with 0. I don't know much about RNGs, but this
> doesn't seem like that much of an improvement over the default seed to 
> me.
It certainly won't be worse, though. Note that for a long long time, we 
actually used a seed of 0 - because somebody had added a memset(_rnd, 
0, sizeof(_rnd)) into the Scumm constructor :-)
Anyway, I wasn't aware that  _system->get_msecs() calls SDL_GetTicks(), 
which in turn returns milliseconds since program start. I (incorrectly) 
assumed that it would return milliseconds since boot time, like clock() 

We could replace it with time(NULL), that should be portable and be 
random enough.



More information about the Scummvm-devel mailing list