# ai_config.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_config.hpp 17248 2009-08-21 20:21: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
    00015 #include <map>
    00016 #include "ai_info.hpp"
    00017 #include "../core/string_compare_type.hpp"
    00018
    00019 class AIConfig {
    00020 private:
    00021   typedef std::map<const char *, int, StringCompare> SettingValueList;
    00022
    00023 public:
    00024   AIConfig() :
    00025     name(NULL),
    00026     version(-1),
    00027     info(NULL),
    00028     config_list(NULL)
    00029   {}
    00030   AIConfig(const AIConfig *config);
    00031   ~AIConfig();
    00032
    00038   void ChangeAI(const char *name, int version = -1);
    00039
    00046   bool ResetInfo();
    00047
    00051   class AIInfo *GetInfo();
    00052
    00056   const AIConfigItemList *GetConfigList();
    00057
    00061   static AIConfig *GetConfig(CompanyID company, bool forceNewgameSetting = false);
    00062
    00070   int GetSetting(const char *name);
    00071
    00075   void SetSetting(const char *name, int value);
    00076
    00080   void ResetSettings();
    00081
    00085   void AddRandomDeviation();
    00086
    00090   bool HasAI();
    00091
    00095   const char *GetName();
    00096
    00100   int GetVersion();
    00101
    00106   void StringToSettings(const char *value);
    00107
    00112   void SettingsToString(char *string, size_t size);
    00113
    00114 private:
    00115   const char *name;
    00116   int version;
    00117   class AIInfo *info;
    00118   SettingValueList settings;
    00119   AIConfigItemList *config_list;
    00120 };
    00121
    00122 #endif /* AI_CONFIG_HPP */