OpenTTD
ai_scanner.hpp
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef AI_SCANNER_HPP
13 #define AI_SCANNER_HPP
14 
15 #include "../script/script_scanner.hpp"
16 
17 class AIScannerInfo : public ScriptScanner {
18 public:
19  AIScannerInfo();
20  ~AIScannerInfo();
21 
22  void Initialize() override;
23 
28  class AIInfo *SelectRandomAI() const;
29 
37  class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
38 
42  void SetDummyAI(class AIInfo *info);
43 
44 protected:
45  void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
46  const char *GetFileName() const override { return PATHSEP "info.nut"; }
47  Subdirectory GetDirectory() const override { return AI_DIR; }
48  const char *GetScannerName() const override { return "AIs"; }
49  void RegisterAPI(class Squirrel *engine) override;
50 
51 private:
53 };
54 
56 public:
57  void Initialize() override;
58 
65  class AILibrary *FindLibrary(const char *library, int version);
66 
67 protected:
68  void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
69  const char *GetFileName() const override { return PATHSEP "library.nut"; }
70  Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
71  const char *GetScannerName() const override { return "AI Libraries"; }
72  void RegisterAPI(class Squirrel *engine) override;
73 };
74 
75 #endif /* AI_SCANNER_HPP */
int version
Version of the script.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:46
void SetDummyAI(class AIInfo *info)
Set the Dummy AI.
Definition: ai_scanner.cpp:43
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:71
AIInfo * info_dummy
The dummy AI.
Definition: ai_scanner.hpp:52
Scanner to help finding scripts.
All static information from an Script like name, version, etc.
Definition: script_info.hpp:32
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: ai_scanner.cpp:58
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:47
All static information from an AI library like name, version, etc.
Definition: ai_info.hpp:60
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:97
const char * name
Full name of the script.
Subdirectory for all AI libraries.
Definition: fileio_type.h:122
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: ai_scanner.hpp:69
All static information from an AI like name, version, etc.
Definition: ai_info.hpp:18
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: ai_scanner.hpp:48
Subdirectory for all AI files.
Definition: fileio_type.h:121
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: ai_scanner.hpp:70
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:53
class AIInfo * SelectRandomAI() const
Select a random AI.
Definition: ai_scanner.cpp:63
class Squirrel * engine
The engine we&#39;re scanning with.