Check for unit types found before creating units based on them.

This commit is contained in:
J. Tyne 2013-01-16 03:19:31 +00:00
parent 4bb579c875
commit d09401df2c

View File

@ -768,6 +768,8 @@ private:
const unit_type* att_type = unit_types.find(att);
const unit_type* def_type = unit_types.find(def);
if ( att_type == NULL || def_type == NULL )
return variant();
unit attacker(att_type, 3, false);
unit defender(def_type, 2, false);
@ -777,7 +779,6 @@ private:
temporary_unit_placer def_place(*resources::units, def_loc, defender);
std::pair<double, std::vector<variant> > score = get_battle_score(attacker, defender, att_loc, def_loc);
std::pair<double, std::vector<variant> > score2 = get_battle_score(defender, attacker, def_loc, att_loc);