ai_config.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
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
00065 bool ResetInfo(bool force_exact_match);
00066
00070 class AIInfo *GetInfo() const;
00071
00075 const AIConfigItemList *GetConfigList();
00076
00081 enum AISettingSource {
00082 AISS_DEFAULT,
00083 AISS_FORCE_NEWGAME,
00084 AISS_FORCE_GAME,
00085 };
00086
00090 static AIConfig *GetConfig(CompanyID company, AISettingSource source = AISS_DEFAULT);
00091
00099 int GetSetting(const char *name) const;
00100
00104 void SetSetting(const char *name, int value);
00105
00109 void ResetSettings();
00110
00114 void AddRandomDeviation();
00115
00119 bool HasAI() const;
00120
00124 bool IsRandomAI() const;
00125
00129 const char *GetName() const;
00130
00134 int GetVersion() const;
00135
00140 void StringToSettings(const char *value);
00141
00146 void SettingsToString(char *string, size_t size) const;
00147
00148 private:
00149 const char *name;
00150 int version;
00151 class AIInfo *info;
00152 SettingValueList settings;
00153 AIConfigItemList *config_list;
00154 bool is_random_ai;
00155 };
00156
00157 #endif
00158 #endif