ai_config.hpp

Go to the documentation of this file.
00001 /* $Id: ai_config.hpp 18944 2010-01-29 00:03:31Z 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 
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 
00043   void ChangeAI(const char *name, int version = -1, bool force_exact_match = false, bool is_random = false);
00044 
00051   bool ResetInfo();
00052 
00056   class AIInfo *GetInfo() const;
00057 
00061   const AIConfigItemList *GetConfigList();
00062 
00066   static AIConfig *GetConfig(CompanyID company, bool forceNewgameSetting = false);
00067 
00075   int GetSetting(const char *name) const;
00076 
00080   void SetSetting(const char *name, int value);
00081 
00085   void ResetSettings();
00086 
00090   void AddRandomDeviation();
00091 
00095   bool HasAI() const;
00096 
00100   bool IsRandomAI() const;
00101 
00105   const char *GetName() const;
00106 
00110   int GetVersion() const;
00111 
00116   void StringToSettings(const char *value);
00117 
00122   void SettingsToString(char *string, size_t size) const;
00123 
00124 private:
00125   const char *name;
00126   int version;
00127   class AIInfo *info;
00128   SettingValueList settings;
00129   AIConfigItemList *config_list;
00130   bool is_random_ai;
00131 };
00132 
00133 #endif /* AI_CONFIG_HPP */

Generated on Thu Feb 4 17:20:21 2010 for OpenTTD by  doxygen 1.5.6