OpenTTD Source: src/ai/ai_scanner.hpp Source File

OpenTTD Source 12.2

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 char *nameParam, int versionParam, bool force_exact_match);
36
40 void SetDummyAI(class AIInfo *info);
41
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;
48
49 private:
50 AIInfo *info_dummy;
51 };
52
53 class AIScannerLibrary : public ScriptScanner {
54 public:
55 void Initialize() override;
56
63 class AILibrary *FindLibrary(const char *library, int version);
64
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;
71 };
72
73 #endif /* AI_SCANNER_HPP */
AIScannerLibrary::GetFileName
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:67
ScriptScanner::engine
class Squirrel * engine
The engine we're scanning with.
Definition: script_scanner.hpp:86
AIScannerInfo::GetFileName
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:44
AIScannerLibrary
Definition: ai_scanner.hpp:53
AIScannerLibrary::GetScriptName
void GetScriptName(ScriptInfo *info, char *name, const char *last) override
Get the script name how to store the script in memory.
Definition: ai_scanner.cpp:140
AIScannerInfo::GetDirectory
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:45
AIScannerInfo::FindInfo
class AIInfo * FindInfo(const char *nameParam, int versionParam, bool force_exact_match)
Check if we have an AI by name and version available in our list.
Definition: ai_scanner.cpp:94
ScriptInfo::version
int version
Version of the script.
Definition: script_info.hpp:161
Squirrel
Definition: squirrel.hpp:23
AIScannerLibrary::FindLibrary
class AILibrary * FindLibrary(const char *library, int version)
Find a library in the pool.
Definition: ai_scanner.cpp:151
AI_DIR
@ AI_DIR
Subdirectory for all AI files.
Definition: fileio_type.h:119
AIScannerLibrary::GetDirectory
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:68
AIScannerInfo::info_dummy
AIInfo * info_dummy
The dummy AI.
Definition: ai_scanner.hpp:50
AILibrary
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:58
ScriptScanner
Scanner to help finding scripts.
Definition: script_scanner.hpp:20
AIScannerInfo
Definition: ai_scanner.hpp:15
AIScannerInfo::SetDummyAI
void SetDummyAI(class AIInfo *info)
Set the Dummy AI.
Definition: ai_scanner.cpp:40
AIScannerLibrary::GetScannerName
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:69
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
AI_LIBRARY_DIR
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
Definition: fileio_type.h:120
AIInfo
All static information from an AI like name, version, etc.
Definition: ai_info.hpp:16
AIScannerLibrary::RegisterAPI
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: ai_scanner.cpp:146
AIScannerInfo::GetScriptName
void GetScriptName(ScriptInfo *info, char *name, const char *last) override
Get the script name how to store the script in memory.
Definition: ai_scanner.cpp:50
AIScannerInfo::GetScannerName
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:46
ScriptInfo::name
const char * name
Full name of the script.
Definition: script_info.hpp:156
ScriptInfo
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30
AIScannerInfo::SelectRandomAI
class AIInfo * SelectRandomAI() const
Select a random AI.
Definition: ai_scanner.cpp:60
AIScannerInfo::RegisterAPI
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: ai_scanner.cpp:55