OpenTTD Source 20260531-master-g0e951f3528
openttd.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef OPENTTD_H
11#define OPENTTD_H
12
13#include <atomic>
14#include <chrono>
15#include "core/enum_type.hpp"
16
18enum class GameMode : uint8_t {
23};
24
43
54
57
59 std::chrono::steady_clock::time_point start_time;
60 std::string savegame_id;
61 std::optional<size_t> savegame_size;
62};
63
64extern GameMode _game_mode;
67extern std::atomic<bool> _exit_game;
68extern bool _save_config;
69
71enum class PauseMode : uint8_t {
72 Normal = 0,
74 Join = 2,
75 Error = 3,
80};
81using PauseModes = EnumBitSet<PauseMode, uint8_t>;
82
84extern PauseModes _pause_mode;
85
86void AskExitGame();
87void AskExitToGameMenu();
88
89int openttd_main(std::span<std::string_view> arguments);
90void StateGameLoop();
91void HandleExitGameRequest();
92
93void SwitchToMode(SwitchMode new_mode);
94
95bool RequestNewGRFScan(struct NewGRFScanCallback *callback = nullptr);
97
98void OpenBrowser(const std::string &url);
99void ChangeAutosaveFrequency(bool reset);
100
101#endif /* OPENTTD_H */
Enum-as-bit-set wrapper.
A connected component of a link graph.
Definition linkgraph.h:37
Type (helpers) for enums.
GameSessionStats _game_session_stats
Statistics about the current session.
Definition gfx.cpp:52
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:51
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:50
bool LoadHeightmap(DetailedFileType dft, std::string_view filename)
Load a heightmap from file and change the map in its current dimensions to a landscape representing t...
DisplayOption
Display Options.
Definition openttd.h:45
@ ShowSigns
Display signs.
Definition openttd.h:48
@ FullDetail
Also draw details of track and roads.
Definition openttd.h:50
@ ShowWaypointNames
Display waypoint names.
Definition openttd.h:51
@ ShowTownNames
Display town names.
Definition openttd.h:46
@ ShowStationNames
Display station names.
Definition openttd.h:47
@ FullAnimation
Perform palette animation.
Definition openttd.h:49
@ ShowCompetitorSigns
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Definition openttd.h:52
int openttd_main(std::span< std::string_view > arguments)
Main entry point for this lovely game.
Definition openttd.cpp:496
void ChangeAutosaveFrequency(bool reset)
Reset the interval of the autosave.
Definition openttd.cpp:1311
void StateGameLoop()
State controlling game loop.
Definition openttd.cpp:1208
void GenerateSavegameId()
Generate an unique savegame ID.
Definition misc.cpp:89
PauseMode
Modes of pausing we've got.
Definition openttd.h:71
@ Error
A game paused because a (critical) error.
Definition openttd.h:75
@ GameScript
A game paused by a game script.
Definition openttd.h:77
@ ActiveClients
A game paused for 'min_active_clients'.
Definition openttd.h:76
@ Join
A game paused for 'pause_on_join'.
Definition openttd.h:74
@ CommandDuringPause
A game paused, and a command executed during the pause; resets on autosave.
Definition openttd.h:79
GameMode
Mode which defines the state of the game.
Definition openttd.h:18
@ Editor
In the scenario editor.
Definition openttd.h:21
@ Bootstrap
In the content bootstrap process.
Definition openttd.h:22
@ Normal
Playing a game.
Definition openttd.h:20
@ Menu
In the main menu.
Definition openttd.h:19
bool RequestNewGRFScan(struct NewGRFScanCallback *callback=nullptr)
Request a new NewGRF scan.
Definition openttd.cpp:1324
SwitchMode
Mode which defines what mode we're switching to.
Definition openttd.h:26
@ LoadGame
Load game, Play Scenario.
Definition openttd.h:32
@ JoinGame
Join a network game.
Definition openttd.h:41
@ LoadScenario
Load scenario from scenario editor.
Definition openttd.h:37
@ StartHeightmap
Load a heightmap and start a new game from it.
Definition openttd.h:38
@ NewGame
New Game --> 'Random game'.
Definition openttd.h:28
@ GenerateRandomLand
Generate random land within scenario editor.
Definition openttd.h:36
@ ReloadGame
Reload the savegame / scenario / heightmap you started the game with.
Definition openttd.h:30
@ SaveGame
Save game.
Definition openttd.h:34
@ RestartHeightmap
Load a heightmap and start a new game from it with current settings.
Definition openttd.h:40
@ SaveHeightmap
Save heightmap.
Definition openttd.h:35
@ RestartGame
Restart --> 'Random game' with current settings.
Definition openttd.h:29
EnumBitSet< DisplayOption, uint8_t > DisplayOptions
Bitset of DisplayOption elements.
Definition openttd.h:56
std::chrono::steady_clock::time_point start_time
Time when the current game was started.
Definition openttd.h:59
std::string savegame_id
Unique ID of the savegame.
Definition openttd.h:60
std::optional< size_t > savegame_size
Size of the last saved savegame in bytes, or std::nullopt if not saved yet.
Definition openttd.h:61
Callback for NewGRF scanning.
SaveLoad type struct.
Definition saveload.h:757
@ None
No visual effect.
Definition vehicle.cpp:2824