OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
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();
210 if (_debug_desync_level > 0) {
334 DEBUG(misc, 1,
"Cannot create genworld thread, reverting to single-threaded mode");
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.
std::mutex _modal_progress_paint_mutex
Rights for the painting.
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)
std::mutex lock
synchronization for playback status fields
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.
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.
bool threaded
Whether we run _GenerateWorld threaded.
Randomizer _random
Random used in the game state calculations.
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
void GWAbortProc()
Called when genworld is aborted.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
std::thread thread
The thread we are in (joinable if a thread was created)
void StartupEngines()
Start/initialise all our engines.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
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.
Date _date
Current date in days (day counter)
Signal used for signalling we knowingly want to end the thread.
@ SLO_SAVE
File is being saved.
bool IsGenerateWorldThreaded()
Tells if the world generation is done in a thread or not.
#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.
bool StartNewThread(std::thread *thr, const char *name, TFn &&_Fx, TArgs &&... _Ax)
Start a new thread.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ PSM_ENTER_GAMELOOP
Enter the gameloop, changes will be permanent.
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.
@ 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 VideoDriver * GetInstance()
Get the currently active instance of the video driver.
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.
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.
bool quit_thread
Do we want to quit the active thread.
@ OWNER_NONE
The tile has no ownership.
@ GWM_EMPTY
Generate an empty map (sea-level)
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 WaitTillGeneratedWorld()
This will wait for the thread to finish up his work.
static bool UseThreadedModelProgress()
Check if we can use a thread for modal progress.
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()
Clean up the 'mess' of generation.
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.
std::mutex _modal_progress_work_mutex
Rights for the performing work.
void RunTileLoop()
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every 256 ticks.