diff --git a/planet/System.ocg/Math.c b/planet/System.ocg/Math.c index 69b01d0f5..c98bea06e 100644 --- a/planet/System.ocg/Math.c +++ b/planet/System.ocg/Math.c @@ -160,4 +160,10 @@ global func GetSurfaceVector(int x, int y) } return normal; -} \ No newline at end of file +} + +// Proper modulo operation. +global func Mod(a, b) +{ + return (a % b + b) % b; +} diff --git a/src/lib/C4Random.cpp b/src/lib/C4Random.cpp index 78fef9d2b..f04edef29 100644 --- a/src/lib/C4Random.cpp +++ b/src/lib/C4Random.cpp @@ -21,14 +21,21 @@ #include "lib/C4Random.h" #include "control/C4Record.h" +#include #include int RandomCount = 0; -static pcg32 RandomRng, UnsyncedRandomRng; + +static pcg32 SeededRng() +{ + pcg_extras::seed_seq_from seed_source; + return pcg32(seed_source); +} + +static pcg32 RandomRng, UnsyncedRandomRng = SeededRng(); void FixedRandom(uint64_t seed) { - UnsyncedRandomRng.seed(seed); RandomRng.seed(seed); RandomCount = 0; }