OpenTTD Source 20250522-master-g467f832c2f
ai_scanner.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_SCANNER_HPP
11#define AI_SCANNER_HPP
12
13#include "../script/script_scanner.hpp"
14
16public:
19
20 void Initialize() override;
21
26 class AIInfo *SelectRandomAI() const;
27
35 class AIInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
36
40 void SetDummyAI(class AIInfo *info);
41
42protected:
43 std::string GetScriptName(ScriptInfo &info) override;
44 std::string_view GetFileName() const override { return PATHSEP "info.nut"; }
45 Subdirectory GetDirectory() const override { return AI_DIR; }
46 std::string_view GetScannerName() const override { return "AIs"; }
47 void RegisterAPI(class Squirrel &engine) override;
48
49private:
51};
52
54public:
55 void Initialize() override;
56
63 class AILibrary *FindLibrary(const std::string &library, int version);
64
65protected:
66 std::string GetScriptName(ScriptInfo &info) override;
67 std::string_view GetFileName() const override { return PATHSEP "library.nut"; }
68 Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
69 std::string_view GetScannerName() const override { return "AI Libraries"; }
70 void RegisterAPI(class Squirrel &engine) override;
71};
72
73#endif /* AI_SCANNER_HPP */
All static information from an AI like name, version, etc.
Definition ai_info.hpp:16
All static information from an AI library like name, version, etc.
Definition ai_info.hpp:60
class AIInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Check if we have an AI by name and version available in our list.
std::string_view GetScannerName() const override
Get the type of the script, in plural.
Subdirectory GetDirectory() const override
Get the directory to scan in.
void RegisterAPI(class Squirrel &engine) override
Register the API for this ScriptInfo.
AIInfo * info_dummy
The dummy AI.
class AIInfo * SelectRandomAI() const
Select a random AI.
std::string GetScriptName(ScriptInfo &info) override
Get the script name how to store the script in memory.
std::string_view GetFileName() const override
Get the filename to scan for this type of script.
void SetDummyAI(class AIInfo *info)
Set the Dummy AI.
void RegisterAPI(class Squirrel &engine) override
Register the API for this ScriptInfo.
std::string GetScriptName(ScriptInfo &info) override
Get the script name how to store the script in memory.
class AILibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
Subdirectory GetDirectory() const override
Get the directory to scan in.
std::string_view GetScannerName() const override
Get the type of the script, in plural.
std::string_view GetFileName() const override
Get the filename to scan for this type of script.
All static information from an Script like name, version, etc.
Scanner to help finding scripts.
class Squirrel * engine
The engine we're scanning with.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition fileio_type.h:87
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
Definition fileio_type.h:99
@ AI_DIR
Subdirectory for all AI files.
Definition fileio_type.h:98