Fix rare crash in AI code

Reported in https://forums.wesnoth.org/viewtopic.php?p=626344#p626344

Regression from commit a3d5b9d603.

The crash occurred when
* the attacker had only one weapon
* the said weapon was disabled, and
    - the defender had no weapons
    - the defender had only one weapon, or
    - all defender's weapons were disabled

(cherry-picked from commit 4d569815d0)
This commit is contained in:
Jyrki Vesterinen 2018-04-23 19:29:19 +03:00
parent 5621fbb643
commit fe19bdaf44

View file

@ -563,6 +563,7 @@ int battle_context::choose_attacker_weapon(const unit& attacker,
attacker, attacker_loc, choices[0], true, defender, defender_loc, def_weapon, units));
if(attacker_stats_->disable) {
attacker_stats_.reset();
return -1;
}