src/core/random_func.hpp
author skidd13
Wed, 21 Nov 2007 19:18:34 +0000
changeset 7936 3df083e704f2
parent 7935 c2d1b2f4ecd6
child 7967 a230c063a672
permissions -rw-r--r--
(svn r11489) -Fix r11488: Somehow the code was added multiple times
7935
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     1
/* $Id$ */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     2
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     3
/** @file random_func.h */
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     4
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     5
#ifndef RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     6
#define RANDOM_FUNC_HPP
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     7
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     8
/**************
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
     9
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    10
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    11
 * If enabled, in a network game all randoms will be dumped to the
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    12
 *  stdout if the first client joins (or if you are a client). This
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    13
 *  is to help finding desync problems.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    14
 *
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    15
 * Warning: DO NOT enable this unless you understand what it does
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    16
 **************/
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    17
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    18
//#define RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    19
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    20
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    21
// Enable this to produce higher quality random numbers.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    22
// Doesn't work with network yet.
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    23
// #define MERSENNE_TWISTER
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    24
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    25
void SetRandomSeed(uint32 seed);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    26
#ifdef RANDOM_DEBUG
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    27
	#define Random() DoRandom(__LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    28
	uint32 DoRandom(int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    29
	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    30
	uint DoRandomRange(uint max, int line, const char *file);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    31
#else
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    32
	uint32 Random();
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    33
	uint RandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    34
#endif
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    35
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    36
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    37
uint InteractiveRandomRange(uint max);
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    38
c2d1b2f4ecd6 (svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
diff changeset
    39
#endif /* RANDOM_FUNC_HPP */