OpenTTD: src/script/script_scanner.hpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

script_scanner.hpp
Go to the documentation of this file.
1 /* $Id: script_scanner.hpp 26617 2014-05-25 19:53:46Z rubidium $ */
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 SCRIPT_SCANNER_HPP
13 #define SCRIPT_SCANNER_HPP
14
15 #include <map>
16 #include "../fileio_func.h"
17 #include "../core/string_compare_type.hpp"
18
19 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
20
22 class ScriptScanner : public FileScanner {
23 public:
24 ScriptScanner();
25 virtual ~ScriptScanner();
26
27 virtual void Initialize() = 0;
28
32 class Squirrel *GetEngine() { return this->engine; }
33
37 const char *GetMainScript() { return this->main_script; }
38
42 const char *GetTarFile() { return this->tar_file; }
43
47 const ScriptInfoList *GetInfoList() { return &this->info_list; }
48
52 const ScriptInfoList *GetUniqueInfoList() { return &this->info_single_list; }
53
57 void RegisterScript(class ScriptInfo *info);
58
62 char *GetConsoleList(char *p, const char *last, bool newest_only) const;
63
70 bool HasScript(const struct ContentInfo *ci, bool md5sum);
71
78 const char *FindMainScript(const ContentInfo *ci, bool md5sum);
79
80 /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
81
85 void RescanDir();
86
87 protected:
88 class Squirrel *engine;
89 char *main_script;
90 char *tar_file;
91
92 ScriptInfoList info_list;
93 ScriptInfoList info_single_list;
94
99 void Initialize(const char *name);
100
104 virtual void GetScriptName(ScriptInfo *info, char *name, const char *last) = 0;
105
109 virtual const char *GetFileName() const = 0;
110
114 virtual Subdirectory GetDirectory() const = 0;
115
119 virtual void RegisterAPI(class Squirrel *engine) = 0;
120
124 virtual const char *GetScannerName() const = 0;
125
129 void Reset();
130
134 void ResetEngine();
135 };
136
137 #endif /* SCRIPT_SCANNER_HPP */