Merge branch 'development' into feature/no_multiplayer_grf_limit
[openttd-joker.git] / src / openttd.h
blob59ae8676810e1a81bcbe0e8460df68eb0288173b
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file openttd.h Some generic types. */
12 #ifndef OPENTTD_H
13 #define OPENTTD_H
15 #include "core/enum_type.hpp"
17 /** Mode which defines the state of the game. */
18 enum GameMode {
19 GM_MENU,
20 GM_NORMAL,
21 GM_EDITOR,
22 GM_BOOTSTRAP
25 /** Mode which defines what mode we're switching to. */
26 enum SwitchMode {
27 SM_NONE,
28 SM_NEWGAME, ///< New Game --> 'Random game'.
29 SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings.
30 SM_EDITOR, ///< Switch to scenario editor.
31 SM_LOAD_GAME, ///< Load game, Play Scenario.
32 SM_MENU, ///< Switch to game intro menu.
33 SM_SAVE_GAME, ///< Save game.
34 SM_SAVE_HEIGHTMAP, ///< Save heightmap.
35 SM_GENRANDLAND, ///< Generate random land within scenario editor.
36 SM_LOAD_SCENARIO, ///< Load scenario from scenario editor.
37 SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it.
38 SM_LOAD_HEIGHTMAP, ///< Load heightmap from scenario editor.
41 /** Display Options */
42 enum DisplayOptions {
43 DO_SHOW_TOWN_NAMES = 0, ///< Display town names.
44 DO_SHOW_STATION_NAMES = 1, ///< Display station names.
45 DO_SHOW_SIGNS = 2, ///< Display signs.
46 DO_FULL_ANIMATION = 3, ///< Perform palette animation.
47 DO_RAIL_FENCES = 4, ///< Draw rail fences.
48 DO_FULL_DETAIL = 5, ///< Also draw details of track and roads.
49 DO_SHOW_WAYPOINT_NAMES = 6, ///< Display waypoint names.
50 DO_SHOW_COMPETITOR_SIGNS = 7, ///< Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are always shown, even if this option is turned off.
53 extern GameMode _game_mode;
54 extern SwitchMode _switch_mode;
55 extern bool _exit_game;
57 #if defined(WIN32)
58 extern bool _in_event_loop_post_crash;
60 inline bool InEventLoopPostCrash()
62 return _in_event_loop_post_crash;
64 #else
65 inline bool InEventLoopPostCrash()
67 return false;
69 #endif
71 /** Modes of pausing we've got */
72 enum PauseMode {
73 PM_UNPAUSED = 0, ///< A normal unpaused game
74 PM_PAUSED_NORMAL = 1 << 0, ///< A game normally paused
75 PM_PAUSED_SAVELOAD = 1 << 1, ///< A game paused for saving/loading
76 PM_PAUSED_JOIN = 1 << 2, ///< A game paused for 'pause_on_join'
77 PM_PAUSED_ERROR = 1 << 3, ///< A game paused because a (critical) error
78 PM_PAUSED_ACTIVE_CLIENTS = 1 << 4, ///< A game paused for 'min_active_clients'
79 PM_PAUSED_GAME_SCRIPT = 1 << 5, ///< A game paused by a game script
80 PM_PAUSED_LINK_GRAPH = 1 << 6, ///< A game paused due to the link graph schedule lagging
82 /** Pause mode bits when paused for network reasons. */
83 PMB_PAUSED_NETWORK = PM_PAUSED_ACTIVE_CLIENTS | PM_PAUSED_JOIN,
85 DECLARE_ENUM_AS_BIT_SET(PauseMode)
86 typedef SimpleTinyEnumT<PauseMode, byte> PauseModeByte;
88 /** The current pause mode */
89 extern PauseModeByte _pause_mode;
91 void AskExitGame();
92 void AskExitToGameMenu();
94 int openttd_main(int argc, char *argv[]);
95 void HandleExitGameRequest();
97 void SwitchToMode(SwitchMode new_mode);
99 #endif /* OPENTTD_H */