OpenTTD Source: src/ai/ai_info.hpp Source File

OpenTTD Source 1.11.0-RC1

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 ~AIInfo();
20
24 static void RegisterAPI(Squirrel *engine);
25
29 static SQInteger Constructor(HSQUIRRELVM vm);
30
34 static SQInteger DummyConstructor(HSQUIRRELVM vm);
35
39 bool CanLoadFromVersion(int version) const;
40
44 bool UseAsRandomAI() const { return this->use_as_random; }
45
49 const char *GetAPIVersion() const { return this->api_version; }
50
51 private:
52 int min_loadable_version;
53 bool use_as_random;
54 const char *api_version;
55 };
56
58 class AILibrary : public ScriptInfo {
59 public:
60 AILibrary() : ScriptInfo(), category(nullptr) {};
61 ~AILibrary();
62
66 static void RegisterAPI(Squirrel *engine);
67
71 static SQInteger Constructor(HSQUIRRELVM vm);
72
76 const char *GetCategory() const { return this->category; }
77
78 private:
79 const char *category;
80 };
81
82 #endif /* AI_INFO_HPP */
AIInfo::use_as_random
bool use_as_random
Should this AI be used when the user wants a "random AI"?
Definition: ai_info.hpp:53
AILibrary::RegisterAPI
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
Definition: ai_info.cpp:152
ScriptInfo::engine
class Squirrel * engine
Engine used to register for Squirrel.
Definition: script_info.hpp:148
AIInfo::GetAPIVersion
const char * GetAPIVersion() const
Get the API version this AI is written for.
Definition: ai_info.hpp:49
AIInfo::api_version
const char * api_version
API version used by this AI.
Definition: ai_info.hpp:54
AIInfo::UseAsRandomAI
bool UseAsRandomAI() const
Use this AI as a random AI.
Definition: ai_info.hpp:44
ScriptInfo::version
int version
Version of the script.
Definition: script_info.hpp:161
AIInfo::min_loadable_version
int min_loadable_version
The AI can load savegame data if the version is equal or greater than this.
Definition: ai_info.hpp:52
Squirrel
Definition: squirrel.hpp:23
AILibrary
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:58
AILibrary::Constructor
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition: ai_info.cpp:160
AIInfo::Constructor
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition: ai_info.cpp:62
AIInfo::DummyConstructor
static SQInteger DummyConstructor(HSQUIRRELVM vm)
Create a dummy-AI.
Definition: ai_info.cpp:106
AILibrary::GetCategory
const char * GetCategory() const
Get the category this library is in.
Definition: ai_info.hpp:76
AIInfo::RegisterAPI
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
Definition: ai_info.cpp:37
AIInfo
All static information from an AI like name, version, etc.
Definition: ai_info.hpp:16
AIInfo::CanLoadFromVersion
bool CanLoadFromVersion(int version) const
Check if we can start this AI.
Definition: ai_info.cpp:140
ScriptInfo
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30
AILibrary::category
const char * category
The category this library is in.
Definition: ai_info.hpp:79