From 17dc61b782ab935df1a3bc963df310b84c8acd03 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 14:08:00 +0300 Subject: [PATCH] Make randomGetSeed cross-platform See #17 --- src/random.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/random.cc b/src/random.cc index 6d059af..b9ed226 100644 --- a/src/random.cc +++ b/src/random.cc @@ -6,11 +6,15 @@ #include #include +#if defined(_WIN32) // clang-format off #define WIN32_LEAN_AND_MEAN #include #include // clang-format on +#else +#include +#endif // 0x50D4BA const double dbl_50D4BA = 36.42; @@ -208,7 +212,13 @@ void randomSeedPrerandomInternal(int seed) // 0x4A3258 unsigned int randomGetSeed() { +#if defined(_WIN32) return timeGetTime(); +#else + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec / 1000; +#endif } // 0x4A3264