summaryrefslogtreecommitdiff
path: root/src/ai/ai_scanner.hpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-12 17:11:45 +0000
committertruebrain <truebrain@openttd.org>2009-01-12 17:11:45 +0000
commitc2406cd42d481a697602b430111a9e59af61660f (patch)
treeced1a262eb143ad6e64ec02f4a4c89835c0c32fd /src/ai/ai_scanner.hpp
parentec97e1fd0d6ca942805fa25d94007437bc0ed952 (diff)
downloadopenttd-c2406cd42d481a697602b430111a9e59af61660f.tar.xz
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
NoAI is an API (a framework) to build your own AIs in. See: http://wiki.openttd.org/wiki/index.php/AI:Main_Page With many thanks to: - glx and Rubidium for their syncing, feedback and hard work - Yexo for his feedback, patches, and AIs which tested the system very deep - Morloth for his feedback and patches - TJIP for hosting a challenge which kept NoAI on track - All AI authors for testing our AI API, and all other people who helped in one way or another -Remove: all old AIs and their cheats/hacks
Diffstat (limited to 'src/ai/ai_scanner.hpp')
-rw-r--r--src/ai/ai_scanner.hpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp
new file mode 100644
index 000000000..2801f556a
--- /dev/null
+++ b/src/ai/ai_scanner.hpp
@@ -0,0 +1,102 @@
+/* $Id$ */
+
+/** @file ai_scanner.hpp declarations of the class for AI scanner */
+
+#ifndef AI_SCANNER_HPP
+#define AI_SCANNER_HPP
+
+#include <map>
+
+class AIScanner {
+public:
+ AIScanner();
+ ~AIScanner();
+
+ /**
+ * Import a library inside the Squirrel VM.
+ */
+ bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm, class AIController *controller);
+
+ /**
+ * Register a library to be put in the available list.
+ */
+ void RegisterLibrary(class AILibrary *library);
+
+ /**
+ * Register an AI to be put in the available list.
+ */
+ void RegisterAI(class AIInfo *info);
+
+ void SetDummyAI(class AIInfo *info) { this->info_dummy = info; }
+
+ /**
+ * Remove an AI from the available list.
+ */
+ void UnregisterAI(class AIInfo *info);
+
+ /**
+ * Select a Random AI.
+ */
+ class AIInfo *SelectRandomAI();
+
+ /**
+ * Find an AI by name.
+ */
+ class AIInfo *FindAI(const char *name);
+
+ /**
+ * Get the list of available AIs for the console.
+ */
+ char *GetAIConsoleList(char *p, const char *last);
+
+ /**
+ * Get the list of all registered AIs.
+ */
+ const AIInfoList *GetAIInfoList() { return &this->info_list; }
+
+ /**
+ * Get the engine of the main squirrel handler (it indexes all avialable squirrels).
+ */
+ class Squirrel *GetEngine() { return this->engine; }
+
+ /**
+ * Get the current script the ScanDir is looking at.
+ */
+ const char *GetCurrentScript() { return this->current_script; }
+
+ /**
+ * Get the directory of the current script the ScanDir is looking at.
+ */
+ const char *GetCurrentDirName() { return this->current_dir; }
+
+ /**
+ * Rescan the AI dir for scripts.
+ */
+ void RescanAIDir();
+
+private:
+ typedef std::map<const char *, class AILibrary *, ltstr> AILibraryList;
+
+ /**
+ * Scan the AI dir for scripts.
+ */
+ void ScanAIDir();
+
+ /**
+ * Scan a dir for AIs.
+ * For non-library-scan, if an AI is found, AIInfo is created, and the AI
+ * is registered to the central system.
+ * For library-scan, if a library is found, AILibrary is created, and the
+ * library is registered to the central system.
+ */
+ void ScanDir(const char *dirname, bool library_dir, char *library_depth = NULL);
+
+ AIInfoList info_list;
+ AIInfo *info_dummy;
+ AILibraryList library_list;
+ class Squirrel *engine;
+ char *current_script;
+ char *current_dir;
+};
+
+#endif /* AI_SCANNER_HPP */