OpenTTD
genworld.h
Go to the documentation of this file.
1 /* $Id$ */
2 
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  */
9 
12 #ifndef GENWORLD_H
13 #define GENWORLD_H
14 
15 #include "company_type.h"
16 #include <thread>
17 
20  /* Order of these enums has to be the same as in lang/english.txt
21  * Otherwise you will get inconsistent behaviour. */
24 };
25 
26 static const uint32 GENERATE_NEW_SEED = UINT32_MAX;
27 
31  GWM_EMPTY = 1,
32  GWM_RANDOM = 2,
34 };
35 
43 
45 };
46 
47 static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4;
48 static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1;
49 static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90;
50 
51 typedef void GWDoneProc();
52 typedef void GWAbortProc();
53 
55 struct GenWorldInfo {
56  bool abort;
57  bool quit_thread;
58  bool threaded;
61  uint size_x;
62  uint size_y;
65  std::thread thread;
66 };
67 
82  GWP_CLASS_COUNT
83 };
84 
85 /* genworld.cpp */
90 void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
94 
95 /* genworld_gui.cpp */
96 void SetNewLandscapeType(byte landscape);
97 void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
101 void StartNewGameWithoutGUI(uint32 seed);
102 void ShowCreateScenario();
103 void StartScenarioEditor();
104 
105 extern bool _generating_world;
106 
107 #endif /* GENWORLD_H */
Owner
Enum for all companies/owners.
Definition: company_type.h:20
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
Generate trees.
Definition: genworld.h:77
Generate industries.
Definition: genworld.h:75
void GWDoneProc()
Procedure called when the genworld process finishes.
Definition: genworld.h:51
GenWorldProgress
Current stage of world generation process.
Definition: genworld.h:69
Generate objects (radio tower, light houses)
Definition: genworld.h:76
Generate a map for a new game.
Definition: genworld.h:30
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted...
Definition: genworld.cpp:234
uint size_y
Y-size of the map.
Definition: genworld.h:62
GenWorldMode
Modes for GenerateWorld.
Definition: genworld.h:29
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition: genworld.h:47
Create the rivers.
Definition: genworld.h:72
Initialize/allocate the map, start economy.
Definition: genworld.h:70
std::thread thread
The thread we are in (joinable if a thread was created)
Definition: genworld.h:65
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:268
Smoothness preset &#39;smooth&#39;.
Definition: genworld.h:40
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Generate a newgame from a heightmap.
Definition: genworld.h:33
GenWorldMode mode
What mode are we making a world in.
Definition: genworld.h:59
bool quit_thread
Do we want to quit the active thread.
Definition: genworld.h:57
uint size_x
X-size of the map.
Definition: genworld.h:61
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
Definition: genworld.h:26
Smoothness preset &#39;rough&#39;.
Definition: genworld.h:41
Smoothness preset &#39;very rough&#39;.
Definition: genworld.h:42
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
bool abort
Whether to abort the thread ASAP.
Definition: genworld.h:56
Create the landscape.
Definition: genworld.h:71
GWDoneProc * proc
Proc that is called when done (can be nullptr)
Definition: genworld.h:63
TgenSmoothness
Smoothness presets.
Definition: genworld.h:37
Generate towns.
Definition: genworld.h:74
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:62
bool IsGenerateWorldThreaded()
Tells if the world generation is done in a thread or not.
Definition: genworld.cpp:68
TerraGenesis Perlin landscape generator.
Definition: genworld.h:23
bool threaded
Whether we run _GenerateWorld threaded.
Definition: genworld.h:58
Properties of current genworld process.
Definition: genworld.h:55
Generate an empty map (sea-level)
Definition: genworld.h:31
void StartScenarioEditor()
Start with a scenario editor.
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings=true)
Generate a world.
Definition: genworld.cpp:297
Runs the tile loop 1280 times to make snow etc.
Definition: genworld.h:79
Used to iterate.
Definition: genworld.h:44
void GWAbortProc()
Called when genworld is aborted.
Definition: genworld.h:52
GWAbortProc * abortp
Proc that is called when aborting (can be nullptr)
Definition: genworld.h:64
First smoothness value.
Definition: genworld.h:38
LandscapeGenerator
Constants related to world generation.
Definition: genworld.h:19
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:276
void ShowCreateScenario()
Show the window to create a scenario.
Runs the game script at most 2500 times, or when ever the script sleeps.
Definition: genworld.h:80
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition: genworld.h:48
CompanyID lc
The local_company before generating.
Definition: genworld.h:60
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:259
Make rough and rocky areas.
Definition: genworld.h:73
Types related to companies.
The original landscape generator.
Definition: genworld.h:22
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition: genworld.h:49
void WaitTillGeneratedWorld()
This will wait for the thread to finish up his work.
Definition: genworld.cpp:243
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done...
Definition: genworld.cpp:224
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Initialize the game.
Definition: genworld.h:78
Generate a random map for SE.
Definition: genworld.h:32
Really prepare to start the game.
Definition: genworld.h:81
Smoothness preset &#39;very smooth&#39;.
Definition: genworld.h:39