Go to the documentation of this file.
41 void GenerateClearTile();
43 void GenerateObjects();
46 void StartupEconomy();
48 void StartupDisasters();
50 void InitializeGame(uint size_x, uint size_y,
bool reset_date,
bool reset_settings);
120 ConvertGroundTilesIntoWaterTiles();
129 if (_game_mode != GM_EDITOR) {
154 for (i = 0; i < 0x500; i++) {
160 if (_game_mode != GM_EDITOR) {
166 for (i = 0; i < 2500; i++) {
179 _cur_company.
Trash();
194 if (_debug_desync_level > 0) {
207 DEBUG(net, 0,
"Generating map failed, aborting");
290 uint estimated_height = 0;
299 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 HideVitalWindows()
Delete all always on-top windows to get an empty screen.
uint32 generation_seed
noise seed for world generation
void GenerateLandscape(byte mode)
@ 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.
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.
uint8 map_height_limit
the maximum allowed heightlevel
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.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
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.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
static const uint DEF_SNOWLINE_HEIGHT
Default snowline height.
void StartupEngines()
Start/initialise all our engines.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
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.
GameCreationSettings game_creation
settings used during the creation of a game (map)
static uint MapSizeX()
Get the size of the map along the X.
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.
Date _date
Current date in days (day counter)
@ SLO_SAVE
File is being saved.
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
#define DEBUG(name, level,...)
Output a line of debugging information.
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted.
static void MakeVoid(TileIndex t)
Make a nice void tile ;)
void GenerateTrees()
Place new trees.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ 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.
EconomySettings economy
settings to change the economy
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
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
static uint MapSizeY()
Get the size of the map along the Y.
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.
Properties of current genworld process.
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)
This function will generate a certain amount of towns, with a certain layout It can be called from th...
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void Restore()
Restore the variable.
void UnshowCriticalError()
Unshow the critical error.
byte land_generator
the landscape generator
void DeleteAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
@ 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.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
@ 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.
void StartupCompanies()
Start the next competitor now.
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 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...
static bool HasModalProgress()
Check if we are currently in a modal progress state.
void SetSeed(uint32 seed)
(Re)set the state of the random number generator.
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.
#define lastof(x)
Get the last element of an fixed size array.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
static void StartNew()
Start up a new GameScript.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
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.