ai_config.hpp

Go to the documentation of this file.
00001 /* $Id: ai_config.hpp 20285 2010-08-01 19:36:56Z yexo $ */
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_CONFIG_HPP
00013 #define AI_CONFIG_HPP
00014 #ifdef ENABLE_AI
00015 
00016 #include <map>
00017 #include "ai_info.hpp"
00018 #include "../core/string_compare_type.hpp"
00019 #include "../company_type.h"
00020 
00024 class AIConfig {
00025 private:
00027   typedef std::map<const char *, int, StringCompare> SettingValueList;
00028 
00029 public:
00030   AIConfig() :
00031     name(NULL),
00032     version(-1),
00033     info(NULL),
00034     config_list(NULL),
00035     is_random_ai(false)
00036   {}
00037 
00042   AIConfig(const AIConfig *config);
00043 
00045   ~AIConfig();
00046 
00055   void ChangeAI(const char *name, int version = -1, bool force_exact_match = false, bool is_random = false);
00056 
00063   bool ResetInfo();
00064 
00068   class AIInfo *GetInfo() const;
00069 
00073   const AIConfigItemList *GetConfigList();
00074 
00079   enum AISettingSource {
00080     AISS_DEFAULT,       
00081     AISS_FORCE_NEWGAME, 
00082     AISS_FORCE_GAME,    
00083   };
00084 
00088   static AIConfig *GetConfig(CompanyID company, AISettingSource source = AISS_DEFAULT);
00089 
00097   int GetSetting(const char *name) const;
00098 
00102   void SetSetting(const char *name, int value);
00103 
00107   void ResetSettings();
00108 
00112   void AddRandomDeviation();
00113 
00117   bool HasAI() const;
00118 
00122   bool IsRandomAI() const;
00123 
00127   const char *GetName() const;
00128 
00132   int GetVersion() const;
00133 
00138   void StringToSettings(const char *value);
00139 
00144   void SettingsToString(char *string, size_t size) const;
00145 
00146 private:
00147   const char *name;              
00148   int version;                   
00149   class AIInfo *info;            
00150   SettingValueList settings;     
00151   AIConfigItemList *config_list; 
00152   bool is_random_ai;             
00153 };
00154 
00155 #endif /* ENABLE_AI */
00156 #endif /* AI_CONFIG_HPP */

Generated on Sun Jan 9 16:01:50 2011 for OpenTTD by  doxygen 1.6.1