OpenTTD Source 20261112-master-gbcbec5e63f
genworld.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef GENWORLD_H
11#define GENWORLD_H
12
13#include "landscape_type.h"
14
16enum LandscapeGenerator : uint8_t {
17 /* Order of these enums has to be the same as in lang/english.txt
18 * Otherwise you will get inconsistent behaviour. */
21};
22
23static const uint32_t GENERATE_NEW_SEED = UINT32_MAX;
24
26enum GenWorldMode : uint8_t {
31};
32
43
45static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1;
46static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90;
47
48static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL = 15;
49
50static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30;
51static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM = 15;
52
53typedef void GWDoneProc();
54typedef void GWAbortProc();
55
74
75/* genworld.cpp */
78void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
82void LoadTownData();
83
84/* genworld_gui.cpp */
90void StartNewGameWithoutGUI(uint32_t seed);
93
94extern bool _generating_world;
95
96#endif /* GENWORLD_H */
#define DECLARE_ENUM_AS_SEQUENTIAL(enum_type)
For some enums it is useful to add/sub more than 1.
bool _generating_world
Whether we are generating the map or not.
Definition genworld.cpp:70
void GWAbortProc()
Called when genworld is aborted.
Definition genworld.h:54
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM
When map height limit is auto, make this the lowest possible map height limit.
Definition genworld.h:50
LandscapeGenerator
Constants related to world generation.
Definition genworld.h:16
@ LG_ORIGINAL
The original landscape generator.
Definition genworld.h:19
@ LG_TERRAGENESIS
TerraGenesis Perlin landscape generator.
Definition genworld.h:20
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done.
Definition genworld.cpp:239
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition genworld.h:46
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted.
Definition genworld.cpp:249
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings=true)
Generate a world.
Definition genworld.cpp:291
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition genworld.cpp:274
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition genworld.h:44
GenWorldProgress
Current stage of world generation process.
Definition genworld.h:57
@ WaterIndustries
Generate industries.
Definition genworld.h:64
@ Towns
Generate towns.
Definition genworld.h:62
@ RoughAndRocks
Make rough and rocky areas.
Definition genworld.h:61
@ GameStart
Really prepare to start the game.
Definition genworld.h:70
@ Rivers
Create the rivers.
Definition genworld.h:60
@ Landscape
Create the landscape.
Definition genworld.h:59
@ End
End marker.
Definition genworld.h:71
@ GameScript
Runs the game script at most 2500 times, or when ever the script sleeps.
Definition genworld.h:69
@ Init
Initialize/allocate the map, start economy.
Definition genworld.h:58
@ Trees
Generate trees.
Definition genworld.h:66
@ Objects
Generate objects (radio tower, light houses).
Definition genworld.h:65
@ LandIndustries
Generate industries.
Definition genworld.h:63
@ GameInit
Initialize the game.
Definition genworld.h:67
void ShowCreateScenario()
Show the window to create a scenario.
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition genworld.h:45
void GWDoneProc()
Procedure called when the genworld process finishes.
Definition genworld.h:53
static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM
When map height limit is auto, the map height limit will be the highest peak plus this value.
Definition genworld.h:51
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Definition genworld.h:23
TgenSmoothness
Smoothness presets.
Definition genworld.h:34
@ TGEN_SMOOTHNESS_BEGIN
First smoothness value.
Definition genworld.h:35
@ TGEN_SMOOTHNESS_ROUGH
Smoothness preset 'rough'.
Definition genworld.h:38
@ TGEN_SMOOTHNESS_VERY_SMOOTH
Smoothness preset 'very smooth'.
Definition genworld.h:36
@ TGEN_SMOOTHNESS_VERY_ROUGH
Smoothness preset 'very rough'.
Definition genworld.h:39
@ TGEN_SMOOTHNESS_SMOOTH
Smoothness preset 'smooth'.
Definition genworld.h:37
@ TGEN_SMOOTHNESS_END
Used to iterate.
Definition genworld.h:41
void AbortGeneratingWorld()
Initializes the abortion process.
Definition genworld.cpp:257
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition genworld.cpp:266
void SetNewLandscapeType(LandscapeType landscape)
Changes landscape type and sets genworld window dirty.
void StartScenarioEditor()
Start with a scenario editor.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
void LoadTownData()
Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to t...
Definition genworld.cpp:455
GenWorldMode
Modes for GenerateWorld.
Definition genworld.h:26
@ GWM_HEIGHTMAP
Generate a newgame from a heightmap.
Definition genworld.h:30
@ GWM_EMPTY
Generate an empty map (sea-level).
Definition genworld.h:28
@ GWM_RANDOM
Generate a random map for SE.
Definition genworld.h:29
@ GWM_NEWGAME
Generate a map for a new game.
Definition genworld.h:27
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL
Original map height limit.
Definition genworld.h:48
void RunTileLoop()
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQU...
Types related to the landscape.
LandscapeType
Landscape types.