Merge pull request #6816 from mattsc/fix_segfault_attack

Fix seg fault when weapon is removed during attack
This commit is contained in:
mattsc 2022-07-01 15:47:19 -07:00 committed by GitHub
commit a6bf253c73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}