Update readme and changelog for v1.27.0
[openttd-joker.git] / src / genworld.h
blobca15697fe95d5e378628801e48a32d4dff26cd46
1 /* $Id: genworld.h 23611 2011-12-19 20:56:50Z truebrain $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file genworld.h Functions related to world/map generation. */
12 #ifndef GENWORLD_H
13 #define GENWORLD_H
15 #include "company_type.h"
17 /** Constants related to world generation */
18 enum LandscapeGenerator {
19 /* Order of these enums has to be the same as in lang/english.txt
20 * Otherwise you will get inconsistent behaviour. */
21 LG_ORIGINAL = 0, ///< The original landscape generator
22 LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator
25 static const uint GENERATE_NEW_SEED = UINT_MAX; ///< Create a new random seed
27 /** Modes for GenerateWorld */
28 enum GenWorldMode {
29 GWM_NEWGAME = 0, ///< Generate a map for a new game
30 GWM_EMPTY = 1, ///< Generate an empty map (sea-level)
31 GWM_RANDOM = 2, ///< Generate a random map for SE
32 GWM_HEIGHTMAP = 3, ///< Generate a newgame from a heightmap
35 /** Smoothness presets. */
36 enum TgenSmoothness {
37 TGEN_SMOOTHNESS_BEGIN, ///< First smoothness value.
38 TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN, ///< Smoothness preset 'very smooth'.
39 TGEN_SMOOTHNESS_SMOOTH, ///< Smoothness preset 'smooth'.
40 TGEN_SMOOTHNESS_ROUGH, ///< Smoothness preset 'rough'.
41 TGEN_SMOOTHNESS_VERY_ROUGH, ///< Smoothness preset 'very rough'.
43 TGEN_SMOOTHNESS_END, ///< Used to iterate.
46 static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; ///< Value for custom sea level in difficulty settings.
47 static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1; ///< Minimum percentage a user can specify for custom sea level.
48 static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90; ///< Maximum percentage a user can specify for custom sea level.
50 typedef void GWDoneProc(); ///< Procedure called when the genworld process finishes
51 typedef void GWAbortProc(); ///< Called when genworld is aborted
53 /** Properties of current genworld process */
54 struct GenWorldInfo {
55 bool abort; ///< Whether to abort the thread ASAP
56 bool quit_thread; ///< Do we want to quit the active thread
57 bool threaded; ///< Whether we run _GenerateWorld threaded
58 GenWorldMode mode; ///< What mode are we making a world in
59 CompanyID lc; ///< The local_company before generating
60 uint size_x; ///< X-size of the map
61 uint size_y; ///< Y-size of the map
62 GWDoneProc *proc; ///< Proc that is called when done (can be nullptr)
63 GWAbortProc *abortp; ///< Proc that is called when aborting (can be nullptr)
64 class ThreadObject *thread; ///< The thread we are in (can be nullptr)
67 /** Current stage of world generation process */
68 enum GenWorldProgress {
69 GWP_MAP_INIT, ///< Initialize/allocate the map, start economy
70 GWP_LANDSCAPE, ///< Create the landscape
71 GWP_RIVER, ///< Create the rivers
72 GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
73 GWP_TOWN, ///< Generate towns
74 GWP_INDUSTRY, ///< Generate industries
75 GWP_OBJECT, ///< Generate objects (radio tower, light houses)
76 GWP_TREE, ///< Generate trees
77 GWP_PUBLIC_ROADS, ///< Generate public roads
78 GWP_GAME_INIT, ///< Initialize the game
79 GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
80 GWP_RUNSCRIPT, ///< Runs the game script at most 2500 times, or when ever the script sleeps
81 GWP_GAME_START, ///< Really prepare to start the game
82 GWP_CLASS_COUNT
85 /* genworld.cpp */
86 bool IsGenerateWorldThreaded();
87 void GenerateWorldSetCallback(GWDoneProc *proc);
88 void GenerateWorldSetAbortCallback(GWAbortProc *proc);
89 void WaitTillGeneratedWorld();
90 void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
91 void AbortGeneratingWorld();
92 bool IsGeneratingWorldAborted();
93 void HandleGeneratingWorldAbortion();
95 /* genworld_gui.cpp */
96 void SetNewLandscapeType(byte landscape);
97 void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
98 void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
99 void PrepareGenerateWorldProgress();
100 void ShowGenerateWorldProgress();
101 void StartNewGameWithoutGUI(uint seed);
102 void ShowCreateScenario();
103 void StartScenarioEditor();
105 extern bool _generating_world;
107 #endif /* GENWORLD_H */