Go to the documentation of this file.
1 /* $Id: ai_info.hpp 23735 2012-01-03 20:26:05Z rubidium $ */
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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 <>.
8  */
12 #ifndef AI_INFO_HPP
13 #define AI_INFO_HPP
15 #include "../script/script_info.hpp"
18 class AIInfo : public ScriptInfo {
19 public:
20  AIInfo();
21  ~AIInfo();
26  static void RegisterAPI(Squirrel *engine);
31  static SQInteger Constructor(HSQUIRRELVM vm);
36  static SQInteger DummyConstructor(HSQUIRRELVM vm);
41  bool CanLoadFromVersion(int version) const;
46  bool UseAsRandomAI() const { return this->use_as_random; }
51  const char *GetAPIVersion() const { return this->api_version; }
53 private:
56  const char *api_version;
57 };
60 class AILibrary : public ScriptInfo {
61 public:
62  AILibrary() : ScriptInfo(), category(NULL) {};
63  ~AILibrary();
68  static void RegisterAPI(Squirrel *engine);
73  static SQInteger Constructor(HSQUIRRELVM vm);
78  const char *GetCategory() const { return this->category; }
80 private:
81  const char *category;
82 };
84 #endif /* AI_INFO_HPP */
bool UseAsRandomAI() const
Use this AI as a random AI.
Definition: ai_info.hpp:46
int version
Version of the script.
bool use_as_random
Should this AI be used when the user wants a "random AI"?
Definition: ai_info.hpp:55
const char * GetAPIVersion() const
Get the API version this AI is written for.
Definition: ai_info.hpp:51
static SQInteger Constructor(HSQUIRRELVM vm)
Create an AI, using this AIInfo as start-template.
Definition: ai_info.cpp:65
const char * api_version
API version used by this AI.
Definition: ai_info.hpp:56
All static information from an Script like name, version, etc.
Definition: script_info.hpp:32
const char * GetCategory() const
Get the category this library is in.
Definition: ai_info.hpp:78
static SQInteger DummyConstructor(HSQUIRRELVM vm)
Create a dummy-AI.
Definition: ai_info.cpp:109
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:60
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
Definition: ai_info.cpp:40
int min_loadable_version
The AI can load savegame data if the version is equal or greater than this.
Definition: ai_info.hpp:54
bool CanLoadFromVersion(int version) const
Check if we can start this AI.
Definition: ai_info.cpp:143
All static information from an AI like name, version, etc.
Definition: ai_info.hpp:18
const char * category
The category this library is in.
Definition: ai_info.hpp:81
class Squirrel * engine
Engine used to register for Squirrel.