18 #include "settings.h" |
18 #include "settings.h" |
19 #include "heightmap.h" |
19 #include "heightmap.h" |
20 #include "date.h" |
20 #include "date.h" |
21 |
21 |
22 void GenerateLandscape(byte mode); |
22 void GenerateLandscape(byte mode); |
23 void GenerateClearTile(void); |
23 void GenerateClearTile(); |
24 void GenerateIndustries(void); |
24 void GenerateIndustries(); |
25 void GenerateUnmovables(void); |
25 void GenerateUnmovables(); |
26 bool GenerateTowns(void); |
26 bool GenerateTowns(); |
27 void GenerateTrees(void); |
27 void GenerateTrees(); |
28 |
28 |
29 void StartupEconomy(void); |
29 void StartupEconomy(); |
30 void StartupPlayers(void); |
30 void StartupPlayers(); |
31 void StartupDisasters(void); |
31 void StartupDisasters(); |
32 |
32 |
33 void InitializeGame(int mode, uint size_x, uint size_y); |
33 void InitializeGame(int mode, uint size_x, uint size_y); |
34 |
34 |
35 void ConvertGroundTilesIntoWaterTiles(void); |
35 void ConvertGroundTilesIntoWaterTiles(); |
36 |
36 |
37 /* Please only use this variable in genworld.h and genworld.c and |
37 /* Please only use this variable in genworld.h and genworld.c and |
38 * nowhere else. For speed improvements we need it to be global, but |
38 * nowhere else. For speed improvements we need it to be global, but |
39 * in no way the meaning of it is to use it anywhere else besides |
39 * in no way the meaning of it is to use it anywhere else besides |
40 * in the genworld.h and genworld.c! -- TrueLight */ |
40 * in the genworld.h and genworld.c! -- TrueLight */ |
56 * Returns true if the thread wants the main program to do a (full) paint. |
56 * Returns true if the thread wants the main program to do a (full) paint. |
57 * If this returns false, please do not update the screen. Because we are |
57 * If this returns false, please do not update the screen. Because we are |
58 * writing in a thread, it can cause damaged data (reading and writing the |
58 * writing in a thread, it can cause damaged data (reading and writing the |
59 * same tile at the same time). |
59 * same tile at the same time). |
60 */ |
60 */ |
61 bool IsGeneratingWorldReadyForPaint(void) |
61 bool IsGeneratingWorldReadyForPaint() |
62 { |
62 { |
63 /* If we are in quit_thread mode, ignore this and always return false. This |
63 /* If we are in quit_thread mode, ignore this and always return false. This |
64 * forces the screen to not be drawn, and the GUI not to wait for a draw. */ |
64 * forces the screen to not be drawn, and the GUI not to wait for a draw. */ |
65 if (!_gw.active || _gw.quit_thread || !_gw.threaded) return false; |
65 if (!_gw.active || _gw.quit_thread || !_gw.threaded) return false; |
66 |
66 |
178 |
178 |
179 /** |
179 /** |
180 * This will wait for the thread to finish up his work. It will not continue |
180 * This will wait for the thread to finish up his work. It will not continue |
181 * till the work is done. |
181 * till the work is done. |
182 */ |
182 */ |
183 void WaitTillGeneratedWorld(void) |
183 void WaitTillGeneratedWorld() |
184 { |
184 { |
185 if (_gw.thread == NULL) return; |
185 if (_gw.thread == NULL) return; |
186 _gw.quit_thread = true; |
186 _gw.quit_thread = true; |
187 OTTDJoinThread((OTTDThread*)_gw.thread); |
187 OTTDJoinThread((OTTDThread*)_gw.thread); |
188 _gw.thread = NULL; |
188 _gw.thread = NULL; |
190 } |
190 } |
191 |
191 |
192 /** |
192 /** |
193 * Initializes the abortion process |
193 * Initializes the abortion process |
194 */ |
194 */ |
195 void AbortGeneratingWorld(void) |
195 void AbortGeneratingWorld() |
196 { |
196 { |
197 _gw.abort = true; |
197 _gw.abort = true; |
198 } |
198 } |
199 |
199 |
200 /** |
200 /** |
201 * Is the generation being aborted? |
201 * Is the generation being aborted? |
202 */ |
202 */ |
203 bool IsGeneratingWorldAborted(void) |
203 bool IsGeneratingWorldAborted() |
204 { |
204 { |
205 return _gw.abort; |
205 return _gw.abort; |
206 } |
206 } |
207 |
207 |
208 /** |
208 /** |
209 * Really handle the abortion, i.e. clean up some of the mess |
209 * Really handle the abortion, i.e. clean up some of the mess |
210 */ |
210 */ |
211 void HandleGeneratingWorldAbortion(void) |
211 void HandleGeneratingWorldAbortion() |
212 { |
212 { |
213 /* Clean up - in SE create an empty map, otherwise, go to intro menu */ |
213 /* Clean up - in SE create an empty map, otherwise, go to intro menu */ |
214 _switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU; |
214 _switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU; |
215 |
215 |
216 if (_gw.abortp != NULL) _gw.abortp(); |
216 if (_gw.abortp != NULL) _gw.abortp(); |