mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-12 02:11:44 +00:00
Don't dereference iterator after invalidating it
Found by coverity.
This commit is contained in:
parent
ae34792417
commit
7df83c22a8
@ -139,11 +139,6 @@ void recall::apply_temp_modifier(unit_map& unit_map)
|
||||
std::vector<unit>& recalls = resources::teams->at(team_index()).recall_list();
|
||||
std::vector<unit>::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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user