summaryrefslogtreecommitdiff
path: root/src/common/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/random.c')
-rw-r--r--src/common/random.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/common/random.c b/src/common/random.c
index a7d432e34..88d5748cf 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -1,33 +1,40 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
+#define HERCULES_CORE
+
+#include "random.h"
+
+#include <time.h> // time
+
+#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
+
+#include "../common/cbasetypes.h" // for WIN32
#include "../common/showmsg.h"
#include "../common/timer.h" // gettick
-#include "random.h"
+
#if defined(WIN32)
- #include "../common/winapi.h"
+# include "../common/winapi.h"
#elif defined(HAVE_GETPID) || defined(HAVE_GETTID)
- #include <sys/types.h>
- #include <unistd.h>
+# include <sys/types.h>
+# include <unistd.h>
#endif
-#include <time.h> // time
-#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
/// Initializes the random number generator with an appropriate seed.
void rnd_init(void)
{
- uint32 seed = iTimer->gettick();
- seed += (uint32)time(NULL);
+ unsigned long seed = (unsigned long)timer->gettick();
+ seed += (unsigned long)time(NULL);
#if defined(WIN32)
- seed += GetCurrentProcessId();
- seed += GetCurrentThreadId();
+ seed += (unsigned long)GetCurrentProcessId();
+ seed += (unsigned long)GetCurrentThreadId();
#else
#if defined(HAVE_GETPID)
- seed += (uint32)getpid();
+ seed += (unsigned long)getpid();
#endif // HAVE_GETPID
#if defined(HAVE_GETTID)
- seed += (uint32)gettid();
+ seed += (unsigned long)gettid();
#endif // HAVE_GETTID
#endif
init_genrand(seed);