[Scummvm-git-logs] scummvm branch-2-3 -> d439655643f9240eec3289ed06a36fb02dc297ab

sev- sev at scummvm.org
Sat Aug 28 20:56:08 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d439655643 COMMON: improve RandomSource initial seed


Commit: d439655643f9240eec3289ed06a36fb02dc297ab
    https://github.com/scummvm/scummvm/commit/d439655643f9240eec3289ed06a36fb02dc297ab
Author: Die4Ever (die4ever2006 at hotmail.com)
Date: 2021-08-28T22:55:53+02:00

Commit Message:
COMMON: improve RandomSource initial seed

This improves the range of seeds compared to using only getMillis (which
is the number of milliseconds since program start) as the seed. This was
especially an issue if you started the game directly from command line,
Steam, or GOG instead of using the ScummVM interface. Previously the
initial seed was just the load time, which can have very small variance
on a fast computer.

Changed paths:
    common/random.cpp


diff --git a/common/random.cpp b/common/random.cpp
index 2b7d140510..5da2f67337 100644
--- a/common/random.cpp
+++ b/common/random.cpp
@@ -37,7 +37,13 @@ RandomSource::RandomSource(const String &name) {
 #ifdef ENABLE_EVENTRECORDER
 	setSeed(g_eventRec.getRandomSeed(name));
 #else
-	setSeed(g_system->getMillis());
+	TimeDate time;
+	g_system->getTimeAndDate(time);
+	uint32 newSeed = time.tm_sec + time.tm_min * 60 + time.tm_hour * 3600;
+	newSeed += time.tm_mday * 86400 + time.tm_mon * 86400 * 31;
+	newSeed += time.tm_year * 86400 * 366;
+	newSeed = newSeed * 1000 + g_system->getMillis();
+	setSeed(newSeed);
 #endif
 }
 




More information about the Scummvm-git-logs mailing list