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
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
00064
00065
00066 enum AISettingSource {
00067 AISS_DEFAULT,
00068 AISS_FORCE_NEWGAME,
00069 AISS_FORCE_GAME,
00070 };
00071
00075 static AIConfig *GetConfig(CompanyID company, AISettingSource source = AISS_DEFAULT);
00076
00084 int GetSetting(const char *name) const;
00085
00089 void SetSetting(const char *name, int value);
00090
00094 void ResetSettings();
00095
00099 void AddRandomDeviation();
00100
00104 bool HasAI() const;
00105
00109 bool IsRandomAI() const;
00110
00114 const char *GetName() const;
00115
00119 int GetVersion() const;
00120
00125 void StringToSettings(const char *value);
00126
00131 void SettingsToString(char *string, size_t size) const;
00132
00133 private:
00134 const char *name;
00135 int version;
00136 class AIInfo *info;
00137 SettingValueList settings;
00138 AIConfigItemList *config_list;
00139 bool is_random_ai;
00140 };
00141
00142 #endif
00143 #endif