OpenTTD Source  20241121-master-g67a0fccfad
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 <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef AI_INFO_HPP
11 #define AI_INFO_HPP
12 
13 #include "../script/script_info.hpp"
14 
16 class AIInfo : public ScriptInfo {
17 public:
18  AIInfo();
19 
23  static void RegisterAPI(Squirrel *engine);
24 
28  static SQInteger Constructor(HSQUIRRELVM vm);
29 
33  static SQInteger DummyConstructor(HSQUIRRELVM vm);
34 
38  bool CanLoadFromVersion(int version) const;
39 
43  bool UseAsRandomAI() const { return this->use_as_random; }
44 
48  const std::string &GetAPIVersion() const { return this->api_version; }
49 
50 private:
53  std::string api_version;
54 };
55 
57 class AILibrary : public ScriptInfo {
58 public:
59  AILibrary() : ScriptInfo() {};
60 
64  static void RegisterAPI(Squirrel *engine);
65 
69  static SQInteger Constructor(HSQUIRRELVM vm);
70 
74  const std::string &GetCategory() const { return this->category; }
75 
76 private:
77  std::string category;
78 };
79 
80 #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:124
bool UseAsRandomAI() const
Use this AI as a random AI.
Definition: ai_info.hpp:43
bool use_as_random
Should this AI be used when the user wants a "random AI"?
Definition: ai_info.hpp:52
int min_loadable_version
The AI can load savegame data if the version is equal or greater than this.
Definition: ai_info.hpp:51
const std::string & GetAPIVersion() const
Get the API version this AI is written for.
Definition: ai_info.hpp:48
std::string api_version
API version used by this AI.
Definition: ai_info.hpp:53
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
Definition: ai_info.cpp:36
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition: ai_info.cpp:61
static SQInteger DummyConstructor(HSQUIRRELVM vm)
Create a dummy-AI.
Definition: ai_info.cpp:100
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:57
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
Definition: ai_info.cpp:131
const std::string & GetCategory() const
Get the category this library is in.
Definition: ai_info.hpp:74
std::string category
The category this library is in.
Definition: ai_info.hpp:77
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition: ai_info.cpp:139
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30
int version
Version of the script.
class Squirrel * engine
Engine used to register for Squirrel.