Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/wesnoth/wesnoth
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 21, 2014
2 parents 5e9d356 + 7418818 commit c7c69f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/carryover.cpp
Expand Up @@ -131,8 +131,9 @@ const std::string carryover::to_string(){
return side;
}

void carryover::set_gold(int gold){
void carryover::set_gold(int gold, bool add){
gold_ = gold;
add_ = add;
}

void carryover::to_config(config& cfg){
Expand Down Expand Up @@ -171,11 +172,12 @@ carryover_info::carryover_info(const config& cfg, bool from_snpashot)
if(from_snpashot)
{
//adjust gold
int finishing_bonus_per_turn = cfg["map_villages_num"] * side["village_gold"] + side["income"];
//base_income is side["income"] + game_config::base_income;
int finishing_bonus_per_turn = cfg["map_villages_num"] * side["village_gold"] + side["income"] + game_config::base_income;
int finishing_bonus = std::max(0, finishing_bonus_per_turn * turns_left);
if(end_level_.gold_bonus)
{
carryover_sides_.back().set_gold(div100rounded((finishing_bonus + side["gold"]) * end_level_.carryover_percentage));
carryover_sides_.back().set_gold(div100rounded((finishing_bonus + side["gold"]) * end_level_.carryover_percentage), end_level_.carryover_add);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/carryover.hpp
Expand Up @@ -38,7 +38,9 @@ class carryover{
void initialize_team(config& side_cfg);
const std::string to_string();
void to_config(config& cfg);
void set_gold(int gold);
/// @param gold sets the gold of the team, always overwrites current gold.
/// @param add whether the gold should be added to the next scenario gold.
void set_gold(int gold, bool add);
private:
bool add_;
std::string color_;
Expand Down
4 changes: 1 addition & 3 deletions src/game_events/action_wml.cpp
Expand Up @@ -1000,8 +1000,6 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
boxes, but display the error message only if side_for is
used for an inactive side. */
bool side_for_show = has_input;
if (has_input && side_for_raw != str_cast(resources::controller->current_side()))
lg::wml_error << "[message]side_for= cannot query any user input out of turn.\n";

std::vector<std::string> side_for =
utils::split(side_for_raw, ',', utils::STRIP_SPACES | utils::REMOVE_EMPTY);
Expand Down Expand Up @@ -1082,7 +1080,7 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
}
else
{
config choice = mp_sync::get_user_choice("input", msg);
config choice = mp_sync::get_user_choice("input", msg, cfg["side_for"].to_int(0));
option_chosen = choice["value"];
text_input_result = choice["text"].str();
}
Expand Down
3 changes: 3 additions & 0 deletions src/playcampaign.cpp
Expand Up @@ -91,6 +91,9 @@ static void show_carryover_message(saved_game& gamestate, playsingle_controller&
gamestate.classification().campaign_type == game_classification::TEST))
{
gamemap map = playcontroller.get_map_const();
// NOTE: this function uses game_config::village_income/game_config::base_income which is teh same for all teams
// the function that actualy does the carryover (carryover.cpp) uses team.base_income() / team.village_gold() since 1.13
// which can be different for every team
int finishing_bonus_per_turn =
map.villages().size() * game_config::village_income +
game_config::base_income;
Expand Down

0 comments on commit c7c69f2

Please sign in to comment.