OpenTTD Source 20260218-master-g2123fca5ea
ai_info.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
9
10#ifndef AI_INFO_HPP
11#define AI_INFO_HPP
12
14
16class AIInfo : public ScriptInfo {
17public:
19 static constexpr std::string_view ApiVersions[]{ "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14", "15", "16" };
20
21 AIInfo();
22
27 static void RegisterAPI(Squirrel &engine);
28
34 static SQInteger Constructor(HSQUIRRELVM vm);
35
41 static SQInteger DummyConstructor(HSQUIRRELVM vm);
42
48 bool CanLoadFromVersion(int version) const;
49
54 bool UseAsRandomAI() const { return this->use_as_random; }
55
60 const std::string &GetAPIVersion() const { return this->api_version; }
61
62private:
65 std::string api_version;
66};
67
69class AILibrary : public ScriptInfo {
70public:
71 AILibrary() : ScriptInfo() {};
72
77 static void RegisterAPI(Squirrel &engine);
78
84 static SQInteger Constructor(HSQUIRRELVM vm);
85
90 const std::string &GetCategory() const { return this->category; }
91
92private:
93 std::string category;
94};
95
96#endif /* AI_INFO_HPP */
All static information from an AI like name, version, etc.
Definition ai_info.hpp:16
bool CanLoadFromVersion(int version) const
Check if we can start this AI.
Definition ai_info.cpp:122
bool UseAsRandomAI() const
Use this AI as a random AI.
Definition ai_info.hpp:54
const std::string & GetAPIVersion() const
Get the API version this AI is written for.
Definition ai_info.hpp:60
bool use_as_random
Should this AI be used when the user wants a "random AI"?
Definition ai_info.hpp:64
int min_loadable_version
The AI can load savegame data if the version is equal or greater than this.
Definition ai_info.hpp:63
std::string api_version
API version used by this AI.
Definition ai_info.hpp:65
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
Definition ai_info.cpp:33
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition ai_info.cpp:58
static constexpr std::string_view ApiVersions[]
All valid AI API versions, in order.
Definition ai_info.hpp:19
static SQInteger DummyConstructor(HSQUIRRELVM vm)
Create a dummy-AI.
Definition ai_info.cpp:98
const std::string & GetCategory() const
Get the category this library is in.
Definition ai_info.hpp:90
std::string category
The category this library is in.
Definition ai_info.hpp:93
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
Definition ai_info.cpp:129
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition ai_info.cpp:137
All static information from an Script like name, version, etc.
int version
Version of the script.
class Squirrel * engine
Engine used to register for Squirrel.
ScriptInfo keeps track of all information of a script, like Author, Description, ....