# ai_scanner.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_scanner.hpp 15716 2009-03-14 23:57:37Z yexo $ */
    00002
    00005 #ifndef AI_SCANNER_HPP
    00006 #define AI_SCANNER_HPP
    00007
    00008 #include "../core/string_compare_type.hpp"
    00009 #include <map>
    00010
    00011 class AIScanner {
    00012 public:
    00013   AIScanner();
    00014   ~AIScanner();
    00015
    00019   bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm, class AIController *controller);
    00020
    00024   void RegisterLibrary(class AILibrary *library);
    00025
    00029   void RegisterAI(class AIInfo *info);
    00030
    00031   void SetDummyAI(class AIInfo *info) { this->info_dummy = info; }
    00032
    00036   class AIInfo *SelectRandomAI();
    00037
    00041   class AIInfo *FindInfo(const char *name, int version);
    00042
    00046   char *GetAIConsoleList(char *p, const char *last);
    00047
    00051   const AIInfoList *GetAIInfoList() { return &this->info_list; }
    00052
    00056   const AIInfoList *GetUniqueAIInfoList() { return &this->info_single_list; }
    00057
    00061   class Squirrel *GetEngine() { return this->engine; }
    00062
    00066   const char *GetMainScript() { return this->main_script; }
    00067
    00071   void RescanAIDir();
    00072
    00073 #if defined(ENABLE_NETWORK)
    00074   bool HasAI(const struct ContentInfo *ci, bool md5sum);
    00075 #endif
    00076 private:
    00077   typedef std::map<const char *, class AILibrary *, StringCompare> AILibraryList;
    00078
    00082   void ScanAIDir();
    00083
    00091   void ScanDir(const char *dirname, bool library_dir);
    00092
    00093   AIInfo *info_dummy;
    00094   AIInfoList info_list;
    00095   AIInfoList info_single_list;
    00096   AILibraryList library_list;
    00097   class Squirrel *engine;
    00098   char main_script[1024];
    00099 };
    00100
    00101 #endif /* AI_SCANNER_HPP */