author | truelight |
Sat, 20 Oct 2007 10:42:28 +0000 | |
branch | noai |
changeset 9718 | f82a4facea8b |
parent 9704 | 197cb8c6ae17 |
child 9722 | ebf0ece7d8f6 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
3 |
/** @file functions.h */ |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
4 |
|
0 | 5 |
#ifndef FUNCTIONS_H |
6 |
#define FUNCTIONS_H |
|
7 |
||
5887
063ca43b682c
(svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents:
5838
diff
changeset
|
8 |
#include "gfx.h" |
063ca43b682c
(svn r8095) -Codechange: stuff that is not related to HAL moved from hal.h to gfx.h
KUDr
parents:
5838
diff
changeset
|
9 |
|
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1335
diff
changeset
|
10 |
void UpdateTownMaxPass(Town *t); |
0 | 11 |
|
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
12 |
/* clear_land.cpp */ |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2380
diff
changeset
|
13 |
void DrawHillyLandTile(const TileInfo *ti); |
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2380
diff
changeset
|
14 |
void DrawClearLandTile(const TileInfo *ti, byte set); |
2220 | 15 |
void DrawClearLandFence(const TileInfo *ti); |
1420
5308b177b5b3
(svn r1924) Use same type names in declaration and implementation
tron
parents:
1377
diff
changeset
|
16 |
void TileLoopClearHelper(TileIndex tile); |
0 | 17 |
|
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
18 |
/* water_land.cpp */ |
0 | 19 |
void DrawShipDepotSprite(int x, int y, int image); |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1935
diff
changeset
|
20 |
void TileLoop_Water(TileIndex tile); |
0 | 21 |
|
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
22 |
/* players.cpp */ |
9629 | 23 |
bool CheckPlayerHasMoney(CommandCost cost); |
24 |
void SubtractMoneyFromPlayer(CommandCost cost); |
|
25 |
void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost); |
|
4849
9a3c3ae7f62f
(svn r6775) -Codechange: Use some more proper types, especially Owner and PlayerID as
Darkvater
parents:
4833
diff
changeset
|
26 |
bool CheckOwnership(Owner owner); |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1935
diff
changeset
|
27 |
bool CheckTileOwnership(TileIndex tile); |
0 | 28 |
|
29 |
/* standard */ |
|
30 |
void ShowInfo(const char *str); |
|
31 |
void CDECL ShowInfoF(const char *str, ...); |
|
32 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
33 |
/* openttd.cpp */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
34 |
|
4432
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
35 |
/************** |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
36 |
* Warning: DO NOT enable this unless you understand what it does |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
37 |
* |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
38 |
* If enabled, in a network game all randoms will be dumped to the |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
39 |
* stdout if the first client joins (or if you are a client). This |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
40 |
* is to help finding desync problems. |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
41 |
* |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
42 |
* Warning: DO NOT enable this unless you understand what it does |
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4300
diff
changeset
|
43 |
**************/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
44 |
|
1539
3d5b40209884
(svn r2043) -Fix: committed too many files in the last commit
truelight
parents:
1538
diff
changeset
|
45 |
//#define RANDOM_DEBUG |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
46 |
|
2073 | 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); |
|
6573 | 54 |
uint32 RandomMT(); |
2073 | 55 |
|
56 |
||
57 |
#ifdef MERSENNE_TWISTER |
|
6573 | 58 |
static inline uint32 Random() { return RandomMT(); } |
2073 | 59 |
uint RandomRange(uint max); |
60 |
#else |
|
61 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
62 |
#ifdef RANDOM_DEBUG |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
63 |
#define Random() DoRandom(__LINE__, __FILE__) |
1120
ea3bf8bc6678
(svn r1621) -Fix: fixed some compiler warnings for the random-debug-switch
truelight
parents:
1115
diff
changeset
|
64 |
uint32 DoRandom(int line, const char *file); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
65 |
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__) |
1120
ea3bf8bc6678
(svn r1621) -Fix: fixed some compiler warnings for the random-debug-switch
truelight
parents:
1115
diff
changeset
|
66 |
uint DoRandomRange(uint max, int line, const char *file); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
67 |
#else |
6573 | 68 |
uint32 Random(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
69 |
uint RandomRange(uint max); |
2073 | 70 |
#endif |
71 |
#endif // MERSENNE_TWISTER |
|
2051 | 72 |
|
2073 | 73 |
static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); } |
6573 | 74 |
static inline TileIndex RandomTile() { return TILE_MASK(Random()); } |
2073 | 75 |
|
76 |
||
6573 | 77 |
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link |
239 | 78 |
uint InteractiveRandomRange(uint max); |
79 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
80 |
/* texteff.cpp */ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
81 |
void AddAnimatedTile(TileIndex tile); |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1935
diff
changeset
|
82 |
void DeleteAnimatedTile(TileIndex tile); |
6573 | 83 |
void AnimateAnimatedTiles(); |
84 |
void InitializeAnimatedTiles(); |
|
0 | 85 |
|
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
86 |
/* tunnelbridge_cmd.cpp */ |
2639 | 87 |
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len); |
0 | 88 |
uint32 GetBridgeLength(TileIndex begin, TileIndex end); |
89 |
int CalcBridgeLenCostFactor(int x); |
|
90 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
91 |
/* misc_cmd.cpp */ |
6573 | 92 |
void PlaceTreesRandomly(); |
0 | 93 |
|
94 |
void InitializeLandscapeVariables(bool only_constants); |
|
95 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
96 |
/* misc.cpp */ |
4862
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4849
diff
changeset
|
97 |
bool IsCustomName(StringID id); |
0 | 98 |
void DeleteName(StringID id); |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
99 |
char *GetName(char *buff, StringID id, const char *last); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
100 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
101 |
#define AllocateName(name, skip) RealAllocateName(name, skip, false) |
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1317
diff
changeset
|
102 |
StringID RealAllocateName(const char *name, byte skip, bool check_double); |
6573 | 103 |
void ConvertNameArray(); |
0 | 104 |
|
105 |
/* misc functions */ |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
106 |
/** |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
107 |
* Mark a tile given by its coordinate dirty for repaint. |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
108 |
* |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
109 |
* @ingroup dirty |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
110 |
*/ |
0 | 111 |
void MarkTileDirty(int x, int y); |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
112 |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
113 |
/** |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
114 |
* Mark a tile given by its index dirty for repaint. |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
115 |
* |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
116 |
* @ingroup dirty |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
117 |
*/ |
0 | 118 |
void MarkTileDirtyByTile(TileIndex tile); |
2788
db2896482939
(svn r3336) byte -> WindowClass, uint16 -> WindowNumber
tron
parents:
2639
diff
changeset
|
119 |
void InvalidateWindow(WindowClass cls, WindowNumber number); |
db2896482939
(svn r3336) byte -> WindowClass, uint16 -> WindowNumber
tron
parents:
2639
diff
changeset
|
120 |
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index); |
db2896482939
(svn r3336) byte -> WindowClass, uint16 -> WindowNumber
tron
parents:
2639
diff
changeset
|
121 |
void InvalidateWindowClasses(WindowClass cls); |
4766
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4548
diff
changeset
|
122 |
void InvalidateWindowClassesData(WindowClass cls); |
0 | 123 |
void DeleteWindowById(WindowClass cls, WindowNumber number); |
999
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
998
diff
changeset
|
124 |
void DeleteWindowByClass(WindowClass cls); |
0 | 125 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5887
diff
changeset
|
126 |
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5887
diff
changeset
|
127 |
void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num); |
0 | 128 |
|
6573 | 129 |
void ResetObjectToPlace(); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
130 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
131 |
bool ScrollWindowTo(int x, int y, Window *w, bool instant = false); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
132 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
133 |
bool ScrollMainWindowToTile(TileIndex tile, bool instant = false); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
134 |
bool ScrollMainWindowTo(int x, int y, bool instant = false); |
3794
ac26a7b4615d
(svn r4790) Remove slope magic from EnsureNoVehicleZ() and rename it to EnsureNoVehicleOnGround() to make more clear what it does
tron
parents:
3636
diff
changeset
|
135 |
bool EnsureNoVehicleOnGround(TileIndex tile); |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
136 |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
137 |
/** |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
138 |
* Mark all viewports dirty for repaint. |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
139 |
* |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
140 |
* @ingroup dirty |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
141 |
*/ |
0 | 142 |
void MarkAllViewportsDirty(int left, int top, int right, int bottom); |
9629 | 143 |
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost); |
144 |
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost); |
|
0 | 145 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1935
diff
changeset
|
146 |
bool CheckIfAuthorityAllows(TileIndex tile); |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1935
diff
changeset
|
147 |
Town *ClosestTownFromTile(TileIndex tile, uint threshold); |
0 | 148 |
void ChangeTownRating(Town *t, int add, int max); |
149 |
||
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3794
diff
changeset
|
150 |
uint GetTownRadiusGroup(const Town* t, TileIndex tile); |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
151 |
void ShowHighscoreTable(int difficulty, int8 rank); |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
152 |
|
0 | 153 |
int FindFirstBit(uint32 x); |
154 |
||
6573 | 155 |
void AfterLoadTown(); |
156 |
void UpdatePatches(); |
|
157 |
void AskExitGame(); |
|
158 |
void AskExitToGameMenu(); |
|
0 | 159 |
|
6573 | 160 |
void RedrawAutosave(); |
0 | 161 |
|
162 |
StringID RemapOldStringID(StringID s); |
|
163 |
||
164 |
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str); |
|
165 |
||
166 |
enum { |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
167 |
SLD_LOAD_GAME, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
168 |
SLD_LOAD_SCENARIO, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
169 |
SLD_SAVE_GAME, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
170 |
SLD_SAVE_SCENARIO, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
171 |
SLD_LOAD_HEIGHTMAP, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4261
diff
changeset
|
172 |
SLD_NEW_GAME, |
0 | 173 |
}; |
174 |
void ShowSaveLoadDialog(int mode); |
|
175 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5919
diff
changeset
|
176 |
/* callback from drivers that is called if the game size changes dynamically */ |
6573 | 177 |
void GameSizeChanged(); |
0 | 178 |
bool FileExists(const char *filename); |
3329
992d1f7cb747
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3297
diff
changeset
|
179 |
const char *GetCurrentLocale(const char *param); |
1310
85cde2193afc
(svn r1814) Let ReadFileToMem() return void* (instead of byte*) because we don't know what the caller wants to do with the data
tron
parents:
1309
diff
changeset
|
180 |
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); |
0 | 181 |
|
6573 | 182 |
void LoadFromConfig(); |
183 |
void SaveToConfig(); |
|
184 |
void CheckConfig(); |
|
0 | 185 |
int ttd_main(int argc, char* argv[]); |
6573 | 186 |
void HandleExitGameRequest(); |
0 | 187 |
|
188 |
#endif /* FUNCTIONS_H */ |