# ai_info.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_info.hpp 18478 2009-12-13 00:33:00Z rubidium $ */
    00002
    00005 #ifndef AI_INFO
    00006 #define AI_INFO
    00007
    00008 #include <list>
    00009 #include "../core/smallmap_type.hpp"
    00010 #include "api/ai_object.hpp"
    00011
    00012 enum AIConfigFlags {
    00013   AICONFIG_NONE    = 0x0,
    00014   AICONFIG_RANDOM  = 0x1,
    00015   AICONFIG_BOOLEAN = 0x2,
    00016 };
    00017
    00018 typedef SmallMap<int, char *> LabelMapping;
    00019
    00020 struct AIConfigItem {
    00021   const char *name;
    00022   const char *description;
    00023   int min_value;
    00024   int max_value;
    00025   int custom_value;
    00026   int easy_value;
    00027   int medium_value;
    00028   int hard_value;
    00029   int random_deviation;
    00030   int step_size;
    00031   AIConfigFlags flags;
    00032   LabelMapping *labels;
    00033 };
    00034
    00035 extern AIConfigItem _start_date_config;
    00036
    00037 typedef std::list<AIConfigItem> AIConfigItemList;
    00038
    00039 class AIFileInfo : public AIObject {
    00040 public:
    00041   friend class AIInfo;
    00042   friend class AILibrary;
    00043
    00044   AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL), version(0), url(NULL) {};
    00045   ~AIFileInfo();
    00046
    00050   const char *GetAuthor() const { return this->author; }
    00051
    00055   const char *GetName() const { return this->name; }
    00056
    00060   const char *GetShortName() const { return this->short_name; }
    00061
    00065   const char *GetDescription() const { return this->description; }
    00066
    00070   int GetVersion() const { return this->version; }
    00071
    00075   bool GetSettings();
    00076
    00080   const char *GetDate() const { return this->date; }
    00081
    00085   const char *GetInstanceName() const { return this->instance_name; }
    00086
    00090   const char *GetURL() const { return this->url; }
    00091
    00095   const char *GetMainScript() const { return this->main_script; }
    00096
    00100   bool CheckMethod(const char *name) const;
    00101
    00105   static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info, bool library);
    00106
    00107 private:
    00108   class Squirrel *engine;
    00109   HSQOBJECT *SQ_instance;
    00110   char *main_script;
    00111   class AIScanner *base;
    00112   const char *author;
    00113   const char *name;
    00114   const char *short_name;
    00115   const char *description;
    00116   const char *date;
    00117   const char *instance_name;
    00118   int version;
    00119   const char *url;
    00120 };
    00121
    00122 class AIInfo : public AIFileInfo {
    00123 public:
    00124   static const char *GetClassName() { return "AIInfo"; }
    00125
    00126   AIInfo();
    00127   ~AIInfo();
    00128
    00132   static SQInteger Constructor(HSQUIRRELVM vm);
    00133   static SQInteger DummyConstructor(HSQUIRRELVM vm);
    00134
    00138   const AIConfigItemList *GetConfigList() const;
    00139
    00143   const AIConfigItem *GetConfigItem(const char *name) const;
    00144
    00148   bool CanLoadFromVersion(int version) const;
    00149
    00153   SQInteger AddSetting(HSQUIRRELVM vm);
    00154
    00158   SQInteger AddLabels(HSQUIRRELVM vm);
    00159
    00163   int GetSettingDefaultValue(const char *name) const;
    00164
    00168   bool UseAsRandomAI() const { return this->use_as_random; }
    00169
    00170 private:
    00171   AIConfigItemList config_list;
    00172   int min_loadable_version;
    00173   bool use_as_random;
    00174 };
    00175
    00176 class AILibrary : public AIFileInfo {
    00177 public:
    00178   AILibrary() : AIFileInfo(), category(NULL) {};
    00179   ~AILibrary();
    00180
    00184   static SQInteger Constructor(HSQUIRRELVM vm);
    00185
    00186   static SQInteger Import(HSQUIRRELVM vm);
    00187
    00191   const char *GetCategory() const { return this->category; }
    00192
    00193 private:
    00194   const char *category;
    00195 };
    00196
    00197 #endif /* AI_INFO */