OpenTTD Source: src/genworld.h Source File

OpenTTD Source 15.3

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
10#ifndef GENWORLD_H
11#define GENWORLD_H
12
13#include "company_type.h"
14#include "landscape_type.h"
15#include <thread>
16
18 enum LandscapeGenerator : uint8_t {
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,
22 LG_TERRAGENESIS = 1,
23};
24
25 static const uint32_t GENERATE_NEW_SEED = UINT32_MAX;
26
28 enum GenWorldMode : uint8_t {
29 GWM_NEWGAME = 0,
30 GWM_EMPTY = 1,
31 GWM_RANDOM = 2,
32 GWM_HEIGHTMAP = 3,
33};
34
36 enum TgenSmoothness : uint8_t {
37 TGEN_SMOOTHNESS_BEGIN,
38 TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN,
39 TGEN_SMOOTHNESS_SMOOTH,
40 TGEN_SMOOTHNESS_ROUGH,
41 TGEN_SMOOTHNESS_VERY_ROUGH,
42
43 TGEN_SMOOTHNESS_END,
44};
45
46 static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY = 5;
47
48 static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4;
49 static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1;
50 static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90;
51
52 static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL = 15;
53
54 static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30;
55 static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM = 15;
56
57 typedef void GWDoneProc();
58 typedef void GWAbortProc();
59
61 enum GenWorldProgress : uint8_t {
62 GWP_MAP_INIT,
63 GWP_LANDSCAPE,
64 GWP_RIVER,
65 GWP_ROUGH_ROCKY,
66 GWP_TOWN,
67 GWP_LAND_INDUSTRY,
68 GWP_WATER_INDUSTRY,
69 GWP_OBJECT,
70 GWP_TREE,
71 GWP_GAME_INIT,
72 GWP_RUNTILELOOP,
73 GWP_RUNSCRIPT,
74 GWP_GAME_START,
75 GWP_CLASS_COUNT
76};
77
78/* genworld.cpp */
79void GenerateWorldSetCallback(GWDoneProc *proc);
80void GenerateWorldSetAbortCallback(GWAbortProc *proc);
81void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
82void AbortGeneratingWorld();
83bool IsGeneratingWorldAborted();
84void HandleGeneratingWorldAbortion();
85void LoadTownData();
86
87/* genworld_gui.cpp */
88void SetNewLandscapeType(LandscapeType landscape);
89void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
90void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
91void PrepareGenerateWorldProgress();
92void ShowGenerateWorldProgress();
93void StartNewGameWithoutGUI(uint32_t seed);
94void ShowCreateScenario();
95void StartScenarioEditor();
96
97extern bool _generating_world;
98
99#endif /* GENWORLD_H */
company_type.h
Types related to companies.
GWAbortProc
void GWAbortProc()
Called when genworld is aborted.
Definition genworld.h:58
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition genworld_gui.cpp:1539
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition genworld.cpp:74
MAP_HEIGHT_LIMIT_AUTO_MINIMUM
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:54
LandscapeGenerator
LandscapeGenerator
Constants related to world generation.
Definition genworld.h:18
LG_ORIGINAL
@ LG_ORIGINAL
The original landscape generator.
Definition genworld.h:21
LG_TERRAGENESIS
@ LG_TERRAGENESIS
TerraGenesis Perlin landscape generator.
Definition genworld.h:22
GenerateWorldSetCallback
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done.
Definition genworld.cpp:243
CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition genworld.h:50
GenerateWorldSetAbortCallback
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted.
Definition genworld.cpp:253
ShowGenerateWorldProgress
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Definition genworld_gui.cpp:1457
GenerateWorld
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings=true)
Generate a world.
Definition genworld.cpp:295
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition genworld.cpp:278
CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition genworld.h:48
GenWorldProgress
GenWorldProgress
Current stage of world generation process.
Definition genworld.h:61
GWP_TREE
@ GWP_TREE
Generate trees.
Definition genworld.h:70
GWP_LAND_INDUSTRY
@ GWP_LAND_INDUSTRY
Generate industries.
Definition genworld.h:67
GWP_ROUGH_ROCKY
@ GWP_ROUGH_ROCKY
Make rough and rocky areas.
Definition genworld.h:65
GWP_OBJECT
@ GWP_OBJECT
Generate objects (radio tower, light houses)
Definition genworld.h:69
GWP_MAP_INIT
@ GWP_MAP_INIT
Initialize/allocate the map, start economy.
Definition genworld.h:62
GWP_TOWN
@ GWP_TOWN
Generate towns.
Definition genworld.h:66
GWP_WATER_INDUSTRY
@ GWP_WATER_INDUSTRY
Generate industries.
Definition genworld.h:68
GWP_RUNSCRIPT
@ GWP_RUNSCRIPT
Runs the game script at most 2500 times, or when ever the script sleeps.
Definition genworld.h:73
GWP_GAME_START
@ GWP_GAME_START
Really prepare to start the game.
Definition genworld.h:74
GWP_LANDSCAPE
@ GWP_LANDSCAPE
Create the landscape.
Definition genworld.h:63
GWP_GAME_INIT
@ GWP_GAME_INIT
Initialize the game.
Definition genworld.h:71
GWP_RIVER
@ GWP_RIVER
Create the rivers.
Definition genworld.h:64
GWP_RUNTILELOOP
@ GWP_RUNTILELOOP
Runs the tile loop 1280 times to make snow etc.
Definition genworld.h:72
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition genworld_gui.cpp:1319
CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition genworld.h:49
GWDoneProc
void GWDoneProc()
Procedure called when the genworld process finishes.
Definition genworld.h:57
MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM
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:55
GENERATE_NEW_SEED
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Definition genworld.h:25
TgenSmoothness
TgenSmoothness
Smoothness presets.
Definition genworld.h:36
TGEN_SMOOTHNESS_BEGIN
@ TGEN_SMOOTHNESS_BEGIN
First smoothness value.
Definition genworld.h:37
TGEN_SMOOTHNESS_ROUGH
@ TGEN_SMOOTHNESS_ROUGH
Smoothness preset 'rough'.
Definition genworld.h:40
TGEN_SMOOTHNESS_VERY_SMOOTH
@ TGEN_SMOOTHNESS_VERY_SMOOTH
Smoothness preset 'very smooth'.
Definition genworld.h:38
TGEN_SMOOTHNESS_VERY_ROUGH
@ TGEN_SMOOTHNESS_VERY_ROUGH
Smoothness preset 'very rough'.
Definition genworld.h:41
TGEN_SMOOTHNESS_SMOOTH
@ TGEN_SMOOTHNESS_SMOOTH
Smoothness preset 'smooth'.
Definition genworld.h:39
TGEN_SMOOTHNESS_END
@ TGEN_SMOOTHNESS_END
Used to iterate.
Definition genworld.h:43
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition genworld.cpp:261
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition genworld.cpp:270
SetNewLandscapeType
void SetNewLandscapeType(LandscapeType landscape)
Changes landscape type and sets genworld window dirty.
Definition genworld_gui.cpp:69
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition genworld_gui.cpp:1058
CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
Value for custom terrain type in difficulty settings.
Definition genworld.h:46
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition genworld_gui.cpp:1525
PrepareGenerateWorldProgress
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
Definition genworld_gui.cpp:1446
LoadTownData
void LoadTownData()
Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to t...
Definition genworld.cpp:359
GenWorldMode
GenWorldMode
Modes for GenerateWorld.
Definition genworld.h:28
GWM_HEIGHTMAP
@ GWM_HEIGHTMAP
Generate a newgame from a heightmap.
Definition genworld.h:32
GWM_EMPTY
@ GWM_EMPTY
Generate an empty map (sea-level)
Definition genworld.h:30
GWM_RANDOM
@ GWM_RANDOM
Generate a random map for SE.
Definition genworld.h:31
GWM_NEWGAME
@ GWM_NEWGAME
Generate a map for a new game.
Definition genworld.h:29
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
Definition genworld_gui.cpp:1067
MAP_HEIGHT_LIMIT_ORIGINAL
static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL
Original map height limit.
Definition genworld.h:52
landscape_type.h
Types related to the landscape.
LandscapeType
LandscapeType
Landscape types.
Definition landscape_type.h:16