diff --git a/include/ege.h b/include/ege.h index d478fb4..7361c42 100644 --- a/include/ege.h +++ b/include/ege.h @@ -1354,8 +1354,10 @@ PVOID EGEAPI getProcfunc(); long EGEAPI getGraphicsVer(); float EGEAPI getfps(); -void EGEAPI randomize(); -unsigned int EGEAPI random(unsigned int n); +unsigned int EGEAPI randomize(); +unsigned int EGEAPI randomize(unsigned int seed); + +unsigned int EGEAPI random(unsigned int n = 0); double EGEAPI randomf(); diff --git a/src/random.cpp b/src/random.cpp index 0c5ae90..ba2421a 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -185,10 +185,18 @@ extern double mtdrand() return mtrand_help()(1.0); } -void randomize() +uint32_t randomize() { static uint32_t add = 0; - mtsrand((uint32_t)time(NULL) + add++); + uint32_t seed = (uint32_t)time(NULL) + add++; + mtsrand(seed); + return seed; +} + +uint32_t randomize(uint32_t seed) +{ + mtsrand(seed); + return seed; } unsigned int random(unsigned int n)