Merge pull request #6816 from mattsc/fix_segfault_attack
Fix seg fault when weapon is removed during attack
This commit is contained in:
commit
a6bf253c73
1 changed files with 10 additions and 0 deletions
|
@ -1221,6 +1221,16 @@ bool attack::perform_hit(bool attacker_turn, statistics::attack_context& stats)
|
|||
}
|
||||
|
||||
--attacker.n_attacks_;
|
||||
|
||||
// If an event removed a unit's weapon, set number of remaining attacks to zero
|
||||
// for that unit, but let the other unit continue
|
||||
if (attacker_stats->weapon == nullptr){
|
||||
attacker.n_attacks_ = 0;
|
||||
}
|
||||
if (defender_stats->weapon == nullptr){
|
||||
defender.n_attacks_ = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue