ai_config.hpp

Go to the documentation of this file.
00001 /* $Id: ai_config.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_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 
00021 class AIConfig {
00022 private:
00023   typedef std::map<const char *, int, StringCompare> SettingValueList;
00024 
00025 public:
00026   AIConfig() :
00027     name(NULL),
00028     version(-1),
00029     info(NULL),
00030     config_list(NULL),
00031     is_random_ai(false)
00032   {}
00033   AIConfig(const AIConfig *config);
00034   ~AIConfig();
00035 
00044   void ChangeAI(const char *name, int version = -1, bool force_exact_match = false, bool is_random = false);
00045 
00052   bool ResetInfo();
00053 
00057   class AIInfo *GetInfo() const;
00058 
00062   const AIConfigItemList *GetConfigList();
00063 
00067   static AIConfig *GetConfig(CompanyID company, bool forceNewgameSetting = false);
00068 
00076   int GetSetting(const char *name) const;
00077 
00081   void SetSetting(const char *name, int value);
00082 
00086   void ResetSettings();
00087 
00091   void AddRandomDeviation();
00092 
00096   bool HasAI() const;
00097 
00101   bool IsRandomAI() const;
00102 
00106   const char *GetName() const;
00107 
00111   int GetVersion() const;
00112 
00117   void StringToSettings(const char *value);
00118 
00123   void SettingsToString(char *string, size_t size) const;
00124 
00125 private:
00126   const char *name;
00127   int version;
00128   class AIInfo *info;
00129   SettingValueList settings;
00130   AIConfigItemList *config_list;
00131   bool is_random_ai;
00132 };
00133 
00134 #endif /* ENABLE_AI */
00135 #endif /* AI_CONFIG_HPP */

Generated on Wed Mar 3 23:32:18 2010 for OpenTTD by  doxygen 1.6.1