Fix halo sometimes remaining when a unit is downgraded or killed

This is the rest of pull request #2028. Credit for these changes belongs to
@newfrenchy83.

I initially rejected these changes, but
* for advancement, @Arcanister pointed out that {ADVANCE_UNIT} is sometimes
  used to *downgrade* an unit. Thus, it's plausible that "advancing" can
  remove a halo.
* for killing, @newfrenchy83 said that it's *possible* (although unlikely)
  that the halo can remain. Even though I haven't reproduced the problem
  myself, it's good to ensure that the whiteboard releases its reference to
  the unit anyway.

Pull request #2028 has now been fully merged.
This commit is contained in:
Jyrki Vesterinen 2017-10-04 20:15:40 +03:00
parent 523f61c6e7
commit 9118330a30
2 changed files with 2 additions and 0 deletions

View file

@ -353,6 +353,7 @@ void advance_unit(map_location loc, const advancement_option &advance_to, bool f
LOG_CF << "Added '" << new_unit->type_id() << "' to the encountered units.\n";
}
resources::gameboard->units().erase(loc);
resources::whiteboard->on_kill_unit();
u = resources::gameboard->units().insert(new_unit).first;
// Update fog/shroud.

View file

@ -1289,6 +1289,7 @@ void attack::unit_killed(unit_info& attacker,
}
units_.erase(defender.loc_);
resources::whiteboard->on_kill_unit();
// Plague units make new units on the target hex.
if(attacker.valid() && attacker_stats->plagues && !drain_killed) {