src/functions.h
branchnoai
changeset 9722 ebf0ece7d8f6
parent 9718 f82a4facea8b
child 9723 eee46cb39750
equal deleted inserted replaced
9721:9a27928bcd5e 9722:ebf0ece7d8f6
     4 
     4 
     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"
       
    10 #include "core/random_func.hpp"
     9 
    11 
    10 void UpdateTownMaxPass(Town *t);
    12 void UpdateTownMaxPass(Town *t);
    11 
    13 
    12 /* clear_land.cpp */
    14 /* clear_land.cpp */
    13 void DrawHillyLandTile(const TileInfo *ti);
    15 void DrawHillyLandTile(const TileInfo *ti);
    29 /* standard */
    31 /* standard */
    30 void ShowInfo(const char *str);
    32 void ShowInfo(const char *str);
    31 void CDECL ShowInfoF(const char *str, ...);
    33 void CDECL ShowInfoF(const char *str, ...);
    32 
    34 
    33 /* openttd.cpp */
    35 /* openttd.cpp */
    34 
       
    35 /**************
       
    36  * Warning: DO NOT enable this unless you understand what it does
       
    37  *
       
    38  * If enabled, in a network game all randoms will be dumped to the
       
    39  *  stdout if the first client joins (or if you are a client). This
       
    40  *  is to help finding desync problems.
       
    41  *
       
    42  * Warning: DO NOT enable this unless you understand what it does
       
    43  **************/
       
    44 
       
    45 //#define RANDOM_DEBUG
       
    46 
       
    47 
       
    48 // Enable this to produce higher quality random numbers.
       
    49 // Doesn't work with network yet.
       
    50 //#define MERSENNE_TWISTER
       
    51 
       
    52 // Mersenne twister functions
       
    53 void SeedMT(uint32 seed);
       
    54 uint32 RandomMT();
       
    55 
       
    56 
       
    57 #ifdef MERSENNE_TWISTER
       
    58 	static inline uint32 Random() { return RandomMT(); }
       
    59 	uint RandomRange(uint max);
       
    60 #else
       
    61 
       
    62 #ifdef RANDOM_DEBUG
       
    63 	#define Random() DoRandom(__LINE__, __FILE__)
       
    64 	uint32 DoRandom(int line, const char *file);
       
    65 	#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
       
    66 	uint DoRandomRange(uint max, int line, const char *file);
       
    67 #else
       
    68 	uint32 Random();
       
    69 	uint RandomRange(uint max);
       
    70 #endif
       
    71 #endif // MERSENNE_TWISTER
       
    72 
       
    73 static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
    36 static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
    74 static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
    37 static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
    75 
       
    76 
       
    77 uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
       
    78 uint InteractiveRandomRange(uint max);
       
    79 
    38 
    80 /* texteff.cpp */
    39 /* texteff.cpp */
    81 void AddAnimatedTile(TileIndex tile);
    40 void AddAnimatedTile(TileIndex tile);
    82 void DeleteAnimatedTile(TileIndex tile);
    41 void DeleteAnimatedTile(TileIndex tile);
    83 void AnimateAnimatedTiles();
    42 void AnimateAnimatedTiles();
   121 void InvalidateWindowClasses(WindowClass cls);
    80 void InvalidateWindowClasses(WindowClass cls);
   122 void InvalidateWindowClassesData(WindowClass cls);
    81 void InvalidateWindowClassesData(WindowClass cls);
   123 void DeleteWindowById(WindowClass cls, WindowNumber number);
    82 void DeleteWindowById(WindowClass cls, WindowNumber number);
   124 void DeleteWindowByClass(WindowClass cls);
    83 void DeleteWindowByClass(WindowClass cls);
   125 
    84 
   126 void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w);
    85 void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
   127 void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num);
    86 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
   128 
    87 
   129 void ResetObjectToPlace();
    88 void ResetObjectToPlace();
   130 
    89 
   131 bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
    90 bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
   132 
    91