diff rogue5/mdport.c @ 252:3d4252fa2ed3

Use more portable random seed generation. The new function md_random_seed() has replaced time() + getpid() and similar methods. Putting everything in mdport.c slightly reduces the warnings and workarounds.
author John "Elwin" Edwards
date Sat, 28 Jan 2017 15:49:41 -0500
parents 600873555ec0
children 8b6aba552f6f
line wrap: on
line diff
--- a/rogue5/mdport.c	Sat Jan 28 11:45:36 2017 -0500
+++ b/rogue5/mdport.c	Sat Jan 28 15:49:41 2017 -0500
@@ -98,6 +98,7 @@
 #include <limits.h>
 #include <sys/stat.h>
 #include <signal.h>
+#include <time.h>
 #include "extern.h"
 
 #if !defined(PATH_MAX) && defined(_MAX_PATH)
@@ -411,16 +412,6 @@
 #endif
 }
 
-pid_t
-md_getpid(void)
-{
-#ifdef _WIN32
-    return( _getpid() );
-#else
-    return( getpid() );
-#endif
-}
-
 char *
 md_getusername(void)
 {
@@ -1493,6 +1484,19 @@
 #endif
 }
 
+unsigned int
+md_random_seed(void)
+{
+    unsigned int seed;
+    seed = (unsigned int) time((time_t *) NULL);
+#ifdef _WIN32
+    seed += _getpid();
+#else
+    seed += getpid();
+#endif
+    return seed;
+}
+
 #if defined(CHECKTIME)
 void
 md_start_checkout_timer(int time)