summaryrefslogtreecommitdiff
path: root/functions.h
diff options
context:
space:
mode:
authorludde <ludde@openttd.org>2005-07-15 20:29:06 +0000
committerludde <ludde@openttd.org>2005-07-15 20:29:06 +0000
commit71f9078bddbf26a771c259bc4cde377b90a980ba (patch)
tree4082dbe36cd4d476e1d16f70a88eaa90adb7523f /functions.h
parentc964809d374ef9af63a384a1bd7bc01cdc1bbbf5 (diff)
downloadopenttd-71f9078bddbf26a771c259bc4cde377b90a980ba.tar.xz
(svn r2583) Move OS specific code out of misc.c
Added support for Mersenne Twister random number generator (not implemented in network yet) Wrap player randoms around #ifdef
Diffstat (limited to 'functions.h')
-rw-r--r--functions.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/functions.h b/functions.h
index 4960eb338..1ea2c9a8e 100644
--- a/functions.h
+++ b/functions.h
@@ -93,6 +93,21 @@ void NORETURN CDECL error(const char *str, ...);
//#define RANDOM_DEBUG
+
+// Enable this to produce higher quality random numbers.
+// Doesn't work with network yet.
+//#define MERSENNE_TWISTER
+
+// Mersenne twister functions
+void SeedMT(uint32 seed);
+uint32 RandomMT(void);
+
+
+#ifdef MERSENNE_TWISTER
+ static inline uint32 Random(void) { return RandomMT(); }
+ uint RandomRange(uint max);
+#else
+
#ifdef RANDOM_DEBUG
#define Random() DoRandom(__LINE__, __FILE__)
uint32 DoRandom(int line, const char *file);
@@ -101,12 +116,18 @@ void NORETURN CDECL error(const char *str, ...);
#else
uint32 Random(void);
uint RandomRange(uint max);
-
- static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
- static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); }
#endif
+#endif // MERSENNE_TWISTER
+
+static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
+static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); }
+
+#ifdef PLAYER_SEED_RANDOM
void InitPlayerRandoms(void);
+#endif
+
+
uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
uint InteractiveRandomRange(uint max);