|
OpenTTD Source 20251116-master-g21329071df
|
Functions related to world/map generation. More...
Go to the source code of this file.
Typedefs | |
| typedef void | GWDoneProc() |
| Procedure called when the genworld process finishes. | |
| typedef void | GWAbortProc() |
| Called when genworld is aborted. | |
Enumerations | |
| enum | LandscapeGenerator : uint8_t { LG_ORIGINAL = 0 , LG_TERRAGENESIS = 1 } |
| Constants related to world generation. More... | |
| enum | GenWorldMode : uint8_t { GWM_NEWGAME = 0 , GWM_EMPTY = 1 , GWM_RANDOM = 2 , GWM_HEIGHTMAP = 3 } |
| Modes for GenerateWorld. More... | |
| enum | TgenSmoothness : uint8_t { TGEN_SMOOTHNESS_BEGIN , TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN , TGEN_SMOOTHNESS_SMOOTH , TGEN_SMOOTHNESS_ROUGH , TGEN_SMOOTHNESS_VERY_ROUGH , TGEN_SMOOTHNESS_END } |
| Smoothness presets. More... | |
| enum | GenWorldProgress : uint8_t { GWP_MAP_INIT , GWP_LANDSCAPE , GWP_RIVER , GWP_ROUGH_ROCKY , GWP_TOWN , GWP_LAND_INDUSTRY , GWP_WATER_INDUSTRY , GWP_OBJECT , GWP_TREE , GWP_GAME_INIT , GWP_RUNTILELOOP , GWP_RUNSCRIPT , GWP_GAME_START , GWP_CLASS_COUNT } |
| Current stage of world generation process. More... | |
Functions | |
| void | GenerateWorldSetCallback (GWDoneProc *proc) |
| Set here the function, if any, that you want to be called when landscape generation is done. | |
| void | GenerateWorldSetAbortCallback (GWAbortProc *proc) |
| Set here the function, if any, that you want to be called when landscape generation is aborted. | |
| void | GenerateWorld (GenWorldMode mode, uint size_x, uint size_y, bool reset_settings=true) |
| Generate a world. | |
| void | AbortGeneratingWorld () |
| Initializes the abortion process. | |
| bool | IsGeneratingWorldAborted () |
| Is the generation being aborted? | |
| void | HandleGeneratingWorldAbortion () |
| Really handle the abortion, i.e. | |
| void | LoadTownData () |
| Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to their target populations. | |
| void | SetNewLandscapeType (LandscapeType landscape) |
| Changes landscape type and sets genworld window dirty. | |
| void | SetGeneratingWorldProgress (GenWorldProgress cls, uint total) |
| Set the total of a stage of the world generation. | |
| void | IncreaseGeneratingWorldProgress (GenWorldProgress cls) |
| Increases the current stage of the world generation with one. | |
| void | PrepareGenerateWorldProgress () |
| Initializes the progress counters to the starting point. | |
| void | ShowGenerateWorldProgress () |
| Show the window where a user can follow the process of the map generation. | |
| void | StartNewGameWithoutGUI (uint32_t seed) |
| Start a normal game without the GUI. | |
| void | ShowCreateScenario () |
| Show the window to create a scenario. | |
| void | StartScenarioEditor () |
| Start with a scenario editor. | |
Variables | |
| static const uint32_t | GENERATE_NEW_SEED = UINT32_MAX |
| Create a new random seed. | |
| static const uint | CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY = 5 |
| Value for custom terrain type in difficulty settings. | |
| static const uint | CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4 |
| Value for custom sea level in difficulty settings. | |
| static const uint | CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1 |
| Minimum percentage a user can specify for custom sea level. | |
| static const uint | CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90 |
| Maximum percentage a user can specify for custom sea level. | |
| static constexpr uint | MAP_HEIGHT_LIMIT_ORIGINAL = 15 |
| Original map height limit. | |
| static const uint | MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30 |
| When map height limit is auto, make this the lowest possible map height limit. | |
| static const uint | MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM = 15 |
| When map height limit is auto, the map height limit will be the highest peak plus this value. | |
| bool | _generating_world |
| Whether we are generating the map or not. | |
Functions related to world/map generation.
Definition in file genworld.h.
| typedef void GWAbortProc() |
Called when genworld is aborted.
Definition at line 58 of file genworld.h.
| typedef void GWDoneProc() |
Procedure called when the genworld process finishes.
Definition at line 57 of file genworld.h.
| enum GenWorldMode : uint8_t |
Modes for GenerateWorld.
| Enumerator | |
|---|---|
| GWM_NEWGAME | Generate a map for a new game. |
| GWM_EMPTY | Generate an empty map (sea-level) |
| GWM_RANDOM | Generate a random map for SE. |
| GWM_HEIGHTMAP | Generate a newgame from a heightmap. |
Definition at line 28 of file genworld.h.
| enum GenWorldProgress : uint8_t |
Current stage of world generation process.
Definition at line 61 of file genworld.h.
| enum LandscapeGenerator : uint8_t |
Constants related to world generation.
| Enumerator | |
|---|---|
| LG_ORIGINAL | The original landscape generator. |
| LG_TERRAGENESIS | TerraGenesis Perlin landscape generator. |
Definition at line 18 of file genworld.h.
| enum TgenSmoothness : uint8_t |
Smoothness presets.
Definition at line 36 of file genworld.h.
| void AbortGeneratingWorld | ( | ) |
Initializes the abortion process.
Definition at line 261 of file genworld.cpp.
References GenWorldInfo::abort.
| void GenerateWorld | ( | GenWorldMode | mode, |
| uint | size_x, | ||
| uint | size_y, | ||
| bool | reset_settings | ||
| ) |
Generate a world.
| mode | The mode of world generation (see GenWorldMode). |
| size_x | The X-size of the map. |
| size_y | The Y-size of the map. |
| reset_settings | Whether to reset the game configuration (used for restart) |
Definition at line 295 of file genworld.cpp.
References _GenerateWorld(), _local_company, _settings_game, GenWorldInfo::abort, GenWorldInfo::abortp, CloseAllNonVitalWindows(), COMPANY_SPECTATOR, GameSettings::construction, GameSettings::game_creation, GENERATE_NEW_SEED, GameCreationSettings::generation_seed, GetEstimationTGPMapHeight(), GfxLoadSprites(), GWM_EMPTY, GWM_HEIGHTMAP, HasModalProgress(), GameCreationSettings::heightmap_height, HideVitalWindows(), HT_NONE, InitializeBuildingCounts(), GameCreationSettings::land_generator, GenWorldInfo::lc, LG_TERRAGENESIS, LoadStringWidthTable(), ConstructionSettings::map_height_limit, MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM, MAP_HEIGHT_LIMIT_AUTO_MINIMUM, MAX_MAP_HEIGHT_LIMIT, GenWorldInfo::mode, PrepareGenerateWorldProgress(), ResetWindowSystem(), ScrollMainWindowToTile(), GameCreationSettings::se_flat_world_height, SetCurrentRailTypeLabelList(), SetCurrentRoadTypeLabelList(), SetLocalCompany(), SetModalProgress(), SetObjectToPlace(), SetupColoursAndInitialWindow(), ShowGenerateWorldProgress(), GenWorldInfo::size_x, GenWorldInfo::size_y, Map::SizeX(), Map::SizeY(), TileXY(), UnshowCriticalError(), and WC_MAIN_WINDOW.
Referenced by LoadIntroGame(), and openttd_main().
| void GenerateWorldSetAbortCallback | ( | GWAbortProc * | proc | ) |
Set here the function, if any, that you want to be called when landscape generation is aborted.
| proc | callback procedure |
Definition at line 253 of file genworld.cpp.
References GenWorldInfo::abortp.
Referenced by GenerateTerrainPerlin().
| void GenerateWorldSetCallback | ( | GWDoneProc * | proc | ) |
Set here the function, if any, that you want to be called when landscape generation is done.
| proc | callback procedure |
Definition at line 243 of file genworld.cpp.
References GenWorldInfo::proc.
| void HandleGeneratingWorldAbortion | ( | ) |
Really handle the abortion, i.e.
clean up some of the mess
Definition at line 278 of file genworld.cpp.
References _switch_mode, GenWorldInfo::abortp, SM_EDITOR, and SM_MENU.
Referenced by _GenerateWorld().
| void IncreaseGeneratingWorldProgress | ( | GenWorldProgress | cls | ) |
Increases the current stage of the world generation with one.
| cls | the current class we are in. |
Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always. Also, progress works if total is zero, total works if progress is zero.
Definition at line 1534 of file genworld_gui.cpp.
Referenced by _GenerateWorld(), CreateRivers(), GenerateLandscape(), GenerateTerrainPerlin(), GenerateTowns(), PlaceInitialIndustry(), PlaceTreeGroups(), and PlaceTreesRandomly().
| bool IsGeneratingWorldAborted | ( | ) |
Is the generation being aborted?
Definition at line 270 of file genworld.cpp.
References GenWorldInfo::abort.
| void LoadTownData | ( | ) |
Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to their target populations.
Definition at line 359 of file genworld.cpp.
References _file_to_saveload, _settings_game, Town::cache, GameSettings::economy, Execute, FioFOpenFile(), GameSettings::game_creation, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Get(), GetEncodedString(), HEIGHTMAP_DIR, GameCreationSettings::heightmap_rotation, HM_CLOCKWISE, HM_COUNTER_CLOCKWISE, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Map::MaxX(), Map::MaxY(), FileToSaveLoad::name, TownCache::num_houses, TownCache::population, ShowErrorMessage(), TileXY(), EconomySettings::town_layout, TSZ_SMALL, WL_ERROR, and WL_WARNING.
Referenced by SaveLoadWindow::OnClick().
| void PrepareGenerateWorldProgress | ( | ) |
Initializes the progress counters to the starting point.
Definition at line 1441 of file genworld_gui.cpp.
Referenced by GenerateWorld().
| void SetGeneratingWorldProgress | ( | GenWorldProgress | cls, |
| uint | total | ||
| ) |
Set the total of a stage of the world generation.
| cls | the current class we are in. |
| total | Set the total expected items for this class. |
Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always. Also, progress works if total is zero, total works if progress is zero.
Definition at line 1520 of file genworld_gui.cpp.
Referenced by _GenerateWorld(), CreateRivers(), GenerateIndustries(), GenerateLandscape(), GenerateTowns(), and GenerateTrees().
| void SetNewLandscapeType | ( | LandscapeType | landscape | ) |
Changes landscape type and sets genworld window dirty.
| landscape | new landscape type |
Definition at line 69 of file genworld_gui.cpp.
References _settings_newgame, GameSettings::game_creation, InvalidateWindowClassesData(), GameCreationSettings::landscape, WC_GENERATE_LANDSCAPE, and WC_SELECT_GAME.
Referenced by GenerateLandscapeWindow::OnClick(), and CreateScenarioWindow::OnClick().
| void ShowCreateScenario | ( | ) |
Show the window to create a scenario.
Definition at line 1314 of file genworld_gui.cpp.
References CloseWindowByClass(), GLWM_SCENARIO, and WC_GENERATE_LANDSCAPE.
Referenced by ScenarioEditorLandscapeGenerationWindow::OnClick().
| void ShowGenerateWorldProgress | ( | ) |
Show the window where a user can follow the process of the map generation.
Definition at line 1452 of file genworld_gui.cpp.
References BringWindowToFrontById(), and WC_MODAL_PROGRESS.
Referenced by GenerateWorld().
| void StartNewGameWithoutGUI | ( | uint32_t | seed | ) |
Start a normal game without the GUI.
| seed | The seed of the new game. |
Definition at line 1062 of file genworld_gui.cpp.
References _settings_newgame, GameSettings::game_creation, GameCreationSettings::generation_seed, and GLWM_GENERATE.
Referenced by VideoDriver_Dedicated::MainLoop(), SelectGameWindow::OnClick(), and NetworkStartServerWindow::OnClick().
| void StartScenarioEditor | ( | ) |
Start with a scenario editor.
Definition at line 1053 of file genworld_gui.cpp.
References GLWM_SCENARIO.
Referenced by SelectGameWindow::OnClick().
|
extern |
Whether we are generating the map or not.
Definition at line 74 of file genworld.cpp.
Referenced by _GenerateWorld(), BuildTownHouse(), CheckIfIndustryTileSlopes(), CleanupGeneration(), ClosestTownFromTile(), CmdBuildObject(), CmdDeleteTown(), CmdFoundTown(), CmdTerraformLand(), CreateNewIndustryHelper(), CreateRandomTown(), DoCreateNewIndustry(), GenerateDesertArea(), GetTerrainType(), HouseScopeResolver::GetVariable(), HasRoadTypeAvail(), InitializePatchFlags(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), CommandHelperBase::InternalPostBefore(), ObjectSpec::IsEverAvailable(), IsRoadAllowedHere(), BuildIndustryWindow::OnPlaceObject(), FoundTownWindow::OnQueryTextFinished(), ResetLandscapeConfirmationCallback(), TryBuildTownHouse(), and UpdateNearestTownForRoadTiles().
|
static |
Maximum percentage a user can specify for custom sea level.
Definition at line 50 of file genworld.h.
Referenced by GenerateLandscapeWindow::OnQueryTextFinished(), and GenerateLandscapeWindow::UpdateWidgetSize().
|
static |
Minimum percentage a user can specify for custom sea level.
Definition at line 49 of file genworld.h.
Referenced by GenerateLandscapeWindow::OnQueryTextFinished(), and ValidateSettings().
|
static |
Value for custom sea level in difficulty settings.
Definition at line 48 of file genworld.h.
Referenced by GenerateLandscape(), GenerateLandscapeWindow::GetWidgetString(), HeightMapNormalize(), GenerateLandscapeWindow::OnClick(), GenerateLandscapeWindow::OnDropdownSelect(), GenerateLandscapeWindow::OnInvalidateData(), and ValidateSettings().
|
static |
Value for custom terrain type in difficulty settings.
Definition at line 46 of file genworld.h.
Referenced by GenerateLandscapeWindow::GetWidgetString(), GenerateLandscapeWindow::OnDropdownSelect(), GenerateLandscapeWindow::OnInvalidateData(), and TGPGetMaxHeight().
|
static |
Create a new random seed.
Definition at line 25 of file genworld.h.
Referenced by GenerateWorld(), VideoDriver_Dedicated::MainLoop(), NetworkRestartMap(), SelectGameWindow::OnClick(), NetworkStartServerWindow::OnClick(), and openttd_main().
|
static |
When map height limit is auto, the map height limit will be the highest peak plus this value.
Definition at line 55 of file genworld.h.
Referenced by GenerateWorld().
|
static |
When map height limit is auto, make this the lowest possible map height limit.
Definition at line 54 of file genworld.h.
Referenced by GenerateWorld(), and GenerateLandscapeWindow::OnQueryTextFinished().
|
staticconstexpr |
Original map height limit.
Definition at line 52 of file genworld.h.
Referenced by PlaceTreesRandomly().