Make randomGetSeed cross-platform

See #17
This commit is contained in:
Alexander Batalov 2022-05-28 14:08:00 +03:00
parent 6ae1afc57c
commit 17dc61b782
1 changed files with 10 additions and 0 deletions

View File

@ -6,11 +6,15 @@
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_WIN32)
// clang-format off // clang-format off
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <timeapi.h> #include <timeapi.h>
// clang-format on // clang-format on
#else
#include <sys/time.h>
#endif
// 0x50D4BA // 0x50D4BA
const double dbl_50D4BA = 36.42; const double dbl_50D4BA = 36.42;
@ -208,7 +212,13 @@ void randomSeedPrerandomInternal(int seed)
// 0x4A3258 // 0x4A3258
unsigned int randomGetSeed() unsigned int randomGetSeed()
{ {
#if defined(_WIN32)
return timeGetTime(); return timeGetTime();
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_usec / 1000;
#endif
} }
// 0x4A3264 // 0x4A3264