73 void CallLandscapeTick();
75 void DoPaletteAnimations();
82 extern void ShowOSErrorBox(
const char *buf,
bool system);
99 ShowOSErrorBox(buf,
false);
110 void CDECL
error(
const char *s, ...)
119 ShowOSErrorBox(buf,
true);
152 "Command line options:\n" 153 " -v drv = Set video driver (see below)\n" 154 " -s drv = Set sound driver (see below) (param bufsize,hz)\n" 155 " -m drv = Set music driver (see below)\n" 156 " -b drv = Set the blitter to use (see below)\n" 157 " -r res = Set resolution (for instance 800x600)\n" 158 " -h = Display this help text\n" 159 " -t year = Set starting year\n" 160 " -d [[fac=]lvl[,...]]= Debug mode\n" 161 " -e = Start Editor\n" 162 " -g [savegame] = Start new/save game immediately\n" 163 " -G seed = Set random seed\n" 164 #
if defined(ENABLE_NETWORK)
165 " -n [ip:port#company]= Join network game\n" 166 " -p password = Password to join server\n" 167 " -P password = Password to join company\n" 168 " -D [ip][:port] = Start dedicated server\n" 169 " -l ip[:port] = Redirect DEBUG()\n" 170 #
if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
171 " -f = Fork into the background (dedicated only)\n" 174 " -I graphics_set = Force the graphics set (see below)\n" 175 " -S sounds_set = Force the sounds set (see below)\n" 176 " -M music_set = Force the music set (see below)\n" 177 " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" 178 " -x = Do not automatically save to config file on exit\n" 179 " -q savegame = Write some information about the savegame and exit\n" 214 #if !defined(WIN32) && !defined(WIN64) 221 static void WriteSavegameInfo(
const char *
name)
224 uint32 last_ottd_rev = 0;
225 byte ever_modified = 0;
226 bool removed_newgrfs =
false;
234 p +=
seprintf(p,
lastof(buf),
"NewGRF ver: 0x%08X\n", last_ottd_rev);
237 if (removed_newgrfs) {
246 p +=
seprintf(p,
lastof(buf),
"%08X %s %s\n", c->ident.grfid, md5sum, c->filename);
252 #if !defined(WIN32) && !defined(WIN64) 268 const char *t = strchr(s,
'x');
274 res->width =
max(strtoul(s, NULL, 0), 64UL);
275 res->height =
max(strtoul(t + 1, NULL, 0), 64UL);
300 #ifdef ENABLE_NETWORK 322 _game_mode = GM_MENU;
348 void MakeNewgameSettingsLive()
376 void OpenBrowser(
const char *url)
379 if (strstr(url,
"http://") != url && strstr(url,
"https://") != url)
return;
381 extern void OSOpenBrowser(
const char *url);
404 dedicated_host(NULL), dedicated_port(0), network_conn(NULL),
405 join_server_password(NULL), join_company_password(NULL),
406 save_config_ptr(save_config_ptr), save_config(true)
443 #if defined(ENABLE_NETWORK) 444 if (dedicated_host != NULL) {
459 #ifdef ENABLE_NETWORK 461 const char *port = NULL;
462 const char *company = NULL;
468 if (company != NULL) {
479 if (port != NULL) rport = atoi(port);
483 NetworkClientConnectGame(
NetworkAddress(network_conn, rport), join_as, join_server_password, join_company_password);
492 #if defined(UNIX) && !defined(__MORPHOS__) 493 extern void DedicatedFork();
505 #if defined(ENABLE_NETWORK) 511 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) 536 char *musicdriver = NULL;
537 char *sounddriver = NULL;
538 char *videodriver = NULL;
539 char *blitter = NULL;
540 char *graphics_set = NULL;
541 char *sounds_set = NULL;
542 char *music_set = NULL;
547 #if defined(ENABLE_NETWORK) 548 bool dedicated =
false;
549 char *debuglog_conn = NULL;
551 extern bool _dedicated_forks;
552 _dedicated_forks =
false;
555 _game_mode = GM_MENU;
563 while ((i = mgo.
GetOpt()) != -1) {
565 case 'I':
free(graphics_set); graphics_set =
stredup(mgo.
opt);
break;
568 case 'm':
free(musicdriver); musicdriver =
stredup(mgo.
opt);
break;
569 case 's':
free(sounddriver); sounddriver =
stredup(mgo.
opt);
break;
570 case 'v':
free(videodriver); videodriver =
stredup(mgo.
opt);
break;
572 #if defined(ENABLE_NETWORK) 580 videodriver =
stredup(
"dedicated");
584 if (mgo.
opt != NULL) {
587 const char *temp = NULL;
588 const char *port = NULL;
594 case 'f': _dedicated_forks =
true;
break;
599 debuglog_conn = mgo.
opt;
619 if (mgo.
opt != NULL) {
645 goto exit_noshutdown;
655 fprintf(stderr,
"Failed to open savegame\n");
660 fprintf(stderr,
"%s\n", buf);
662 goto exit_noshutdown;
665 WriteSavegameInfo(title);
667 goto exit_noshutdown;
679 if (i == -2 || mgo.
numleft > 0) {
692 goto exit_noshutdown;
695 #if defined(WINCE) && defined(_DEBUG) 703 #if defined(ENABLE_NETWORK) 704 if (dedicated)
DEBUG(net, 0,
"Starting dedicated version %s", _openttd_revision);
705 if (_dedicated_forks && !dedicated) _dedicated_forks =
false;
707 #if defined(UNIX) && !defined(__MORPHOS__) 709 if (_dedicated_forks) DedicatedFork();
747 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND);
757 DEBUG(misc, 1,
"Loading blitter...");
771 usererror(
"Failed to autoprobe blitter") :
772 usererror(
"Failed to select requested blitter '%s'; does it exist?", blitter);
788 #if defined(ENABLE_NETWORK) 790 const char *not_used = NULL;
791 const char *port = NULL;
797 if (port != NULL) rport = atoi(port);
818 usererror(
"Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of readme.txt.");
820 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND);
831 usererror(
"Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of readme.txt.");
833 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND);
904 #ifdef ENABLE_NETWORK 906 if (_log_fd != NULL) {
914 void HandleExitGameRequest()
916 if (_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) {
926 static void MakeNewGameDone()
950 #ifdef ENABLE_NETWORK 965 static void MakeNewGame(
bool from_heightmap,
bool reset_settings)
967 _game_mode = GM_NORMAL;
975 static void MakeNewEditorWorldDone()
980 static void MakeNewEditorWorld()
982 _game_mode = GM_EDITOR;
1009 case SL_OK:
return true;
1012 #ifdef ENABLE_NETWORK 1020 DEBUG(net, 0,
"Loading game failed, so a new (random) game will be started!");
1021 MakeNewGame(
false,
true);
1033 case GM_EDITOR: MakeNewEditorWorld();
break;
1045 #ifdef ENABLE_NETWORK 1064 MakeNewgameSettingsLive();
1067 NetworkServerStart();
1080 MakeNewEditorWorld();
1085 #ifdef ENABLE_NETWORK 1112 #ifdef ENABLE_NETWORK 1122 #ifdef ENABLE_NETWORK 1127 MakeNewGame(
true,
true);
1180 default: NOT_REACHED();
1195 if (_debug_desync_level <= 1)
return;
1211 DEBUG(desync, 2,
"town cache mismatch: town %i", (
int)t->
index);
1225 FOR_ALL_COMPANIES(c) {
1227 DEBUG(desync, 2,
"infrastructure cache mismatch: company %i", (
int)c->
index);
1234 FOR_ALL_ROADSTOPS(rs) {
1248 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) length++;
1250 NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
1251 VehicleCache *veh_cache = CallocT<VehicleCache>(length);
1253 TrainCache *tra_cache = CallocT<TrainCache>(length);
1256 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
1258 grf_cache[length] = u->grf_cache;
1259 veh_cache[length] = u->vcache;
1283 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
1285 if (memcmp(&grf_cache[length], &u->grf_cache,
sizeof(
NewGRFCache)) != 0) {
1286 DEBUG(desync, 2,
"newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (
int)v->
type, v->
index, (
int)v->
owner, v->
unitnumber, length);
1288 if (memcmp(&veh_cache[length], &u->vcache,
sizeof(
VehicleCache)) != 0) {
1289 DEBUG(desync, 2,
"vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (
int)v->
type, v->
index, (
int)v->
owner, v->
unitnumber, length);
1294 DEBUG(desync, 2,
"train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
1297 DEBUG(desync, 2,
"train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
1302 DEBUG(desync, 2,
"road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
1326 FOR_ALL_STATIONS(st) {
1346 #ifndef DEBUG_DUMP_COMMANDS 1356 if (_game_mode == GM_EDITOR) {
1360 CallLandscapeTick();
1369 char name[MAX_PATH];
1385 CallLandscapeTick();
1388 #ifndef DEBUG_DUMP_COMMANDS 1419 static int _autosave_ctr = 0;
1427 DEBUG(sl, 2,
"Autosaving to '%s'", buf);
1435 if (_game_mode == GM_BOOTSTRAP) {
1436 #ifdef ENABLE_NETWORK 1459 IncreaseSpriteLRU();
1460 InteractiveRandom();
1462 extern int _caret_timer;
1466 #ifdef ENABLE_NETWORK 1484 static uint check_message = 0;
bool disable_elrails
when true, the elrails are disabled
FiosType
Elements of a file system that are recognized.
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows. ...
Functions related to OTTD's strings.
void UpdateLandscapingLimits()
Update the landscaping limits per company.
char * _ini_videodriver
The video driver a stored in the configuration file.
VehicleSettings vehicle
options for vehicles
Cached often queried (NewGRF) values.
static bool IsLocalCompany()
Is the current company the local company?
VehicleCargoList cargo
The cargo this vehicle is carrying.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
void ParseConnectionString(const char **company, const char **port, char *connection_string)
Converts a string to ip/port/company Format: IP:port::company.
bool _networking
are we in networking mode?
Base of all video drivers.
void InitializeScreenshotFormats()
Initialize screenshot format information on startup, with _screenshot_format_name filled from the loa...
#define GETOPT_SHORT_OPTVAL(shortname)
Short option with optional value.
void CheckEngines()
Check for engines that have an appropriate availability.
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last)
Callback for FiosGetFileList.
virtual void MainLoop()
Called once every tick.
bool HandleBootstrap()
Handle all procedures for bootstrapping OpenTTD without a base graphics set.
FILE * _log_fd
File to reroute output of a forked OpenTTD to.
#define GETOPT_SHORT_VALUE(shortname)
Short option with value.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
static int MemCmpT(const T *ptr1, const T *ptr2, size_t num=1)
Type-safe version of memcmp().
int openttd_main(int argc, char *argv[])
Main entry point for this lovely game.
static char * strecat(char *dst, const char *src, const char *last)
Appends characters from one string to another.
void SetDParamStr(uint n, const char *str)
Set a rawstring parameter.
Base class for roadstops.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
bool keep_all_autosave
name the autosave in a different way
uint16 last_port
port of the last joined server
Load heightmap from scenario editor.
#define GETOPT_SHORT_NOVAL(shortname)
Short option without value.
void GenerateDefaultSaveName(char *buf, const char *last)
Fill the buffer with the default name for a savegame or screenshot.
static void GameLoop()
Called every game-tick to let Game do something.
Saveload window; Window numbers:
GameConfig stores the configuration settings of every Game.
byte _display_opt
What do we want to draw/do?
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
CargoList that is used for stations.
static Titem * Get(size_t index)
Returns Titem with given index.
struct LoggedAction * gamelog_action
Gamelog actions.
Switch to game intro menu.
void SetName(const char *name)
Set the name of the file.
Hotkey related functions.
Functions related to dates.
Generate a map for a new game.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Load game, Play Scenario.
static const OptionData _options[]
Options of OpenTTD.
Base for the train class.
bool pause_on_newgame
whether to start new games paused or not
uint16 _sl_version
the major savegame version identifier
bool * save_config_ptr
The pointer to the save config setting.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for AIScanner::GetAIConsoleList.
Functions to be called to log possibly unsafe game events.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
void InitWindowSystem()
(re)initialize the windowing system
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
TileIndex xy
Position on the map.
void RebuildTownCaches()
Rebuild all the cached variables of towns.
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
Safer implementation of vsnprintf; same as vsnprintf except:
Functions related to vehicles.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
static void ShutdownDrivers()
Shuts down all active drivers.
char title[255]
Internal name of the game.
MusicSettings music
settings related to music/sound
Base for all sound drivers.
static void Initialize()
Initialize the AI system.
GRFConfig * grfconfig
NewGrf configuration from save.
void FioCloseAll()
Close all slotted open files.
static const Year INVALID_YEAR
Representation of an invalid year.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Generate a newgame from a heightmap.
static const uint GENERATE_NEW_SEED
Create a new random seed.
static void Clean(PoolType)
Clean all pools of given type.
Tindex index
Index of this pool item.
void NetworkStartUp()
This tries to launch the network for a given OS.
Northeast, upper right on your monitor.
Cached often queried values common to all vehicles.
Dimension _cur_resolution
The current resolution.
uint16 dedicated_port
Port for the dedicated server.
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
The client wants a new company.
Simple vector template class.
Functions related to world/map generation.
static char * GetDriversInfo(char *p, const char *last)
Build a human readable list of available drivers, grouped by type.
Functions to make screenshots.
bool UpdateNewGRFConfigPalette(int32 p1)
Update the palettes of the graphics from the config file.
bool reload_cfg
reload the config file before restarting
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
void SaveToConfig()
Save the values to the configuration file.
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
uint8 map_x
X size of map.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Subdirectory for all base data (base sets, intro game)
static T max(const T a, const T b)
Returns the maximum of two values.
uint32 last_newgrf_count
the numbers of NewGRFs we found during the last scan
Functions related to laying out the texts.
Year _cur_year
Current year, starting at 0.
Cached, frequently calculated values.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void InputLoop()
Regular call from the global game loop.
CompanySettings settings
settings specific for each company
const char * GetSaveLoadErrorString()
Get the string representation of the error message.
GoodsEntry goods[NUM_CARGO]
Goods at this station.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Load file for checking and/or preview.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
bool _network_available
is network mode available?
Variables that are cached to improve performance and such.
bool _network_dedicated
are we a dedicated server?
T * Append(uint to_add=1)
Append an item and return it.
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.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
static void CheckCaches()
Check the validity of some of the caches.
ThreadMutex * _modal_progress_work_mutex
Rights for the performing work.
Pseudo random number generator.
uint8 map_y
Y size of map.
void InitFreeType(bool monospace)
(Re)initialize the freetype related things, i.e.
Library for parsing command-line options.
void ProcessAsyncSaveFinish()
Handle async save finishes.
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
Save game or scenario file.
Interface for filtering a savegame till it is loaded.
Functions to read fonts from files and cache them.
Critical errors, the MessageBox is shown in all cases.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
void NetworkChatMessageLoop()
Check if a message is expired.
static char * GetBlittersInfo(char *p, const char *last)
Fill a buffer with information about the blitters.
Callback structure of statements to be executed after the NewGRF scan.
void GamelogInfo(LoggedAction *gamelog_action, uint gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs)
Get some basic information from the given gamelog.
NetworkSettings network
settings related to the network
bool _is_network_server
Does this client wants to be a network-server?
void UpdateCache()
Update the caches of this ship.
void GamelogReset()
Resets and frees all memory allocated - used before loading or starting a new game.
Functions/types related to saving and loading games.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
Generate a world.
A music driver, needs to be before sound to properly shut down extmidi forked music players...
Functions related to errors.
Load a heightmap and start a new game from it.
char * _ini_blitter
The blitter as stored in the configuration file.
UnitID unitnumber
unit number, for display purposes only
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
Switch to scenario editor.
DateFract _date_fract
Fractional part of the day.
static void GameLoop()
Called every game-tick to let AIs do something.
SaveOrLoadResult
Save or load result codes.
static void ShowHelp()
Show the help message when someone passed a wrong parameter.
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
virtual void Stop()=0
Stop this driver.
CompanySettings company
default values for per-company settings
Information about GRF, used in the game and (part of it) in savegames.
char * _ini_sounddriver
The sound driver a stored in the configuration file.
void ConsistChanged(ConsistChangeFlags allowed_changes)
Recalculates the cached stuff of a train.
GameMode
Mode which defines the state of the game.
Old save game or scenario file.
VehicleDefaultSettings vehicle
default settings for vehicles
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...
static void Uninitialize(bool keepConfig)
Uninitialize the AI system.
static Blitter * SelectBlitter(const char *name)
Find the requested blitter and return his class.
void IConsoleCmdExec(const char *cmdstr)
Execute a given command passed to us.
Functions related to setting/changing the settings.
static const uint16 NETWORK_DEFAULT_DEBUGLOG_PORT
The default port debug-log is sent to (TCP)
ClientSettings _settings_client
The current settings for this game.
void CheckIntegrity(const RoadStop *rs) const
Check the integrity of the data in this struct.
Functions related to modal progress.
A path without any base directory.
virtual void OnNewGRFsScanned()
Called whenever the NewGRF scan completed.
Base for all music playback.
Definition of base types and functions in a cross-platform compatible way.
Enter the gameloop, changes will be permanent.
char * _config_file
Configuration file of OpenTTD.
void Clear()
Reset read data.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
A number of safeguards to prevent using unsafe methods.
void StateGameLoop()
State controlling game loop.
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...
Declaration of link graph schedule used for cargo distribution.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
First company, same as owner.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
uint8 _network_reconnect
Reconnect timeout.
void FillNewGRFVehicleCache(const Vehicle *v)
Fill the grf_cache of the given vehicle.
Scan for scenarios and heightmaps.
Base directory for all savegames.
Subdirectory of save for autosaves.
const char * join_server_password
The password to join the server with.
void InvalidateCache()
Invalidates the cached data and rebuild it.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
AfterNewGRFScan(bool *save_config_ptr)
Create a new callback.
void LoadFromConfig(bool minimal)
Load the values from the configuration files.
Console functions used outside of the console code.
char * error_data
Data to pass to SetDParamStr when displaying error.
#define GETOPT_END()
Option terminator.
void ScheduleErrorMessage(const ErrorMessageData &data)
Schedule an error.
char * DumpDebugFacilityNames(char *buf, char *last)
Dump the available debug facility names in the help text.
bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf=NULL)
Load the specified savegame but on error do different things.
static void ShutdownGame()
Unitializes drivers, frees allocated memory, cleans pools, ...
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
SaveOrLoadResult LoadWithFilter(LoadFilter *reader)
Load the game using a (reader) filter.
const char * join_company_password
The password to join the company with.
bool HasErrors()
Check whether loading the game resulted in errors.
The tile has no ownership.
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?"
void CheckIndustries()
Verify whether the generated industries are complete, and warn the user if not.
Generate an empty map (sea-level)
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
char * opt
Option value, if available (else NULL).
Basic functions/variables used all over the place.
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.
void NetworkShutDown()
This shuts the network down.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
NetworkServerGameInfo _network_game_info
Information about our game.
PauseModeByte _pause_mode
The current pause mode.
bool save_config
The save config setting.
void InitializeLanguagePacks()
Make a list of the available language packs.
ThreadMutex * _modal_progress_paint_mutex
Rights for the painting.
StringID error
Error message from loading. INVALID_STRING_ID if no error.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
void WaitTillGeneratedWorld()
This will wait for the thread to finish up his work.
SaveLoadOperation
Operation performed on the file.
Maximum number of companies.
void CallWindowTickEvent()
Dispatch WE_TICK event over all windows.
void UnInitWindowSystem()
Close down the windowing system.
class GameConfig * game_config
settings for gamescript
Functions to be called to log a crash.
char * dedicated_host
Hostname for the dedicated server.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
No construction actions may be executed.
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
StringID name
The name for this object.
#define DEBUG(name, level,...)
Output a line of debugging information.
Maximal number of cargo types in a game.
static void Initialize()
Initialize the Game system.
char map_name[NETWORK_NAME_LENGTH]
Map which is played ["random" for a randomized map].
uint16 server_port
port the server listens on
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
static SoundDriver * GetInstance()
Get the currently active instance of the sound driver.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
void GenerateWorldSetCallback(GWDoneProc *proc)
Set here the function, if any, that you want to be called when landscape generation is done...
Callback for NewGRF scanning.
byte music_vol
The requested music volume.
void IncreaseDate()
Increases the tick counter, increases date and possibly calls procedures that have to be called daily...
void LoadHotkeysFromConfig()
Load the hotkeys from the config file.
Functions related to companies.
No support for 8bpp by OS or hardware, force 32bpp blitters.
static const uint16 NETWORK_DEFAULT_PORT
The default port of the game server (TCP & UDP)
The data of the error message.
Leave the gameloop, changes will be temporary.
uint32 generation_seed
noise seed for world generation
Declaration of functions and types defined in highscore.h and highscore_gui.h.
Data storage for parsing command line options.
GUISettings gui
settings related to the GUI
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
CargoList that is used for vehicles.
void DeterminePaths(const char *exe)
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir...
static void DoAutosave()
Create an autosave.
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static void SelectDriver(const char *name, Driver::Type type)
Find the requested driver and return its class.
void ResetNewGRFData()
Reset all NewGRF loaded data TODO.
Declarations for savegames operations.
CompanyByte _current_company
Company currently doing an action.
Vehicle * Next() const
Get the next vehicle of this vehicle.
uint8 command_pause_level
level/amount of commands that can't be executed while paused
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
static void KillAll()
Kill any and all AIs we manage.
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
Restart –> 'Random game' with current settings.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
OwnerByte owner
Which company owns the vehicle?
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
char * network_conn
Information about the server to connect to, or NULL.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
static void Clear()
Clear all link graphs and jobs from the schedule.
virtual void MainLoop()=0
Perform the actual drawing.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
VehicleDefaultSettings _old_vds
Used for loading default vehicles settings from old savegames.
TownCache cache
Container for all cacheable data.
bool in_window
mouse inside this window, determines drawing logic
SwitchMode _switch_mode
The next mainloop command.
char default_company_pass[NETWORK_PASSWORD_LENGTH]
default password for new companies in encrypted form
uint gamelog_actions
Number of gamelog actions.
const Entry * GetEntry(DiagDirection dir) const
Get the drive through road stop entry struct for the given direction.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
Statusbar (at the bottom of your screen); Window numbers:
Base functions for all Games.
Functions related to commands.
Network functions used by other parts of OpenTTD.
uint generation_seed
Seed for the new game.
char name[MAX_PATH]
Name of the file.
bool _network_server
network-server is active
SaveLoadOperation file_op
File operation to perform.
A Stop for a Road Vehicle.
static void ReduceLineCache()
Reduce the size of linecache if necessary to prevent infinite growth.
void SaveHotkeysToConfig()
Save the hotkeys to the config file.
void Clear()
Remove all items from the list.
void UninitFreeType()
Free everything allocated w.r.t.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Perform palette animation.
static void LoadIntroGame(bool load_newgrfs=true)
Load the introduction game.
class AIConfig * ai_config[MAX_COMPANIES]
settings per company
void NetworkBackgroundLoop()
We have to do some (simple) background stuff that runs normally, even when we are not in multiplayer...
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
byte max_num_autosaves
controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num...
header file for electrified rail specific functions
int GetOpt()
Find the next option.
void NetworkDisconnect(bool blocking, bool close_admins)
We want to disconnect from the host/clients.
Load scenario from scenario editor.
ConstructionSettings construction
construction of things in-game
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static void ParseResolution(Dimension *res, const char *s)
Extract the resolution from the given string and store it in the 'res' parameter. ...
char last_host[NETWORK_HOSTNAME_LENGTH]
IP address of the last joined server.
declaration of OTTD revision dependent variables
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
bool HasNewGrfs()
Check whether the game uses any NewGrfs.
void InitializeSpriteSorter()
Choose the "best" sprite sorter and set _vp_sprite_sorter.
Types related to sprite sorting.
void Restore()
Restore the variable.
Base functions for all AIs.
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
char * _ini_musicdriver
The music driver a stored in the configuration file.
const T * Get(uint index) const
Get the pointer to item "number" (const)
void RunTileLoop()
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every 256 ticks...
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) ...
GameCreationSettings game_creation
settings used during the creation of a game (map)
void SetMode(FiosType ft)
Set the mode and file type of the file to save or load based on the type of file entry at the file sy...
byte CargoID
Cargo slots to indicate a cargo type within a game.
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
StringList _network_bind_list
The addresses to bind on.
A game paused for saving/loading.
Generate random land within scenario editor.
virtual void BeginCritical(bool allow_recursive=false)=0
Begin the critical section.
AIConfig stores the configuration settings of every AI.
Owner
Enum for all companies/owners.
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
void InvalidateCache()
Invalidates the cached data and rebuilds it.
int numleft
Number of arguments left in argv.
const char * NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
Change the company password of a given company.
GUI functions that shouldn't be here.
Functions related to news.
void SaveToHighScore()
Save HighScore table to file.
bool MakeHeightmapScreenshot(const char *filename)
Make a heightmap of the current map.
Base classes/functions for stations.
Errors (eg. saving/loading failed)
Date _date
Current date in days (day counter)
Year startyear
The start year.
DetailedFileType
Kinds of files in each AbstractFileType.
VehicleTypeByte type
Type of vehicle.
Dimensions (a width and height) of a rectangle in 2D.
Valid changes while vehicle is driving, and possibly changing tracks.
static void SetErrorMessage(const char *message)
Sets a message for the error message handler.
Generate a random map for SE.
bool _do_autosave
are we doing an autosave at the moment?
Year starting_year
starting date
void AnimateAnimatedTiles()
Animate all tiles in the animated tile list, i.e. call AnimateTile on them.
Class for backupping variables and making sure they are restored later.
Factory to 'query' all available blitters.
Functions related to subsidies.
New Game –> 'Random game'.
SwitchMode
Mode which defines what mode we're switching to.
static bool HasModalProgress()
Check if we are currently in a modal progress state.
void LoadFromHighScore()
Initialize the highscore table to 0 and if any file exists, load in values.
GroundVehicleCache gcache
Cache of often calculated values.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
bool SettingsDisableElrail(int32 p1)
_settings_game.disable_elrail callback
Base for the NewGRF implementation.
error that was caught in the middle of updating game state, need to clear it. (can only happen during...