# ai_info.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_info.hpp 18418 2009-12-06 20:22:21Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef AI_INFO
    00013 #define AI_INFO
    00014
    00015 #include <list>
    00016 #include "../core/smallmap_type.hpp"
    00017 #include "../script/script_info.hpp"
    00018
    00019 enum AIConfigFlags {
    00020   AICONFIG_NONE    = 0x0,
    00021   AICONFIG_RANDOM  = 0x1,
    00022   AICONFIG_BOOLEAN = 0x2,
    00023 };
    00024
    00025 typedef SmallMap<int, char *> LabelMapping;
    00026
    00027 struct AIConfigItem {
    00028   const char *name;
    00029   const char *description;
    00030   int min_value;
    00031   int max_value;
    00032   int custom_value;
    00033   int easy_value;
    00034   int medium_value;
    00035   int hard_value;
    00036   int random_deviation;
    00037   int step_size;
    00038   AIConfigFlags flags;
    00039   LabelMapping *labels;
    00040 };
    00041
    00042 extern AIConfigItem _start_date_config;
    00043
    00044 typedef std::list<AIConfigItem> AIConfigItemList;
    00045
    00046 class AIFileInfo : public ScriptFileInfo {
    00047 public:
    00051   static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info);
    00052
    00053 protected:
    00054   class AIScanner *base;
    00055 };
    00056
    00057 class AIInfo : public AIFileInfo {
    00058 public:
    00059   static const char *GetClassName() { return "AIInfo"; }
    00060
    00061   AIInfo();
    00062   ~AIInfo();
    00063
    00067   static SQInteger Constructor(HSQUIRRELVM vm);
    00068   static SQInteger DummyConstructor(HSQUIRRELVM vm);
    00069
    00073   bool GetSettings();
    00074
    00078   const AIConfigItemList *GetConfigList() const;
    00079
    00083   const AIConfigItem *GetConfigItem(const char *name) const;
    00084
    00088   bool CanLoadFromVersion(int version) const;
    00089
    00093   SQInteger AddSetting(HSQUIRRELVM vm);
    00094
    00098   SQInteger AddLabels(HSQUIRRELVM vm);
    00099
    00103   int GetSettingDefaultValue(const char *name) const;
    00104
    00108   bool UseAsRandomAI() const { return this->use_as_random; }
    00109
    00113   const char *GetAPIVersion() const { return this->api_version; }
    00114
    00115 private:
    00116   AIConfigItemList config_list;
    00117   int min_loadable_version;
    00118   bool use_as_random;
    00119   const char *api_version;
    00120 };
    00121
    00122 class AILibrary : public AIFileInfo {
    00123 public:
    00124   AILibrary() : AIFileInfo(), category(NULL) {};
    00125   ~AILibrary();
    00126
    00130   static SQInteger Constructor(HSQUIRRELVM vm);
    00131
    00132   static SQInteger Import(HSQUIRRELVM vm);
    00133
    00137   const char *GetCategory() const { return this->category; }
    00138
    00139 private:
    00140   const char *category;
    00141 };
    00142
    00143 #endif /* AI_INFO */