Mercurial > hg > openttd
annotate src/ai/ai_scanner.hpp @ 18518:928151e04253 draft
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
author | truebrain <truebrain@openttd.org> |
---|---|
date | Tue, 29 Nov 2011 23:21:52 +0000 |
parents | ae9def3e6284 |
children | 9e9c2bc58ba0 |
rev | line source |
---|---|
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
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/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11385
diff
changeset
|
9 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
10 /** @file ai_scanner.hpp declarations of the class for AI scanner */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
11 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
12 #ifndef AI_SCANNER_HPP |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
13 #define AI_SCANNER_HPP |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
14 |
11385
ea7a290c75a5
(svn r15736) -Codechange: Split AIScanner/AIFileInfo to the more generic classes ScriptScanner/ScriptFileInfo.
yexo <yexo@openttd.org>
parents:
11366
diff
changeset
|
15 #include "../script/script_scanner.hpp" |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
16 |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
17 class AIScannerInfo : public ScriptScanner { |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
18 public: |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
19 AIScannerInfo(); |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
20 ~AIScannerInfo(); |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
21 |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
22 /* virtual */ void Initialize(const char *name); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
23 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
24 /** |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
25 * Select a random AI. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
26 * @return A random AI from the pool. |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
27 */ |
14197
06812674f0fc
(svn r18747) -Codechange: add some constness to the AI code
rubidium <rubidium@openttd.org>
parents:
13194
diff
changeset
|
28 class AIInfo *SelectRandomAI() const; |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
29 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
30 /** |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
31 * Check if we have an AI by name and version available in our list. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
32 * @param nameParam The name of the AI. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
33 * @param versionParam The versionof the AI, or -1 if you want the latest. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
34 * @param force_exact_match Only match name+version, never latest. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
35 * @return NULL if no match found, otherwise the AI that matched. |
16967
77f2b8f0869d
(svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents:
16524
diff
changeset
|
36 */ |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
37 class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match); |
10840
f0752f5361f0
(svn r15175) -Feature: Add the option to select the AIs to start in a new game and configure them via the gui.
Yexo <Yexo@openttd.org>
parents:
10793
diff
changeset
|
38 |
f0752f5361f0
(svn r15175) -Feature: Add the option to select the AIs to start in a new game and configure them via the gui.
Yexo <Yexo@openttd.org>
parents:
10793
diff
changeset
|
39 /** |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
40 * Set the Dummy AI. |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
41 */ |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
42 void SetDummyAI(class AIInfo *info); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
43 |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
44 protected: |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
45 /* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len); |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
46 /* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
47 /* virtual */ Subdirectory GetDirectory() const { return AI_DIR; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
48 /* virtual */ const char *GetScannerName() const { return "AIs"; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
49 /* virtual */ void RegisterAPI(class Squirrel *engine); |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
50 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
51 private: |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
52 AIInfo *info_dummy; ///< The dummy AI. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
53 }; |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
54 |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
55 class AIScannerLibrary : public ScriptScanner { |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
56 public: |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
57 /** |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
58 * Find a library in the pool. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
59 * @param library The library name to find. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
60 * @param version The version the library should have. |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
61 * @return The library if found, NULL otherwise. |
16524
b341f0626692
(svn r21250) -Fix [FS#3952]: Rescanning AIs didn't "forget" removed AIs
rubidium <rubidium@openttd.org>
parents:
15608
diff
changeset
|
62 */ |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
63 class AILibrary *FindLibrary(const char *library, int version); |
16524
b341f0626692
(svn r21250) -Fix [FS#3952]: Rescanning AIs didn't "forget" removed AIs
rubidium <rubidium@openttd.org>
parents:
15608
diff
changeset
|
64 |
18518
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
65 protected: |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
66 /* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len); |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
67 /* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
68 /* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
69 /* virtual */ const char *GetScannerName() const { return "AI Libraries"; } |
928151e04253
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
truebrain <truebrain@openttd.org>
parents:
18451
diff
changeset
|
70 /* virtual */ void RegisterAPI(class Squirrel *engine); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
71 }; |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
72 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
diff
changeset
|
73 #endif /* AI_SCANNER_HPP */ |