|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
42 void GenerateClearTile();
44 void GenerateObjects();
47 void StartupEconomy();
49 void StartupDisasters();
51 void InitializeGame(uint size_x, uint size_y,
bool reset_date,
bool reset_settings);
98 ScriptObject::InitializeRandomizers();
106 bool landscape_generated =
false;
113 if (!landscape_generated) {
125 ConvertGroundTilesIntoWaterTiles();
133 if (_game_mode != GM_EDITOR) {
158 for (i = 0; i < 0x500; i++) {
164 if (_game_mode != GM_EDITOR) {
170 for (i = 0; i < 2500; i++) {
183 _cur_company.
Trash();
200 if (_debug_desync_level > 0) {
212 Debug(net, 0,
"Generating map failed; closing server");
295 uint estimated_height = 0;
304 estimated_height = 0;
uint size_y
Y-size of the map.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
void ShowFirstError()
Show the first error of the queue.
@ GWP_GAME_INIT
Initialize the game.
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
@ GWP_RUNTILELOOP
Runs the tile loop 1280 times to make snow etc.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
static void _GenerateWorld()
The internal, real, generate function.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
bool abort
Whether to abort the thread ASAP.
CompanyID lc
The local_company before generating.
GenWorldInfo _gw
Please only use this variable in genworld.h and genworld.cpp and nowhere else.
void AbortGeneratingWorld()
Initializes the abortion process.
TownLayout town_layout
select town layout,
Class to backup a specific variable and restore it later.
GWAbortProc * abortp
Proc that is called when aborting (can be nullptr)
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
@ SM_EDITOR
Switch to scenario editor.
GenWorldMode mode
What mode are we making a world in.
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done.
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
@ DFT_GAME_FILE
Save game or scenario file.
Randomizer _random
Random used in the game state calculations.
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
void GWAbortProc()
Called when genworld is aborted.
uint GetEstimationTGPMapHeight()
Get an overestimation of the highest peak TGP wants to generate.
static const uint DEF_SNOWLINE_HEIGHT
Default snowline height.
void StartupEngines()
Start/initialise all our engines.
byte heightmap_height
highest mountain for heightmap (towards what it scales)
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
void ShowNewGRFError()
Show the first NewGRF error we can find.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
GameCreationSettings game_creation
settings used during the creation of a game (map)
bool GenerateLandscape(byte mode)
GWDoneProc * proc
Proc that is called when done (can be nullptr)
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
void ShowVitalWindows()
Show the vital in-game windows.
@ GWM_HEIGHTMAP
Generate a newgame from a heightmap.
@ SLO_SAVE
File is being saved.
void SetSeed(uint32_t seed)
(Re)set the state of the random number generator.
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
uint8_t map_height_limit
the maximum allowed heightlevel
void MakeVoid(Tile t)
Make a nice void tile ;)
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted.
void GenerateTrees()
Place new trees.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool HasModalProgress()
Check if we are currently in a modal progress state.
@ PSM_ENTER_GAMELOOP
Enter the gameloop, changes will be permanent.
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM
When map height limit is auto, make this the lowest possible map height limit.
static void StartNew(bool randomise=true)
Start up a new GameScript.
EconomySettings economy
settings to change the economy
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
byte snow_line_height
the configured snow line height (deduced from "snow_coverage")
@ GWP_GAME_START
Really prepare to start the game.
@ GWP_OBJECT
Generate objects (radio tower, light houses)
bool freeform_edges
allow terraforming the tiles at the map edges
@ GWP_MAP_INIT
Initialize/allocate the map, start economy.
byte se_flat_world_height
land height a flat world gets in SE
bool _network_dedicated
are we a dedicated server?
static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM
When map height limit is auto, the map height limit will be the higest peak plus this value.
void FlatEmptyWorld(byte tile_height)
Make an empty world where all tiles are of height 'tile_height'.
bool IsValid() const
Checks whether the variable was already restored.
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
Properties of current genworld process.
static debug_inline uint SizeX()
Get the size of the map along the X.
bool _generating_world
Whether we are generating the map or not.
SwitchMode _switch_mode
The next mainloop command.
CompanyID _current_company
Company currently doing an action.
static void GameLoop()
Called every game-tick to let Game do something.
void Trash()
Trash the backup.
bool GenerateTowns(TownLayout layout)
Generate a number of towns with a given layout.
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
uint32_t generation_seed
noise seed for world generation
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
void Restore()
Restore the variable.
void UnshowCriticalError()
Unshow the critical error.
byte land_generator
the landscape generator
@ COMPANY_SPECTATOR
The client is spectating.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
@ OWNER_NONE
The tile has no ownership.
@ GWM_EMPTY
Generate an empty map (sea-level)
@ LG_TERRAGENESIS
TerraGenesis Perlin landscape generator.
@ WC_MAIN_WINDOW
Main window; Window numbers:
void GfxLoadSprites()
Initialise and load all the sprites.
@ SM_MENU
Switch to game intro menu.
void GenerateIndustries()
This function will create random industries during game creation.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void StartupCompanies()
Start of a new game.
uint size_x
X-size of the map.
bool IsGeneratingWorldAborted()
Is the generation being aborted?
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
Generate a world.
@ PSM_LEAVE_GAMELOOP
Leave the gameloop, changes will be temporary.
static void SwitchMode(PersistentStorageMode mode, bool ignore_prev_mode=false)
Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes sh...
static void CleanupGeneration()
Generation is done; show windows again and delete the progress window.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
ConstructionSettings construction
construction of things in-game
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
GenWorldMode
Modes for GenerateWorld.
void GWDoneProc()
Procedure called when the genworld process finishes.
void SetModalProgress(bool state)
Set the modal progress state.
static class GameInstance * GetInstance()
Get the current active instance.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
static uint SizeY()
Get the size of the map along the Y.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
@ GWP_RUNSCRIPT
Runs the game script at most 2500 times, or when ever the script sleeps.
void RunTileLoop()
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every 256 ticks.
static Date date
Current date in days (day counter).