40 void GenerateClearTile();
42 void GenerateObjects();
45 void StartupEconomy();
47 void StartupDisasters();
49 void InitializeGame(uint size_x, uint size_y,
bool reset_date,
bool reset_settings);
130 ConvertGroundTilesIntoWaterTiles();
137 if (_game_mode != GM_EDITOR) {
144 DEBUG(net, 0,
"Generating map failed, aborting");
169 for (i = 0; i < 0x500; i++) {
175 if (_game_mode != GM_EDITOR) {
181 for (i = 0; i < 2500; i++) {
194 _cur_company.
Trash();
199 if (_gw.
proc !=
nullptr) _gw.
proc();
210 if (_debug_desync_level > 0) {
249 if (!_gw.
thread.joinable())
return;
317 InitializeGame(_gw.
size_x, _gw.
size_y,
true, reset_settings);
334 DEBUG(misc, 1,
"Cannot create genworld thread, reverting to single-threaded mode");
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows. ...
void GenerateIndustries()
This function will create random industries during game creation.
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
static uint MapSizeX()
Get the size of the map along the X.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Base of all video drivers.
static uint MapSizeY()
Get the size of the map along the Y.
static void MakeVoid(TileIndex t)
Make a nice void tile ;)
void GWDoneProc()
Procedure called when the genworld process finishes.
static void GameLoop()
Called every game-tick to let Game do something.
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
EconomySettings economy
settings to change the economy
Generate objects (radio tower, light houses)
Switch to game intro menu.
Functions related to dates.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Progress report of landscape generation; Window numbers:
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
bool IsValid() const
Checks whether the variable was already restored.
uint size_y
Y-size of the map.
GenWorldMode
Modes for GenerateWorld.
Initialize/allocate the map, start economy.
GenWorldInfo _gw
Please only use this variable in genworld.h and genworld.cpp and nowhere else.
std::thread thread
The thread we are in (joinable if a thread was created)
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
void GenerateTrees()
Place new trees.
bool IsGenerateWorldThreaded()
Tells if the world generation is done in a thread or not.
GenWorldMode mode
What mode are we making a world in.
bool IsGeneratingWorldAborted()
Is the generation being aborted?
bool quit_thread
Do we want to quit the active thread.
TownLayout town_layout
select town layout,
#define lastof(x)
Get the last element of an fixed size array.
Functions related to world/map generation.
bool GenerateTowns(TownLayout layout)
This function will generate a certain amount of towns, with a certain layout It can be called from th...
void AbortGeneratingWorld()
Initializes the abortion process.
void DeleteAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
byte se_flat_world_height
land height a flat world gets in SE
uint size_x
X-size of the map.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
bool _network_dedicated
are we a dedicated server?
Class to backup a specific variable and restore it later.
Functions related to (drawing on) viewports.
Pseudo random number generator.
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
Set here the function, if any, that you want to be called when landscape generation is aborted...
std::mutex _modal_progress_work_mutex
Rights for the performing work.
bool freeform_edges
allow terraforming the tiles at the map edges
Save game or scenario file.
bool StartNewThread(std::thread *thr, const char *name, TFn &&_Fx, TArgs &&... _Ax)
Start a new thread.
bool abort
Whether to abort the thread ASAP.
Main window; Window numbers:
Functions related to low-level strings.
The tile has no ownership.
Functions/types related to saving and loading games.
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
Generate a world.
Functions related to errors.
Switch to scenario editor.
void HideVitalWindows()
Delete all always on-top windows to get an empty screen.
static bool UseThreadedModelProgress()
Check if we can use a thread for modal progress.
GWDoneProc * proc
Proc that is called when done (can be nullptr)
The client is spectating.
Functions related to engines.
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...
std::mutex lock
synchronization for playback status fields
Functions related to modal progress.
Definition of base types and functions in a cross-platform compatible way.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Enter the gameloop, changes will be permanent.
A number of safeguards to prevent using unsafe methods.
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...
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Subdirectory of save for autosaves.
The GameInstance tracks games.
bool threaded
Whether we run _GenerateWorld threaded.
Properties of current genworld process.
Generate an empty map (sea-level)
Basic functions/variables used all over the place.
void SetSeed(uint32 seed)
(Re)set the state of the random number generator.
static class GameInstance * GetInstance()
Get the current active instance.
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
Runs the tile loop 1280 times to make snow etc.
void GWAbortProc()
Called when genworld is aborted.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
void StartupCompanies()
Start the next competitor now.
static void StartNew()
Start up a new GameScript.
GWAbortProc * abortp
Proc that is called when aborting (can be nullptr)
static void CleanupGeneration()
Clean up the 'mess' of generation.
void WaitTillGeneratedWorld()
This will wait for the thread to finish up his work.
#define DEBUG(name, level,...)
Output a line of debugging information.
void StartupEngines()
Start/initialise all our engines.
Functions related to the graphics initialization.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
void ShowNewGRFError()
Show the first NewGRF error we can find.
void UnshowCriticalError()
Unshow the critical error.
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done...
void Trash()
Trash the backup.
Functions related to companies.
bool _generating_world
Whether we are generating the map or not.
Leave the gameloop, changes will be temporary.
uint32 generation_seed
noise seed for world generation
Functions related to creating heightmaps from files.
Randomizer _random
Random used in the game state calculations.
Map accessors for void tiles.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Runs the game script at most 2500 times, or when ever the script sleeps.
CompanyID lc
The local_company before generating.
void FlatEmptyWorld(byte tile_height)
Make an empty world where all tiles are of height 'tile_height'.
static void _GenerateWorld()
The internal, real, generate function.
SwitchMode _switch_mode
The next mainloop command.
Functions related to OTTD's landscape.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Base functions for all Games.
CompanyID _current_company
Company currently doing an action.
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...
ConstructionSettings construction
construction of things in-game
void SetModalProgress(bool state)
Set the modal progress state.
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
void Restore()
Restore the variable.
std::mutex _modal_progress_paint_mutex
Rights for the painting.
void RunTileLoop()
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every 256 ticks...
GameCreationSettings game_creation
settings used during the creation of a game (map)
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Functions related to tile highlights.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
Window functions not directly related to making/drawing windows.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Functions related to water (management)
void GenerateLandscape(byte mode)
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Date _date
Current date in days (day counter)
void ShowVitalWindows()
Show the vital in-game windows.
Signal used for signalling we knowingly want to end the thread.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Class for backupping variables and making sure they are restored later.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static bool HasModalProgress()
Check if we are currently in a modal progress state.
Really prepare to start the game.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
void GfxLoadSprites()
Initialise and load all the sprites.
void ShowFirstError()
Show the first error of the queue.
Base for the NewGRF implementation.