src/functions.h
changeset 8431 68fb2ccbce06
parent 8385 aedd7656cfd1
child 8444 9317090e9c8c
equal deleted inserted replaced
8430:9f32cec597ed 8431:68fb2ccbce06
     5 #ifndef FUNCTIONS_H
     5 #ifndef FUNCTIONS_H
     6 #define FUNCTIONS_H
     6 #define FUNCTIONS_H
     7 
     7 
     8 #include "gfx.h"
     8 #include "gfx.h"
     9 #include "viewport.h"
     9 #include "viewport.h"
       
    10 #include "core/random_func.hpp"
    10 
    11 
    11 void UpdateTownMaxPass(Town *t);
    12 void UpdateTownMaxPass(Town *t);
    12 
    13 
    13 /* clear_land.cpp */
    14 /* clear_land.cpp */
    14 void DrawHillyLandTile(const TileInfo *ti);
    15 void DrawHillyLandTile(const TileInfo *ti);
    30 /* standard */
    31 /* standard */
    31 void ShowInfo(const char *str);
    32 void ShowInfo(const char *str);
    32 void CDECL ShowInfoF(const char *str, ...);
    33 void CDECL ShowInfoF(const char *str, ...);
    33 
    34 
    34 /* openttd.cpp */
    35 /* openttd.cpp */
    35 
       
    36 /**************
       
    37  * Warning: DO NOT enable this unless you understand what it does
       
    38  *
       
    39  * If enabled, in a network game all randoms will be dumped to the
       
    40  *  stdout if the first client joins (or if you are a client). This
       
    41  *  is to help finding desync problems.
       
    42  *
       
    43  * Warning: DO NOT enable this unless you understand what it does
       
    44  **************/
       
    45 
       
    46 //#define RANDOM_DEBUG
       
    47 
       
    48 
       
    49 // Enable this to produce higher quality random numbers.
       
    50 // Doesn't work with network yet.
       
    51 //#define MERSENNE_TWISTER
       
    52 
       
    53 // Mersenne twister functions
       
    54 void SeedMT(uint32 seed);
       
    55 uint32 RandomMT();
       
    56 
       
    57 
       
    58 #ifdef MERSENNE_TWISTER
       
    59 	static inline uint32 Random() { return RandomMT(); }
       
    60 	uint RandomRange(uint max);
       
    61 #else
       
    62 
       
    63 #ifdef RANDOM_DEBUG
       
    64 	#define Random() DoRandom(__LINE__, __FILE__)
       
    65 	uint32 DoRandom(int line, const char *file);
       
    66 	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
       
    67 	uint DoRandomRange(uint max, int line, const char *file);
       
    68 #else
       
    69 	uint32 Random();
       
    70 	uint RandomRange(uint max);
       
    71 #endif
       
    72 #endif // MERSENNE_TWISTER
       
    73 
       
    74 static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
    36 static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
    75 static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
    37 static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
    76 
       
    77 
       
    78 uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
       
    79 uint InteractiveRandomRange(uint max);
       
    80 
    38 
    81 /* texteff.cpp */
    39 /* texteff.cpp */
    82 void AddAnimatedTile(TileIndex tile);
    40 void AddAnimatedTile(TileIndex tile);
    83 void DeleteAnimatedTile(TileIndex tile);
    41 void DeleteAnimatedTile(TileIndex tile);
    84 void AnimateAnimatedTiles();
    42 void AnimateAnimatedTiles();