Fix #8316: Make sort industries by production and transported with a cargo filter...
[openttd-github.git] / src / ai / ai_info.hpp
blob8f236e09ab7a32206bf4e22df9172d2c1cef1c4f
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 */
8 /** @file ai_info.hpp AIInfo keeps track of all information of an AI, like Author, Description, ... */
10 #ifndef AI_INFO_HPP
11 #define AI_INFO_HPP
13 #include "../script/script_info.hpp"
15 /** All static information from an AI like name, version, etc. */
16 class AIInfo : public ScriptInfo {
17 public:
18 AIInfo();
19 ~AIInfo();
21 /**
22 * Register the functions of this class.
24 static void RegisterAPI(Squirrel *engine);
26 /**
27 * Create an AI, using this AIInfo as start-template.
29 static SQInteger Constructor(HSQUIRRELVM vm);
31 /**
32 * Create a dummy-AI.
34 static SQInteger DummyConstructor(HSQUIRRELVM vm);
36 /**
37 * Check if we can start this AI.
39 bool CanLoadFromVersion(int version) const;
41 /**
42 * Use this AI as a random AI.
44 bool UseAsRandomAI() const { return this->use_as_random; }
46 /**
47 * Get the API version this AI is written for.
49 const char *GetAPIVersion() const { return this->api_version; }
51 private:
52 int min_loadable_version; ///< The AI can load savegame data if the version is equal or greater than this.
53 bool use_as_random; ///< Should this AI be used when the user wants a "random AI"?
54 const char *api_version; ///< API version used by this AI.
57 /** All static information from an AI library like name, version, etc. */
58 class AILibrary : public ScriptInfo {
59 public:
60 AILibrary() : ScriptInfo(), category(nullptr) {};
61 ~AILibrary();
63 /**
64 * Register the functions of this class.
66 static void RegisterAPI(Squirrel *engine);
68 /**
69 * Create an AI, using this AIInfo as start-template.
71 static SQInteger Constructor(HSQUIRRELVM vm);
73 /**
74 * Get the category this library is in.
76 const char *GetCategory() const { return this->category; }
78 private:
79 const char *category; ///< The category this library is in.
82 #endif /* AI_INFO_HPP */