ai_info.hpp

Go to the documentation of this file.
00001 /* $Id$ */
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_HPP
00013 #define AI_INFO_HPP
00014 
00015 #ifdef ENABLE_AI
00016 
00017 #include <list>
00018 #include "../core/smallmap_type.hpp"
00019 #include "../script/script_info.hpp"
00020 
00022 enum AIConfigFlags {
00023   AICONFIG_NONE    = 0x0, 
00024   AICONFIG_RANDOM  = 0x1, 
00025   AICONFIG_BOOLEAN = 0x2, 
00026   AICONFIG_INGAME  = 0x4, 
00027 };
00028 
00029 typedef SmallMap<int, char *> LabelMapping; 
00030 
00032 struct AIConfigItem {
00033   const char *name;        
00034   const char *description; 
00035   int min_value;           
00036   int max_value;           
00037   int custom_value;        
00038   int easy_value;          
00039   int medium_value;        
00040   int hard_value;          
00041   int random_deviation;    
00042   int step_size;           
00043   AIConfigFlags flags;     
00044   LabelMapping *labels;    
00045 };
00046 
00047 extern AIConfigItem _start_date_config;
00048 
00049 typedef std::list<AIConfigItem> AIConfigItemList; 
00050 
00052 class AIFileInfo : public ScriptFileInfo {
00053 public:
00057   static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info);
00058 
00059 protected:
00060   class AIScanner *base; 
00061 };
00062 
00064 class AIInfo : public AIFileInfo {
00065 public:
00066   static const char *GetClassName() { return "AIInfo"; }
00067 
00068   AIInfo();
00069   ~AIInfo();
00070 
00074   static SQInteger Constructor(HSQUIRRELVM vm);
00075 
00079   static SQInteger DummyConstructor(HSQUIRRELVM vm);
00080 
00084   bool GetSettings();
00085 
00089   const AIConfigItemList *GetConfigList() const;
00090 
00094   const AIConfigItem *GetConfigItem(const char *name) const;
00095 
00099   bool CanLoadFromVersion(int version) const;
00100 
00104   SQInteger AddSetting(HSQUIRRELVM vm);
00105 
00109   SQInteger AddLabels(HSQUIRRELVM vm);
00110 
00114   int GetSettingDefaultValue(const char *name) const;
00115 
00119   bool UseAsRandomAI() const { return this->use_as_random; }
00120 
00124   const char *GetAPIVersion() const { return this->api_version; }
00125 
00126 private:
00127   AIConfigItemList config_list; 
00128   int min_loadable_version;     
00129   bool use_as_random;           
00130   const char *api_version;      
00131 };
00132 
00134 class AILibrary : public AIFileInfo {
00135 public:
00136   AILibrary() : AIFileInfo(), category(NULL) {};
00137   ~AILibrary();
00138 
00142   static SQInteger Constructor(HSQUIRRELVM vm);
00143 
00149   static SQInteger Import(HSQUIRRELVM vm);
00150 
00154   const char *GetCategory() const { return this->category; }
00155 
00156 private:
00157   const char *category; 
00158 };
00159 
00160 #endif /* ENABLE_AI */
00161 #endif /* AI_INFO_HPP */

Generated on Wed Apr 13 00:47:44 2011 for OpenTTD by  doxygen 1.6.1