|
OpenTTD Source 20251117-master-g7398d2e290
|
Functions to generate a map. More...
#include "stdafx.h"#include "landscape.h"#include "company_func.h"#include "town_cmd.h"#include "signs_cmd.h"#include "3rdparty/nlohmann/json.hpp"#include "strings_func.h"#include "genworld.h"#include "gfxinit.h"#include "window_func.h"#include "network/network.h"#include "heightmap.h"#include "viewport_func.h"#include "timer/timer_game_calendar.h"#include "timer/timer_game_tick.h"#include "engine_func.h"#include "water.h"#include "video/video_driver.hpp"#include "tilehighlight_func.h"#include "saveload/saveload.h"#include "void_map.h"#include "town.h"#include "newgrf.h"#include "newgrf_house.h"#include "core/random_func.hpp"#include "core/backup_type.hpp"#include "progress.h"#include "error.h"#include "game/game.hpp"#include "game/game_instance.hpp"#include "newgrf_railtype.h"#include "newgrf_roadtype.h"#include "string_func.h"#include "thread.h"#include "tgp.h"#include "table/strings.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | GenWorldInfo |
| Properties of current genworld process. More... | |
| class | AbortGenerateWorldSignal |
Functions | |
| void | GenerateClearTile () |
| void | GenerateIndustries () |
| This function will create random industries during game creation. | |
| void | GenerateObjects () |
| void | GenerateTrees () |
| Place new trees. | |
| void | StartupEconomy () |
| void | StartupCompanies () |
| Start of a new game. | |
| void | StartupDisasters () |
| void | InitializeGame (uint size_x, uint size_y, bool reset_date, bool reset_settings) |
| static void | CleanupGeneration () |
| Generation is done; show windows again and delete the progress window. | |
| static void | _GenerateWorld () |
| The internal, real, generate function. | |
| 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 | AbortGeneratingWorld () |
| Initializes the abortion process. | |
| bool | IsGeneratingWorldAborted () |
| Is the generation being aborted? | |
| void | HandleGeneratingWorldAbortion () |
| Really handle the abortion, i.e. | |
| void | GenerateWorld (GenWorldMode mode, uint size_x, uint size_y, bool reset_settings) |
| Generate a world. | |
| void | LoadTownData () |
| Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to their target populations. | |
Variables | |
| bool | _generating_world |
| Whether we are generating the map or not. | |
Functions to generate a map.
Definition in file genworld.cpp.
|
static |
The internal, real, generate function.
Definition at line 98 of file genworld.cpp.
References _current_company, _generating_world, _local_company, _network_dedicated, _random, _settings_game, _switch_mode, AUTOSAVE_DIR, CheckTownRoadTypes(), CleanupGeneration(), GameSettings::construction, TimerGameTick::counter, TimerGameEconomy::date, Debug, DEF_SNOWLINE_HEIGHT, DFT_GAME_FILE, GameSettings::economy, FlatEmptyWorld(), ConstructionSettings::freeform_edges, GameSettings::game_creation, Game::GameLoop(), GenerateIndustries(), GenerateLandscape(), GenerateTowns(), GenerateTrees(), GameCreationSettings::generation_seed, Game::GetInstance(), GWM_EMPTY, GWP_GAME_INIT, GWP_GAME_START, GWP_MAP_INIT, GWP_OBJECT, GWP_RUNSCRIPT, GWP_RUNTILELOOP, HandleGeneratingWorldAbortion(), HT_NONE, IncreaseGeneratingWorldProgress(), Backup< T >::IsValid(), GenWorldInfo::lc, MakeVoid(), GenWorldInfo::mode, OWNER_NONE, GenWorldInfo::proc, PSM_ENTER_GAMELOOP, PSM_LEAVE_GAMELOOP, ResetObjectToPlace(), Backup< T >::Restore(), RunTileLoop(), SaveOrLoad(), GameCreationSettings::se_flat_world_height, SetGeneratingWorldProgress(), SetObjectToPlace(), Randomizer::SetSeed(), ShowNewGRFError(), ShowVitalWindows(), Map::SizeX(), Map::SizeY(), SLO_SAVE, GameCreationSettings::snow_line_height, Game::StartNew(), StartupCompanies(), StartupEngines(), BasePersistentStorageArray::SwitchMode(), TileXY(), EconomySettings::town_layout, Backup< T >::Trash(), and WC_MAIN_WINDOW.
Referenced by GenerateWorld().
| void AbortGeneratingWorld | ( | ) |
Initializes the abortion process.
Definition at line 261 of file genworld.cpp.
References GenWorldInfo::abort.
|
static |
Generation is done; show windows again and delete the progress window.
Definition at line 81 of file genworld.cpp.
References _generating_world, GenWorldInfo::abortp, CloseWindowByClass(), MarkWholeScreenDirty(), GenWorldInfo::proc, SetModalProgress(), SetMouseCursorBusy(), ShowFirstError(), and WC_MODAL_PROGRESS.
Referenced by _GenerateWorld().
| void GenerateClearTile | ( | ) |
Definition at line 316 of file clear_cmd.cpp.
| void GenerateIndustries | ( | ) |
This function will create random industries during game creation.
It will scale the amount of industries by mapsize and difficulty level.
Definition at line 2481 of file industry_cmd.cpp.
References _industry_builder, _settings_game, GameSettings::difficulty, GetNumberOfIndustries(), GetScaledProbabilities(), GWP_LAND_INDUSTRY, GWP_WATER_INDUSTRY, ID_CUSTOM, ID_FUND_ONLY, DifficultySettings::industry_density, NUM_INDUSTRYTYPES, PlaceInitialIndustry(), RandomRange(), IndustryBuildData::Reset(), Map::ScaleByLandProportion(), and SetGeneratingWorldProgress().
Referenced by _GenerateWorld().
| void GenerateObjects | ( | ) |
Definition at line 805 of file object_cmd.cpp.
| void GenerateTrees | ( | ) |
Place new trees.
This function takes care of the selected tree placer algorithm and place randomly the trees for a new game.
Definition at line 476 of file tree_cmd.cpp.
References _settings_game, DEFAULT_RAINFOREST_TREE_STEPS, DEFAULT_TREE_STEPS, GameSettings::game_creation, GB(), GWP_TREE, GameCreationSettings::landscape, PlaceTreeGroups(), PlaceTreesRandomly(), Random, Map::ScaleBySize(), SetGeneratingWorldProgress(), TP_IMPROVED, TP_NONE, TP_ORIGINAL, and GameCreationSettings::tree_placer.
Referenced by _GenerateWorld().
| 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 InitializeGame | ( | uint | size_x, |
| uint | size_y, | ||
| bool | reset_date, | ||
| bool | reset_settings | ||
| ) |
| 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 StartupCompanies | ( | ) |
Start of a new game.
Definition at line 677 of file company_cmd.cpp.
References _new_competitor_timeout, and TimeoutTimer< TTimerType >::Abort().
Referenced by _GenerateWorld().
| void StartupDisasters | ( | ) |
Definition at line 952 of file disaster_vehicle.cpp.
| void StartupEconomy | ( | ) |
Definition at line 909 of file economy.cpp.
| bool _generating_world |
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().