Fix: CmdSetAutoReplace didn't validate group type and engine type match (#9950)
[openttd-github.git] / src / ai / ai_scanner.hpp
blob4faee9c62f9bba522a916b1de36058482986bb48
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_scanner.hpp declarations of the class for AI scanner */
10 #ifndef AI_SCANNER_HPP
11 #define AI_SCANNER_HPP
13 #include "../script/script_scanner.hpp"
15 class AIScannerInfo : public ScriptScanner {
16 public:
17 AIScannerInfo();
18 ~AIScannerInfo();
20 void Initialize() override;
22 /**
23 * Select a random AI.
24 * @return A random AI from the pool.
26 class AIInfo *SelectRandomAI() const;
28 /**
29 * Check if we have an AI by name and version available in our list.
30 * @param nameParam The name of the AI.
31 * @param versionParam The version of the AI, or -1 if you want the latest.
32 * @param force_exact_match Only match name+version, never latest.
33 * @return nullptr if no match found, otherwise the AI that matched.
35 class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
37 /**
38 * Set the Dummy AI.
40 void SetDummyAI(class AIInfo *info);
42 protected:
43 void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
44 const char *GetFileName() const override { return PATHSEP "info.nut"; }
45 Subdirectory GetDirectory() const override { return AI_DIR; }
46 const char *GetScannerName() const override { return "AIs"; }
47 void RegisterAPI(class Squirrel *engine) override;
49 private:
50 AIInfo *info_dummy; ///< The dummy AI.
53 class AIScannerLibrary : public ScriptScanner {
54 public:
55 void Initialize() override;
57 /**
58 * Find a library in the pool.
59 * @param library The library name to find.
60 * @param version The version the library should have.
61 * @return The library if found, nullptr otherwise.
63 class AILibrary *FindLibrary(const char *library, int version);
65 protected:
66 void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
67 const char *GetFileName() const override { return PATHSEP "library.nut"; }
68 Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
69 const char *GetScannerName() const override { return "AI Libraries"; }
70 void RegisterAPI(class Squirrel *engine) override;
73 #endif /* AI_SCANNER_HPP */