ai_config.hpp

Go to the documentation of this file.
00001 /* $Id: ai_config.hpp 18809 2010-01-15 16:41:15Z 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_CONFIG_HPP
00013 #define AI_CONFIG_HPP
00014 
00015 #include <map>
00016 #include "ai_info.hpp"
00017 #include "../core/string_compare_type.hpp"
00018 #include "../company_type.h"
00019 
00020 class AIConfig {
00021 private:
00022   typedef std::map<const char *, int, StringCompare> SettingValueList;
00023 
00024 public:
00025   AIConfig() :
00026     name(NULL),
00027     version(-1),
00028     info(NULL),
00029     config_list(NULL),
00030     is_random_ai(false)
00031   {}
00032   AIConfig(const AIConfig *config);
00033   ~AIConfig();
00034 
00041   void ChangeAI(const char *name, int version = -1, bool is_random = false);
00042 
00049   bool ResetInfo();
00050 
00054   class AIInfo *GetInfo() const;
00055 
00059   const AIConfigItemList *GetConfigList();
00060 
00064   static AIConfig *GetConfig(CompanyID company, bool forceNewgameSetting = false);
00065 
00073   int GetSetting(const char *name) const;
00074 
00078   void SetSetting(const char *name, int value);
00079 
00083   void ResetSettings();
00084 
00088   void AddRandomDeviation();
00089 
00093   bool HasAI() const;
00094 
00098   bool IsRandomAI() const;
00099 
00103   const char *GetName() const;
00104 
00108   int GetVersion() const;
00109 
00114   void StringToSettings(const char *value);
00115 
00120   void SettingsToString(char *string, size_t size) const;
00121 
00122 private:
00123   const char *name;
00124   int version;
00125   class AIInfo *info;
00126   SettingValueList settings;
00127   AIConfigItemList *config_list;
00128   bool is_random_ai;
00129 };
00130 
00131 #endif /* AI_CONFIG_HPP */

Generated on Wed Jan 20 23:38:33 2010 for OpenTTD by  doxygen 1.5.6