src/core/random_func.hpp
branchnoai
changeset 9722 ebf0ece7d8f6
child 9723 eee46cb39750
equal deleted inserted replaced
9721:9a27928bcd5e 9722:ebf0ece7d8f6
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file random_func.h */
       
     4 
       
     5 #ifndef RANDOM_FUNC_HPP
       
     6 #define RANDOM_FUNC_HPP
       
     7 
       
     8 /**************
       
     9  * Warning: DO NOT enable this unless you understand what it does
       
    10  *
       
    11  * If enabled, in a network game all randoms will be dumped to the
       
    12  *  stdout if the first client joins (or if you are a client). This
       
    13  *  is to help finding desync problems.
       
    14  *
       
    15  * Warning: DO NOT enable this unless you understand what it does
       
    16  **************/
       
    17 
       
    18 //#define RANDOM_DEBUG
       
    19 
       
    20 
       
    21 // Enable this to produce higher quality random numbers.
       
    22 // Doesn't work with network yet.
       
    23 // #define MERSENNE_TWISTER
       
    24 
       
    25 void SetRandomSeed(uint32 seed);
       
    26 #ifdef RANDOM_DEBUG
       
    27 	#define Random() DoRandom(__LINE__, __FILE__)
       
    28 	uint32 DoRandom(int line, const char *file);
       
    29 	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
       
    30 	uint DoRandomRange(uint max, int line, const char *file);
       
    31 #else
       
    32 	uint32 Random();
       
    33 	uint RandomRange(uint max);
       
    34 #endif
       
    35 
       
    36 uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
       
    37 uint InteractiveRandomRange(uint max);
       
    38 
       
    39 #endif /* RANDOM_FUNC_HPP */