openttd.cpp File Reference

Functions related to starting OpenTTD. More...

#include "stdafx.h"
#include "blitter/factory.hpp"
#include "sound/sound_driver.hpp"
#include "music/music_driver.hpp"
#include "video/video_driver.hpp"
#include "fontcache.h"
#include "gui.h"
#include "sound_func.h"
#include "window_func.h"
#include "base_media_base.h"
#include "saveload/saveload.h"
#include "company_func.h"
#include "command_func.h"
#include "news_func.h"
#include "fios.h"
#include "aircraft.h"
#include "roadveh.h"
#include "train.h"
#include "ship.h"
#include "console_func.h"
#include "screenshot.h"
#include "network/network.h"
#include "network/network_func.h"
#include "signs_base.h"
#include "ai/ai.hpp"
#include "ai/ai_config.hpp"
#include "settings_func.h"
#include "genworld.h"
#include "group.h"
#include "strings_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "gamelog.h"
#include "animated_tile_func.h"
#include "roadstop_base.h"
#include "elrail_func.h"
#include "rev.h"
#include "highscore.h"
#include "thread/thread.h"
#include "station_base.h"
#include "crashlog.h"
#include "engine_func.h"
#include "core/random_func.hpp"
#include "rail_gui.h"
#include "core/backup_type.hpp"
#include "hotkeys.h"
#include "newgrf.h"
#include "misc/getoptdata.h"
#include "town.h"
#include "industry.h"
#include <stdarg.h>
#include "table/strings.h"

Go to the source code of this file.

Functions

void CallLandscapeTick ()
void IncreaseDate ()
 Increases the tick counter, increases date and possibly calls procedures that have to be called daily, monthly or yearly.
void DoPaletteAnimations ()
void MusicLoop ()
void ResetMusic ()
void CallWindowTickEvent ()
 Dispatch WE_TICK event over all windows.
void SetDifficultyLevel (int mode, DifficultySettings *gm_opt)
CompanyDoStartupNewCompany (bool is_ai, CompanyID company=INVALID_COMPANY)
 Create a new company and sets all company variables default values.
void ShowOSErrorBox (const char *buf, bool system)
void CDECL usererror (const char *s,...)
 Error handling for fatal user errors.
void CDECL error (const char *s,...)
 Error handling for fatal non-user errors.
void CDECL ShowInfoF (const char *str,...)
 Shows some information on the console/a popup box depending on the OS.
static void ShowHelp ()
 Show the help message when someone passed a wrong parameter.
static void ParseResolution (Dimension *res, const char *s)
 Extract the resolution from the given string and store it in the 'res' parameter.
static void InitializeDynamicVariables ()
static void ShutdownGame ()
 Unitializes drivers, frees allocated memory, cleans pools, .
static void LoadIntroGame ()
void MakeNewgameSettingsLive ()
int ttd_main (int argc, char *argv[])
void HandleExitGameRequest ()
static void MakeNewGameDone ()
static void MakeNewGame (bool from_heightmap, bool reset_settings)
static void MakeNewEditorWorldDone ()
static void MakeNewEditorWorld ()
bool SafeLoad (const char *filename, int mode, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf=NULL)
 Load the specified savegame but on error do different things.
void SwitchToMode (SwitchMode new_mode)
static void CheckCaches ()
 Check the validity of some of the caches.
void StateGameLoop ()
 State controlling game loop.
static void DoAutosave ()
 Create an autosave.
void GameLoop ()

Variables

StringID _switch_mode_errorstr
 Error message to show when switching modes.
char * _config_file
 Configuration file of OpenTTD.
static const OptionData _options []
 Options of OpenTTD.

Detailed Description

Functions related to starting OpenTTD.

Definition in file openttd.cpp.


Function Documentation

static void CheckCaches (  )  [static]
static void DoAutosave (  )  [static]

Create an autosave.

The default name is "autosave#.sav". However with the setting 'keep_all_autosave' the name defaults to company-name + date

Definition at line 1172 of file openttd.cpp.

References _networking, _settings_client, AUTOSAVE_DIR, DEBUG, GenerateDefaultSaveName(), ClientSettings::gui, INVALID_STRING_ID, GUISettings::keep_all_autosave, lastof, GUISettings::max_num_autosaves, SaveOrLoad(), ShowErrorMessage(), SL_OK, SL_SAVE, strecat(), and WL_ERROR.

Company* DoStartupNewCompany ( bool  is_ai,
CompanyID  company = INVALID_COMPANY 
)

Create a new company and sets all company variables default values.

Parameters:
is_ai is an AI company?
company CompanyID to use for the new company
Returns:
the company struct

Definition at line 527 of file company_cmd.cpp.

void CDECL error ( const char *  s,
  ... 
)
static void ParseResolution ( Dimension res,
const char *  s 
) [static]

Extract the resolution from the given string and store it in the 'res' parameter.

Parameters:
res variable to store the resolution in.
s the string to decompose.

Definition at line 222 of file openttd.cpp.

References max(), and ShowInfoF().

bool SafeLoad ( const char *  filename,
int  mode,
GameMode  newgm,
Subdirectory  subdir,
struct LoadFilter lf = NULL 
)

Load the specified savegame but on error do different things.

If loading fails due to corrupt savegame, bad version, etc. go back to a previous correct state. In the menu for example load the intro game again.

Parameters:
mode mode of loading, either SL_LOAD or SL_OLD_LOAD
newgm switch to this mode of loading fails due to some unknown error
filename file to be loaded
subdir default directory to look for filename, set to 0 if not needed
lf Load filter to use, if NULL: use filename + subdir.

Definition at line 811 of file openttd.cpp.

References _network_dedicated, _network_server, DEBUG, LoadWithFilter(), NetworkDisconnect(), SaveOrLoad(), SL_LOAD, SL_OK, SL_OLD_LOAD, and SL_REINIT.

Referenced by VideoDriver_Dedicated::MainLoop(), and ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE().

void CDECL ShowInfoF ( const char *  str,
  ... 
)

Shows some information on the console/a popup box depending on the OS.

Parameters:
str the text to show.

Definition at line 132 of file openttd.cpp.

References lengthof.

Referenced by CheckExternalFiles(), GetFontByFaceName(), GetKeyboardLayout(), GetSavegameFormat(), GRFLoadConfig(), IniLoadSettings(), LoadFreeTypeFont(), ParseResolution(), IniFile::ReportFileError(), SetDebugString(), and StringToVal().

static void ShutdownGame (  )  [static]

Unitializes drivers, frees allocated memory, cleans pools, .

.. Generally, prepares the game for shutting down

Definition at line 250 of file openttd.cpp.

References _config_file, _network_available, PoolBase::Clean(), GamelogReset(), NetworkShutDown(), PT_ALL, ResetNewGRFData(), DriverFactoryBase::ShutdownDrivers(), AI::Uninitialize(), and UnInitWindowSystem().

void StateGameLoop (  ) 
void CDECL usererror ( const char *  s,
  ... 
)

Error handling for fatal user errors.

Parameters:
s the string to print.
Note:
Does NEVER return.

Definition at line 92 of file openttd.cpp.

References _video_driver, lengthof, and Driver::Stop().

Referenced by DEFINE_POOL_METHOD(), HandleInvalidSpriteRequest(), InitializeLanguagePacks(), VideoDriver_Win32::MakeWindow(), ReadSprite(), DriverFactoryBase::SelectDriver(), and ServerNetworkGameSocketHandler::SendMap().


Variable Documentation

const OptionData _options[] [static]

Error message to show when switching modes.

Definition at line 73 of file openttd.cpp.

Referenced by AfterLoadGame(), NetworkGameSocketHandler::CloseConnection(), and GenerateTowns().


Generated on Sun May 8 07:30:29 2011 for OpenTTD by  doxygen 1.6.1