27 #define ERR_NG LOG_STREAM(err, log_engine)
28 #define WRN_NG LOG_STREAM(warn, log_engine)
29 #define LOG_NG LOG_STREAM(info, log_engine)
30 #define DBG_NG LOG_STREAM(debug, log_engine)
45 mp_countdown_init_time(0),
46 mp_countdown_reservoir_time(0),
47 mp_countdown_turn_bonus(0),
48 mp_countdown_action_bonus(0),
50 use_map_settings(false),
51 random_start_time(false),
54 allow_observers(true),
55 private_replay(false),
64 : name(cfg[
"scenario"].str())
66 , hash(cfg[
"hash"].str())
67 , mp_era_name(cfg[
"mp_era_name"].str())
68 , mp_scenario(cfg[
"mp_scenario"].str())
69 , mp_scenario_name(cfg[
"mp_scenario_name"].str())
70 , mp_campaign(cfg[
"mp_campaign"].str())
72 , num_turns(cfg[
"mp_num_turns"].to_int())
73 , village_gold(cfg[
"mp_village_gold"].to_int())
75 , xp_modifier(cfg[
"experience_modifier"].to_int(100))
76 , mp_countdown_init_time(cfg[
"mp_countdown_init_time"].to_int())
77 , mp_countdown_reservoir_time(cfg[
"mp_countdown_reservoir_time"].to_int())
78 , mp_countdown_turn_bonus(cfg[
"mp_countdown_turn_bonus"].to_int())
79 , mp_countdown_action_bonus(cfg[
"mp_countdown_action_bonus"].to_int())
80 , mp_countdown(cfg[
"mp_countdown"].to_bool())
81 , use_map_settings(cfg[
"mp_use_map_settings"].to_bool())
82 , random_start_time(cfg[
"mp_random_start_time"].to_bool())
83 , fog_game(cfg[
"mp_fog"].to_bool())
84 , shroud_game(cfg[
"mp_shroud"].to_bool())
85 , allow_observers(cfg[
"observer"].to_bool())
86 , private_replay(cfg[
"private_replay"].to_bool())
87 , shuffle_sides(cfg[
"shuffle_sides"].to_bool())
90 , options(cfg.child_or_empty(
"options"))
94 if (!a[
"id"].empty()) {
104 cfg[
"scenario"] =
name;
144 , required(cfg[
"required"].to_bool(false))
147 if (!cfg[
"version"].empty()) {
148 version = cfg[
"version"].str();
150 if (!cfg[
"min_version"].empty()) {
153 for(
const auto& child : cfg.
child_range(
"content")) {
154 content.emplace_back(
addon_content{ child[
"id"].str(), child[
"name"].str(), child[
"type"].str() });
160 cfg[
"version"] = *version;
163 cfg[
"min_version"] = *min_version;
167 cfg[
"required"] = required;
168 for(
const auto& item : content) {
171 c[
"name"] = item.name;
172 c[
"type"] = item.type;
177 if (cfg[
"id"].empty()) {
178 WRN_NG <<
"Tried to add add-on metadata to a game, missing mandatory id field... skipping.\n" << cfg.
debug();
201 for(
const auto& item : new_data.
content) {
206 ERR_NG <<
"Addon version data mismatch! Not all local WML has same version of the addon: '" << cfg[
"id"].str() <<
"'.";
219 addons.emplace(cfg[
"id"].str(), new_data);
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
std::string debug() const
config & add_child(config_key_type key)
Standard logging facilities (interface).
static lg::log_domain log_engine("engine")
std::map< std::string, std::string > map_split(const std::string &val, char major, char minor, int flags, const std::string &default_value)
Splits a string based on two separators into a map.
std::string join_map(const T &v, const std::string &major=",", const std::string &minor=":")
std::string::const_iterator iterator
void write(config &) const
std::vector< addon_content > content
utils::optional< version_info > min_version
addon_version_info(const config &)
utils::optional< version_info > version
random_faction_mode::type mode
void update_addon_requirements(const config &addon_cfg)
Takes a config with addon metadata (id, name, version, min_version) and adds it as a requirement for ...
std::chrono::seconds mp_countdown_reservoir_time
std::string mp_scenario_name
std::chrono::seconds mp_countdown_action_bonus
std::chrono::seconds mp_countdown_turn_bonus
std::map< std::string, std::string > side_users
std::chrono::seconds mp_countdown_init_time
std::map< std::string, addon_version_info > addons
the key is the addon_id
The base template for associating string values with enum values.
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.