75 void CallLandscapeTick();
77 void DoPaletteAnimations();
84 extern void ShowOSErrorBox(
const char *buf,
bool system);
101 ShowOSErrorBox(buf,
false);
112 void CDECL
error(
const char *s, ...)
122 ShowOSErrorBox(buf,
true);
156 "Command line options:\n" 157 " -v drv = Set video driver (see below)\n" 158 " -s drv = Set sound driver (see below) (param bufsize,hz)\n" 159 " -m drv = Set music driver (see below)\n" 160 " -b drv = Set the blitter to use (see below)\n" 161 " -r res = Set resolution (for instance 800x600)\n" 162 " -h = Display this help text\n" 163 " -t year = Set starting year\n" 164 " -d [[fac=]lvl[,...]]= Debug mode\n" 165 " -e = Start Editor\n" 166 " -g [savegame] = Start new/save game immediately\n" 167 " -G seed = Set random seed\n" 168 #
if defined(ENABLE_NETWORK)
169 " -n [ip:port#company]= Join network game\n" 170 " -p password = Password to join server\n" 171 " -P password = Password to join company\n" 172 " -D [ip][:port] = Start dedicated server\n" 173 " -l ip[:port] = Redirect DEBUG()\n" 174 #
if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(_WIN32)
175 " -f = Fork into the background (dedicated only)\n" 178 " -I graphics_set = Force the graphics set (see below)\n" 179 " -S sounds_set = Force the sounds set (see below)\n" 180 " -M music_set = Force the music set (see below)\n" 181 " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" 182 " -x = Do not automatically save to config file on exit\n" 183 " -q savegame = Write some information about the savegame and exit\n" 225 static void WriteSavegameInfo(
const char *
name)
228 uint32 last_ottd_rev = 0;
229 byte ever_modified = 0;
230 bool removed_newgrfs =
false;
238 p +=
seprintf(p,
lastof(buf),
"NewGRF ver: 0x%08X\n", last_ottd_rev);
241 if (removed_newgrfs) {
250 p +=
seprintf(p,
lastof(buf),
"%08X %s %s\n", c->ident.grfid, md5sum, c->filename);
272 const char *t = strchr(s,
'x');
278 res->width =
max(strtoul(s, NULL, 0), 64UL);
279 res->height =
max(strtoul(t + 1, NULL, 0), 64UL);
304 #ifdef ENABLE_NETWORK 326 _game_mode = GM_MENU;
352 void MakeNewgameSettingsLive()
383 void OpenBrowser(
const char *url)
386 if (strstr(url,
"http://") != url && strstr(url,
"https://") != url)
return;
388 extern void OSOpenBrowser(
const char *url);
411 dedicated_host(NULL), dedicated_port(0), network_conn(NULL),
412 join_server_password(NULL), join_company_password(NULL),
413 save_config_ptr(save_config_ptr), save_config(true)
453 #if defined(ENABLE_NETWORK) 454 if (dedicated_host != NULL) {
469 #ifdef ENABLE_NETWORK 471 const char *port = NULL;
472 const char *company = NULL;
478 if (company != NULL) {
489 if (port != NULL) rport = atoi(port);
493 NetworkClientConnectGame(
NetworkAddress(network_conn, rport), join_as, join_server_password, join_company_password);
502 #if defined(UNIX) && !defined(__MORPHOS__) 503 extern void DedicatedFork();
515 #if defined(ENABLE_NETWORK) 521 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(_WIN32) 546 char *musicdriver = NULL;
547 char *sounddriver = NULL;
548 char *videodriver = NULL;
549 char *blitter = NULL;
550 char *graphics_set = NULL;
551 char *sounds_set = NULL;
552 char *music_set = NULL;
557 #if defined(ENABLE_NETWORK) 558 bool dedicated =
false;
559 char *debuglog_conn = NULL;
561 extern bool _dedicated_forks;
562 _dedicated_forks =
false;
565 _game_mode = GM_MENU;
573 while ((i = mgo.
GetOpt()) != -1) {
575 case 'I':
free(graphics_set); graphics_set =
stredup(mgo.
opt);
break;
578 case 'm':
free(musicdriver); musicdriver =
stredup(mgo.
opt);
break;
579 case 's':
free(sounddriver); sounddriver =
stredup(mgo.
opt);
break;
580 case 'v':
free(videodriver); videodriver =
stredup(mgo.
opt);
break;
582 #if defined(ENABLE_NETWORK) 590 videodriver =
stredup(
"dedicated");
594 if (mgo.
opt != NULL) {
597 const char *temp = NULL;
598 const char *port = NULL;
604 case 'f': _dedicated_forks =
true;
break;
609 debuglog_conn = mgo.
opt;
629 if (mgo.
opt != NULL) {
655 goto exit_noshutdown;
665 fprintf(stderr,
"Failed to open savegame\n");
670 fprintf(stderr,
"%s\n", buf);
672 goto exit_noshutdown;
675 WriteSavegameInfo(title);
677 goto exit_noshutdown;
689 if (i == -2 || mgo.
numleft > 0) {
702 goto exit_noshutdown;
708 #if defined(ENABLE_NETWORK) 709 if (dedicated)
DEBUG(net, 0,
"Starting dedicated version %s", _openttd_revision);
710 if (_dedicated_forks && !dedicated) _dedicated_forks =
false;
712 #if defined(UNIX) && !defined(__MORPHOS__) 714 if (_dedicated_forks) DedicatedFork();
752 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND);
762 DEBUG(misc, 1,
"Loading blitter...");
776 usererror(
"Failed to autoprobe blitter") :
777 usererror(
"Failed to select requested blitter '%s'; does it exist?", blitter);
793 #if defined(ENABLE_NETWORK) 795 const char *not_used = NULL;
796 const char *port = NULL;
802 if (port != NULL) rport = atoi(port);
823 usererror(
"Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of README.md.");
825 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND);
836 usererror(
"Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of README.md.");
838 ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND);
909 #ifdef ENABLE_NETWORK 911 if (_log_fd != NULL) {
919 void HandleExitGameRequest()
921 if (_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) {
931 static void MakeNewGameDone()
963 #ifdef ENABLE_NETWORK 978 static void MakeNewGame(
bool from_heightmap,
bool reset_settings)
980 _game_mode = GM_NORMAL;
988 static void MakeNewEditorWorldDone()
993 static void MakeNewEditorWorld()
995 _game_mode = GM_EDITOR;
1022 case SL_OK:
return true;
1025 #ifdef ENABLE_NETWORK 1033 DEBUG(net, 0,
"Loading game failed, so a new (random) game will be started!");
1034 MakeNewGame(
false,
true);
1046 case GM_EDITOR: MakeNewEditorWorld();
break;
1058 #ifdef ENABLE_NETWORK 1077 MakeNewgameSettingsLive();
1080 NetworkServerStart();
1093 MakeNewEditorWorld();
1098 #ifdef ENABLE_NETWORK 1125 #ifdef ENABLE_NETWORK 1135 #ifdef ENABLE_NETWORK 1140 MakeNewGame(
true,
true);
1193 default: NOT_REACHED();
1208 if (_debug_desync_level <= 1)
return;
1224 DEBUG(desync, 2,
"town cache mismatch: town %i", (
int)t->
index);
1238 FOR_ALL_COMPANIES(c) {
1240 DEBUG(desync, 2,
"infrastructure cache mismatch: company %i", (
int)c->
index);
1247 FOR_ALL_ROADSTOPS(rs) {
1261 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) length++;
1263 NewGRFCache *grf_cache = CallocT<NewGRFCache>(length);
1264 VehicleCache *veh_cache = CallocT<VehicleCache>(length);
1266 TrainCache *tra_cache = CallocT<TrainCache>(length);
1269 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
1271 grf_cache[length] = u->grf_cache;
1272 veh_cache[length] = u->vcache;
1296 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
1298 if (memcmp(&grf_cache[length], &u->grf_cache,
sizeof(
NewGRFCache)) != 0) {
1299 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);
1301 if (memcmp(&veh_cache[length], &u->vcache,
sizeof(
VehicleCache)) != 0) {
1302 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);
1307 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);
1310 DEBUG(desync, 2,
"train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
1315 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);
1339 FOR_ALL_STATIONS(st) {
1367 #ifndef DEBUG_DUMP_COMMANDS 1379 if (_game_mode == GM_EDITOR) {
1383 CallLandscapeTick();
1392 char name[MAX_PATH];
1408 CallLandscapeTick();
1411 #ifndef DEBUG_DUMP_COMMANDS 1440 static int _autosave_ctr = 0;
1448 DEBUG(sl, 2,
"Autosaving to '%s'", buf);
1456 if (_game_mode == GM_BOOTSTRAP) {
1457 #ifdef ENABLE_NETWORK 1480 IncreaseSpriteLRU();
1481 InteractiveRandom();
1483 #ifdef ENABLE_NETWORK 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?
Time spent processing cargo movement.
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:
SaveLoadVersion
SaveLoad versions Previous savegame versions, the trunk revision where they were introduced and the r...
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
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.
Maximal number of cargo types in a game.
Functions to be called to log possibly unsafe game events.
Types for recording game performance data.
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.
SaveLoadVersion _sl_version
the major savegame version identifier
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.
void Change(const char *name, int version=-1, bool force_exact_match=false, bool is_random=false)
Set another Script to be loaded in this slot.
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 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.
Time spent processing aircraft.
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.
Speed of gameloop processing.
Load file for checking and/or preview.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
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.
Functions related to (drawing on) viewports.
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.
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 MusicLoop()
Check music playback status and start/stop/song-finished.
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.
Time spend processing road vehicles.
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 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.
byte starting_colour
default color scheme for the company to start a new game with
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
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()
Uninitializes 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.
Time spent processing other world features.
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.
void CallWindowGameTickEvent()
Dispatch OnGameTick event over all windows.
Maximum number of companies.
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.
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.
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.
Time spent processing ships.
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.
Declarations for savegames operations.
CompanyByte _current_company
Company currently doing an action.
Vehicle * Next() const
Get the next vehicle of this vehicle.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
byte colour
Company colour.
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.
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
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
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.
uint32 generation_seed
Seed for the new 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)
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
Get the Script config from the current game.
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.
Time spent processing trains.
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.
Sum of all GS/AI scripts.
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...