OpenTTD Source: src/game/game.hpp Source File

OpenTTD Source 15.3

game.hpp
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
10#ifndef GAME_HPP
11#define GAME_HPP
12
13#include "game_scanner.hpp"
14
15#include "../script/api/script_event_types.hpp"
16
20 class Game {
21public:
25 static void GameLoop();
26
30 static void Initialize();
31
35 static void StartNew();
36
40 static void Uninitialize(bool keepConfig);
41
47 static void Pause();
48
54 static void Unpause();
55
60 static bool IsPaused();
61
65 static void NewEvent(class ScriptEvent *event);
66
70 static class GameInfo *GetInfo() { return Game::info; }
71
72 static void Rescan();
73 static void ResetConfig();
74
78 static void Save();
79
81 static void GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only);
83 static void GetConsoleLibraryList(std::back_insert_iterator<std::string> &output_iterator);
85 static const ScriptInfoList *GetInfoList();
87 static const ScriptInfoList *GetUniqueInfoList();
89 static class GameInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
91 static class GameLibrary *FindLibrary(const std::string &library, int version);
92
96 static class GameInstance *GetInstance() { return Game::instance.get(); }
97
101 static void ResetInstance();
102
104 static bool HasGame(const ContentInfo &ci, bool md5sum);
105 static bool HasGameLibrary(const ContentInfo &ci, bool md5sum);
107 static GameScannerInfo *GetScannerInfo();
109 static GameScannerLibrary *GetScannerLibrary();
110
111private:
112 static uint frame_counter;
113 static std::unique_ptr<GameInstance> instance;
114 static std::unique_ptr<GameScannerInfo> scanner_info;
115 static std::unique_ptr<GameScannerLibrary> scanner_library;
116 static GameInfo *info;
117};
118
119#endif /* GAME_HPP */
GameInfo
All static information from an Game like name, version, etc.
Definition game_info.hpp:16
GameInstance
Runtime information about a game script like a pointer to the squirrel vm and the current state.
Definition game_instance.hpp:16
GameLibrary
All static information from an Game library like name, version, etc.
Definition game_info.hpp:52
GameScannerInfo
Definition game_scanner.hpp:15
GameScannerLibrary
Definition game_scanner.hpp:37
Game
Main Game class.
Definition game.hpp:20
Game::StartNew
static void StartNew()
Start up a new GameScript.
Definition game_core.cpp:72
Game::info
static GameInfo * info
Current selected GameInfo.
Definition game.hpp:116
Game::FindInfo
static class GameInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
Definition game_core.cpp:223
Game::GetInfo
static class GameInfo * GetInfo()
Get the current GameInfo.
Definition game.hpp:70
Game::HasGame
static bool HasGame(const ContentInfo &ci, bool md5sum)
Wrapper function for GameScanner::HasGame.
Definition game_core.cpp:245
Game::GetScannerLibrary
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
Definition game_core.cpp:259
Game::Unpause
static void Unpause()
Resume execution of the Game Script.
Definition game_core.cpp:126
Game::IsPaused
static bool IsPaused()
Checks if the Game Script is paused.
Definition game_core.cpp:131
Game::frame_counter
static uint frame_counter
Tick counter for the Game code.
Definition game.hpp:112
Game::instance
static std::unique_ptr< GameInstance > instance
Instance to the current active Game.
Definition game.hpp:113
Game::Save
static void Save()
Save data from a GameScript to a savegame.
Definition game_core.cpp:192
Game::ResetInstance
static void ResetInstance()
Reset the current active instance.
Definition game_core.cpp:233
Game::FindLibrary
static class GameLibrary * FindLibrary(const std::string &library, int version)
Wrapper function for GameScanner::FindLibrary.
Definition game_core.cpp:228
Game::GetUniqueInfoList
static const ScriptInfoList * GetUniqueInfoList()
Wrapper function for GameScanner::GetUniqueInfoList.
Definition game_core.cpp:218
Game::Pause
static void Pause()
Suspends the Game Script and then pause the execution of the script.
Definition game_core.cpp:121
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition game_core.cpp:136
Game::GetInstance
static class GameInstance * GetInstance()
Get the current active instance.
Definition game.hpp:96
Game::GameLoop
static void GameLoop()
Called every game-tick to let Game do something.
Definition game_core.cpp:31
Game::GetConsoleList
static void GetConsoleList(std::back_insert_iterator< std::string > &output_iterator, bool newest_only)
Wrapper function for GameScanner::GetConsoleList.
Definition game_core.cpp:203
Game::GetConsoleLibraryList
static void GetConsoleLibraryList(std::back_insert_iterator< std::string > &output_iterator)
Wrapper function for GameScanner::GetConsoleLibraryList.
Definition game_core.cpp:208
Game::Uninitialize
static void Uninitialize(bool keepConfig)
Uninitialize the Game system.
Definition game_core.cpp:102
Game::scanner_info
static std::unique_ptr< GameScannerInfo > scanner_info
Scanner for Game scripts.
Definition game.hpp:114
Game::GetInfoList
static const ScriptInfoList * GetInfoList()
Wrapper function for GameScanner::GetInfoList.
Definition game_core.cpp:213
Game::Initialize
static void Initialize()
Initialize the Game system.
Definition game_core.cpp:57
Game::scanner_library
static std::unique_ptr< GameScannerLibrary > scanner_library
Scanner for GS Libraries.
Definition game.hpp:115
Game::GetScannerInfo
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
Definition game_core.cpp:255
game_scanner.hpp
declarations of the class for Game scanner
ScriptInfoList
std::map< std::string, class ScriptInfo *, CaseInsensitiveComparator > ScriptInfoList
Type for the list of scripts.
Definition script_scanner.hpp:16
ContentInfo
Container for all important information about a piece of content.
Definition tcp_content_type.h:56