ai_info.hpp

Go to the documentation of this file.
00001 /* $Id: ai_info.hpp 19081 2010-02-10 16:24:05Z 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 #ifdef ENABLE_AI
00016 
00017 #include <list>
00018 #include "../core/smallmap_type.hpp"
00019 #include "../script/script_info.hpp"
00020 
00021 enum AIConfigFlags {
00022   AICONFIG_NONE    = 0x0,
00023   AICONFIG_RANDOM  = 0x1, 
00024   AICONFIG_BOOLEAN = 0x2, 
00025   AICONFIG_INGAME  = 0x4, 
00026 };
00027 
00028 typedef SmallMap<int, char *> LabelMapping;
00029 
00030 struct AIConfigItem {
00031   const char *name;        
00032   const char *description; 
00033   int min_value;           
00034   int max_value;           
00035   int custom_value;        
00036   int easy_value;          
00037   int medium_value;        
00038   int hard_value;          
00039   int random_deviation;    
00040   int step_size;           
00041   AIConfigFlags flags;     
00042   LabelMapping *labels;    
00043 };
00044 
00045 extern AIConfigItem _start_date_config;
00046 
00047 typedef std::list<AIConfigItem> AIConfigItemList;
00048 
00049 class AIFileInfo : public ScriptFileInfo {
00050 public:
00054   static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info);
00055 
00056 protected:
00057   class AIScanner *base;
00058 };
00059 
00060 class AIInfo : public AIFileInfo {
00061 public:
00062   static const char *GetClassName() { return "AIInfo"; }
00063 
00064   AIInfo();
00065   ~AIInfo();
00066 
00070   static SQInteger Constructor(HSQUIRRELVM vm);
00071   static SQInteger DummyConstructor(HSQUIRRELVM vm);
00072 
00076   bool GetSettings();
00077 
00081   const AIConfigItemList *GetConfigList() const;
00082 
00086   const AIConfigItem *GetConfigItem(const char *name) const;
00087 
00091   bool CanLoadFromVersion(int version) const;
00092 
00096   SQInteger AddSetting(HSQUIRRELVM vm);
00097 
00101   SQInteger AddLabels(HSQUIRRELVM vm);
00102 
00106   int GetSettingDefaultValue(const char *name) const;
00107 
00111   bool UseAsRandomAI() const { return this->use_as_random; }
00112 
00116   const char *GetAPIVersion() const { return this->api_version; }
00117 
00118 private:
00119   AIConfigItemList config_list;
00120   int min_loadable_version;
00121   bool use_as_random;
00122   const char *api_version;
00123 };
00124 
00125 class AILibrary : public AIFileInfo {
00126 public:
00127   AILibrary() : AIFileInfo(), category(NULL) {};
00128   ~AILibrary();
00129 
00133   static SQInteger Constructor(HSQUIRRELVM vm);
00134 
00135   static SQInteger Import(HSQUIRRELVM vm);
00136 
00140   const char *GetCategory() const { return this->category; }
00141 
00142 private:
00143   const char *category;
00144 };
00145 
00146 #endif /* ENABLE_AI */
00147 #endif /* AI_INFO */

Generated on Sat Nov 20 20:59:00 2010 for OpenTTD by  doxygen 1.6.1