25 #define LOG_NG LOG_STREAM(info, log_engine) 26 #define ERR_NG LOG_STREAM(err, log_engine) 29 : add_(!side[
"carryover_add"].empty() ? side[
"carryover_add"].to_bool() : side[
"add"].to_bool())
30 , current_player_(side[
"current_player"])
31 , gold_(!side[
"carryover_gold"].empty() ? side[
"carryover_gold"].to_int() : side[
"gold"].to_int())
35 , save_id_(side[
"save_id"])
36 , variables_(side.child_or_empty(
"variables"))
64 int cfg_gold = side_cfg[
"gold"].to_int();
66 if(side_cfg[
"gold"].empty()) {
68 side_cfg[
"gold"] = cfg_gold;
72 side_cfg[
"gold"] = cfg_gold +
gold_;
74 else if(
gold_ > cfg_gold){
75 side_cfg[
"gold"] =
gold_;
85 side_cfg[
"previous_recruits"] = can_recruit_str;
102 return can_recruit_str;
106 std::string side =
"";
109 side.append(u_cfg[
"name"].str() +
", ");
117 side[
"gold"] =
gold_;
132 , next_scenario_(cfg[
"next_scenario"])
133 , next_underlying_unit_id_(cfg[
"next_underlying_unit_id"].to_int(0))
137 if(side[
"lost"].to_bool(
false) || !side[
"persistent"].to_bool(
true) || side[
"save_id"].empty())
141 ERR_NG <<
"found invalid carryover data in saved game, lost='" << side[
"lost"] <<
"' persistent='" << side[
"persistent"] <<
"' save_id='" << side[
"save_id"] <<
"'";
149 if(
item[
"persistent"].to_bool(
true)) {
167 if (it->get_save_id() ==
id) {
186 if(side_cfg[
"save_id"].empty()){
187 side_cfg[
"save_id"] = side_cfg[
"id"];
196 iside->transfer_all_gold_to(side_cfg);
197 iside->transfer_all_recalls_to(side_cfg);
198 iside->transfer_all_recruits_to(side_cfg);
222 if ( seed_value.
empty() ) {
263 if(side.get_save_id() == save_id){
bool empty() const
Tests for an attribute that either was never set or was set to "".
void add_side(const config &cfg)
const std::string & get_save_id() const
void append(const config &cfg)
Append data from another config object to this one.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< carryover > & get_all_sides()
Variant for storing WML attributes.
bool has_attribute(config_key_type key) const
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
void transfer_all_recalls_to(config &side_cfg)
child_itors child_range(config_key_type key)
void remove_attributes(T... keys)
void merge_old_carryover(const carryover_info &old_carryover)
config & child_or_add(config_key_type key)
Returns a reference to the first child with the given key.
void transfer_to(config &level)
Definitions for the interface to Wesnoth Markup Language (WML).
std::string get_random_seed_str() const
std::set< std::string > previous_recruits_
int next_underlying_unit_id_
std::shared_ptr< const unit > unit_const_ptr
void transfer_all_to(config &side_cfg)
This class stores all the data for a single 'side' (in game nomenclature).
std::vector< config > recall_list_
save_id_equals(const std::string &val)
std::vector< config > wml_menu_items_
void erase(const std::string &key)
void transfer_all_gold_to(config &side_cfg)
std::vector< carryover > carryover_sides_
carryover * get_side(const std::string &save_id)
std::string current_player_
std::string next_scenario_
the scenario coming next (for campaigns)
unsigned int get_random_calls() const
const std::string to_string()
std::string id
Text to match against addon_info.tags()
std::string get_recruits(bool erase=false)
void transfer_all_recruits_to(config &side_cfg)
static lg::log_domain log_engine("engine")
config & add_child(config_key_type key)
Standard logging facilities (interface).
void remove_side(const std::string &id)
recall_list_manager & recall_list()
std::set< std::string > set_split(const std::string &val, const char c=',', const int flags=REMOVE_EMPTY|STRIP_SPACES)
Splits a (comma-)separated string into a set of pieces.
void to_config(config &cfg)
static const int default_gold_qty
A config object defines a single node in a WML file, with access to child nodes.
std::string::const_iterator iterator
std::pair< std::string, unsigned > item