Skip to content

Commit

Permalink
Allow modifying dead units in more event handlers
Browse files Browse the repository at this point in the history
Namely attacker_hits, attacker_misses, defender_hits and defender_misses.
  • Loading branch information
jyrkive committed May 16, 2018
1 parent e0beff6 commit 9110e49
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/actions/attack.cpp
Expand Up @@ -1199,17 +1199,24 @@ bool attack::perform_hit(bool attacker_turn, statistics::attack_context& stats)
OOS_error_ = true;
}

if(dies) {
// Will be reset in unit_killed() later.
unit::dying_unit_loc = defender.loc_;
}

if(hits) {
try {
fire_event(attacker_turn ? "attacker_hits" : "defender_hits");
} catch(const attack_end_exception&) {
unit::dying_unit_loc = map_location::null_location();
refresh_bc();
return false;
}
} else {
try {
fire_event(attacker_turn ? "attacker_misses" : "defender_misses");
} catch(const attack_end_exception&) {
unit::dying_unit_loc = map_location::null_location();
refresh_bc();
return false;
}
Expand Down

0 comments on commit 9110e49

Please sign in to comment.