23 #define LOG_NG LOG_STREAM(info, log_engine)
24 #define ERR_NG LOG_STREAM(err, log_engine)
27 : add_(!side[
"carryover_add"].empty() ? side[
"carryover_add"].to_bool() : side[
"add"].to_bool())
28 , current_player_(side[
"current_player"])
29 , gold_(!side[
"carryover_gold"].empty() ? side[
"carryover_gold"].to_int() : side[
"gold"].to_int())
31 , previous_recruits_(side.has_attribute(
"recruit") ?
utils::
split_set(side[
"recruit"].str()) :
utils::
split_set(side[
"previous_recruits"].str()))
33 , save_id_(side[
"save_id"])
34 , variables_(side.child_or_empty(
"variables"))
47 int cfg_gold = side_cfg[
"gold"].to_int();
49 if(side_cfg[
"gold"].empty()) {
51 side_cfg[
"gold"] = cfg_gold;
55 side_cfg[
"gold"] = cfg_gold +
gold_;
57 else if(
gold_ > cfg_gold){
58 side_cfg[
"gold"] =
gold_;
68 side_cfg[
"previous_recruits"] = can_recruit_str;
85 return can_recruit_str;
89 std::string side =
"";
92 side.append(u_cfg[
"name"].str() +
", ");
100 side[
"gold"] =
gold_;
112 , variables_(cfg.child_or_empty(
"variables"))
115 , next_scenario_(cfg[
"next_scenario"])
116 , next_underlying_unit_id_(cfg[
"next_underlying_unit_id"].to_int(0))
120 if(side[
"lost"].to_bool(
false) || !side[
"persistent"].to_bool(
true) || side[
"save_id"].empty())
124 ERR_NG <<
"found invalid carryover data in saved game, lost='" << side[
"lost"] <<
"' persistent='" << side[
"persistent"] <<
"' save_id='" << side[
"save_id"] <<
"'";
132 if(item[
"persistent"].to_bool(
true)) {
150 if (it->get_save_id() ==
id) {
169 if(side_cfg[
"save_id"].empty()){
170 side_cfg[
"save_id"] = side_cfg[
"id"];
179 iside->transfer_all_gold_to(side_cfg);
180 iside->transfer_all_recalls_to(side_cfg);
181 iside->transfer_all_recruits_to(side_cfg);
196 if(!
level.has_attribute(
"next_underlying_unit_id"))
205 if ( seed_value.
empty() ) {
210 if(!
level.has_child(
"menu_item")){
213 level.add_child(
"menu_item").swap(item);
246 if(side.get_save_id() == save_id){
static const int default_gold_qty
static lg::log_domain log_engine("engine")
void add_side(const config &cfg)
std::string next_scenario_
the scenario coming next (for campaigns)
std::vector< carryover > & get_all_sides()
void merge_old_carryover(const carryover_info &old_carryover)
std::vector< carryover > carryover_sides_
void transfer_to(config &level)
void transfer_all_to(config &side_cfg)
int next_underlying_unit_id_
carryover * get_side(const std::string &save_id)
std::vector< config > wml_menu_items_
void remove_side(const std::string &id)
void transfer_all_gold_to(config &side_cfg)
std::vector< config > recall_list_
std::string current_player_
const std::string & get_save_id() const
void transfer_all_recruits_to(config &side_cfg)
void transfer_all_recalls_to(config &side_cfg)
std::string get_recruits(bool erase=false)
const std::string to_string()
void to_config(config &cfg)
std::set< std::string > previous_recruits_
Variant for storing WML attributes.
bool empty() const
Tests for an attribute that either was never set or was set to "".
A config object defines a single node in a WML file, with access to child nodes.
void remove_attributes(T... keys)
bool has_attribute(config_key_type key) const
child_itors child_range(config_key_type key)
config & child_or_add(config_key_type key)
Returns a reference to the first child with the given key.
config & add_child(config_key_type key)
std::string get_random_seed_str() const
unsigned int get_random_calls() const
Definitions for the interface to Wesnoth Markup Language (WML).
Standard logging facilities (interface).
std::string & erase(std::string &str, const std::size_t start, const std::size_t len)
Erases a portion of a UTF-8 string.
std::set< std::string > split_set(std::string_view s, char sep, const int flags)
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::string::const_iterator iterator
save_id_equals(const std::string &val)
bool operator()(carryover &v2) const