OpenTTD Source  20240919-master-gdf0233f4c2
game_instance.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 <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef GAME_INSTANCE_HPP
11 #define GAME_INSTANCE_HPP
12 
13 #include "../script/script_instance.hpp"
14 
16 class GameInstance : public ScriptInstance {
17 public:
18  GameInstance();
19 
24  void Initialize(class GameInfo *info);
25 
26  int GetSetting(const std::string &name) override;
27  ScriptInfo *FindLibrary(const std::string &library, int version) override;
28 
29 private:
30  void RegisterAPI() override;
31  void Died() override;
33  void LoadDummyScript() override {}
34 };
35 
36 #endif /* GAME_INSTANCE_HPP */
ScriptInstance
Runtime information about a script like a pointer to the squirrel vm and the current state.
Definition: script_instance.hpp:25
GameInstance::FindLibrary
ScriptInfo * FindLibrary(const std::string &library, int version) override
Find a library.
Definition: game_instance.cpp:61
GameInstance::Initialize
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
Definition: game_instance.cpp:34
CommandCallbackData
void CommandCallbackData(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
Define a callback function for the client, after the command is finished.
Definition: command_type.h:500
GameInstance::RegisterAPI
void RegisterAPI() override
Register all API functions to the VM.
Definition: game_instance.cpp:44
GameInstance::Died
void Died() override
Tell the script it died.
Definition: game_instance.cpp:66
GameInstance
Runtime information about a game script like a pointer to the squirrel vm and the current state.
Definition: game_instance.hpp:16
GameInstance::GetDoCommandCallback
CommandCallbackData * GetDoCommandCallback() override
Get the callback handling DoCommands in case of networking.
Definition: game_instance.cpp:100
GameInstance::LoadDummyScript
void LoadDummyScript() override
Load the dummy script.
Definition: game_instance.hpp:33
GameInfo
All static information from an Game like name, version, etc.
Definition: game_info.hpp:16
GameInstance::GetSetting
int GetSetting(const std::string &name) override
Get the value of a setting of the current instance.
Definition: game_instance.cpp:56
ScriptInfo
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30