OpenTTD Source  20241108-master-g80f628063a
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 
15 class AIScannerInfo : public ScriptScanner {
16 public:
17  AIScannerInfo();
18  ~AIScannerInfo();
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 
42 protected:
43  std::string GetScriptName(ScriptInfo *info) 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;
48 
49 private:
51 };
52 
54 public:
55  void Initialize() override;
56 
63  class AILibrary *FindLibrary(const std::string &library, int version);
64 
65 protected:
66  std::string GetScriptName(ScriptInfo *info) 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;
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:57
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.
Definition: ai_scanner.cpp:95
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:45
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:46
AIInfo * info_dummy
The dummy AI.
Definition: ai_scanner.hpp:50
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:44
class AIInfo * SelectRandomAI() const
Select a random AI.
Definition: ai_scanner.cpp:61
std::string GetScriptName(ScriptInfo *info) override
Get the script name how to store the script in memory.
Definition: ai_scanner.cpp:51
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: ai_scanner.cpp:56
void SetDummyAI(class AIInfo *info)
Set the Dummy AI.
Definition: ai_scanner.cpp:41
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: ai_scanner.cpp:143
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:67
std::string GetScriptName(ScriptInfo *info) override
Get the script name how to store the script in memory.
Definition: ai_scanner.cpp:137
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:69
class AILibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
Definition: ai_scanner.cpp:148
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:68
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30
int version
Version of the script.
std::string name
Full name of the script.
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:115
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
Definition: fileio_type.h:127
@ AI_DIR
Subdirectory for all AI files.
Definition: fileio_type.h:126