]> git.pond.sub.org Git - empserver/blobdiff - src/lib/gen/chance.c
Improve portability to really outmoded compilers
[empserver] / src / lib / gen / chance.c
index a92fa6fc19bdcb877e68dba50ece75b1910a4c0e..b20dfb9bda63d54445ab06e097dcba95fae2661e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -34,7 +34,6 @@
 
 #include <fcntl.h>
 #include <math.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <sys/time.h>
 #include <unistd.h>
@@ -120,8 +119,12 @@ seed_prng(unsigned seed)
     init_genrand(seed);
 }
 
-static uint32_t
-djb_hash(uint32_t hash, void *buf, size_t sz)
+/*
+ * Note: this is DJB's hash function when unsigned is 32 bits and hash
+ * is initially 5381.
+ */
+static unsigned
+djb_hash(unsigned hash, void *buf, size_t sz)
 {
     unsigned char *bp;
 
@@ -138,7 +141,7 @@ unsigned
 pick_seed(void)
 {
     int fd;
-    uint32_t seed;
+    unsigned seed;
     int got_seed = 0;
     struct timeval tv;
     pid_t pid;