OpenTTD Source
20241108-master-g80f628063a
|
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 "string_func.h"
#include "thread.h"
#include "tgp.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
class | AbortGenerateWorldSignal |
struct | ExternalTownData |
Town data imported from JSON files and used to place towns. More... | |
Functions | |
void | GenerateClearTile () |
void | GenerateIndustries () |
This function will create random industries during game creation. More... | |
void | GenerateObjects () |
void | GenerateTrees () |
Place new trees. More... | |
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. More... | |
void | GenerateWorldSetAbortCallback (GWAbortProc *proc) |
Set here the function, if any, that you want to be called when landscape generation is aborted. More... | |
void | AbortGeneratingWorld () |
Initializes the abortion process. | |
bool | IsGeneratingWorldAborted () |
Is the generation being aborted? More... | |
void | HandleGeneratingWorldAbortion () |
Really handle the abortion, i.e. More... | |
void | GenerateWorld (GenWorldMode mode, uint size_x, uint size_y, bool reset_settings) |
Generate a world. More... | |
static bool | TryFoundTownNearby (TileIndex tile, void *user_data) |
Helper for CircularTileSearch to found a town on or near a given tile. More... | |
void | LoadTownData () |
Load town data from _file_to_saveload, place towns at the appropriate locations, and expand them to their target populations. | |
Variables | |
GenWorldInfo | _gw |
Please only use this variable in genworld.h and genworld.cpp and nowhere else. More... | |
bool | _generating_world |
Whether we are generating the map or not. | |
Functions to generate a map.
Definition in file genworld.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 2460 of file industry_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 354 of file tree_cmd.cpp.
References _settings_game, GameSettings::game_creation, GameCreationSettings::landscape, TP_NONE, TP_ORIGINAL, and GameCreationSettings::tree_placer.
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 286 of file genworld.cpp.
References _gw, _local_company, GenWorldInfo::abort, GenWorldInfo::abortp, COMPANY_SPECTATOR, HasModalProgress(), GenWorldInfo::lc, GenWorldInfo::mode, SetLocalCompany(), SetModalProgress(), GenWorldInfo::size_x, and GenWorldInfo::size_y.
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 244 of file genworld.cpp.
References _gw, and 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 234 of file genworld.cpp.
References _gw, and GenWorldInfo::proc.
void HandleGeneratingWorldAbortion | ( | ) |
Really handle the abortion, i.e.
clean up some of the mess
Definition at line 269 of file genworld.cpp.
References _switch_mode.
bool IsGeneratingWorldAborted | ( | ) |
Is the generation being aborted?
Definition at line 261 of file genworld.cpp.
References _gw, and GenWorldInfo::abort.
|
static |
Helper for CircularTileSearch to found a town on or near a given tile.
tile | The tile to try founding the town upon. |
user_data | The ExternalTownData to attempt to found. |
Definition at line 361 of file genworld.cpp.
GenWorldInfo _gw |
Please only use this variable in genworld.h and genworld.cpp and nowhere else.
For speed improvements we need it to be global, but in no way the meaning of it is to use it anywhere else besides in the genworld.h and genworld.cpp!
Definition at line 64 of file genworld.cpp.
Referenced by AbortGeneratingWorld(), CleanupGeneration(), GenerateWorld(), GenerateWorldSetAbortCallback(), GenerateWorldSetCallback(), and IsGeneratingWorldAborted().