diff --git a/src/whiteboard/recall.cpp b/src/whiteboard/recall.cpp index 328867cc631e..ccf1ca28bbec 100644 --- a/src/whiteboard/recall.cpp +++ b/src/whiteboard/recall.cpp @@ -139,11 +139,6 @@ void recall::apply_temp_modifier(unit_map& unit_map) std::vector& recalls = resources::teams->at(team_index()).recall_list(); std::vector::iterator it = find_if_matches_id(recalls, temp_unit_->id()); assert(it != recalls.end()); - recalls.erase(it); - - // Temporarily insert unit into unit_map - //unit map takes ownership of temp_unit - unit_map.insert(temp_unit_.release()); //Add cost to money spent on recruits. int cost = resources::teams->at(team_index()).recall_cost(); @@ -151,6 +146,12 @@ void recall::apply_temp_modifier(unit_map& unit_map) cost = it->recall_cost(); } + recalls.erase(it); + + // Temporarily insert unit into unit_map + //unit map takes ownership of temp_unit + unit_map.insert(temp_unit_.release()); + resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(cost); // Update gold in top bar resources::screen->invalidate_game_status();