Permalink
Browse files

Fix invalid vector index (bug #21402)

  • Loading branch information...
1 parent 4a9ca54 commit 3a2c24d2d087770f158d2aafd3411af050221c5c @AI0867 AI0867 committed Jan 3, 2014
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/actions/attack.cpp
View
3 src/actions/attack.cpp
@@ -481,8 +481,9 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
if (choices.size() == 1) {
*defender_weapon = choose_defender_weapon(attacker, defender, choices[0], units,
attacker_loc, defender_loc, prev_def);
+ const attack_type *def_weapon = *defender_weapon >= 0 ? &defender.attacks()[*defender_weapon] : NULL;
attacker_stats_ = new battle_context_unit_stats(attacker, attacker_loc, choices[0],
- true, defender, defender_loc, &defender.attacks()[*defender_weapon], units);
+ true, defender, defender_loc, def_weapon, units);
if (attacker_stats_->disable) {
delete attacker_stats_;
attacker_stats_ = NULL;

0 comments on commit 3a2c24d

Please sign in to comment.