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);
130 ConvertGroundTilesIntoWaterTiles();
137 if (_game_mode != GM_EDITOR) {
163 for (i = 0; i < 0x500; i++) {
169 if (_game_mode != GM_EDITOR) {
175 for (i = 0; i < 2500; i++) {
188 _cur_company.
Trash();
204 if (_debug_desync_level > 0) {
244 if (_gw.
thread == NULL)
return;
314 InitializeGame(_gw.
size_x, _gw.
size_y,
true, reset_settings);
335 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.
static void _GenerateWorld(void *)
The internal, real, generate function.
Initialize/allocate the map, start economy.
GenWorldInfo _gw
Please only use this variable in genworld.h and genworld.cpp and nowhere else.
TownLayoutByte town_layout
select town layout,
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
static const uint GENERATE_NEW_SEED
Create a new random seed.
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.
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
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.
virtual void EndCritical(bool allow_recursive=false)=0
End of the critical section.
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.
bool _network_dedicated
are we a dedicated server?
Class to backup a specific variable and restore it later.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
ThreadMutex * _modal_progress_work_mutex
Rights for the performing work.
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...
bool freeform_edges
allow terraforming the tiles at the map edges
Save game or scenario file.
bool abort
Whether to abort the thread ASAP.
Main window; Window numbers:
Functions related to low-level strings.
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.
GWDoneProc * proc
Proc that is called when done (can be NULL)
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...
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.
The tile has no ownership.
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.
ThreadMutex * _modal_progress_paint_mutex
Rights for the painting.
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 NULL)
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.
virtual void Join()=0
Join this thread.
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
CompanyByte _current_company
Company currently doing an action.
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.
class ThreadObject * thread
The thread we are in (can be NULL)
void FlatEmptyWorld(byte tile_height)
Make an empty world where all tiles are of height 'tile_height'.
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.
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.
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)...
virtual void BeginCritical(bool allow_recursive=false)=0
Begin the critical section.
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.
virtual bool Exit()=0
Exit this thread.
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.
static bool New(OTTDThreadFunc proc, void *param, ThreadObject **thread=NULL, const char *name=NULL)
Create a thread; proc will be called as first function inside the thread, with optional params...
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.