Fix bug #14540...

..."debug-generated units with HP-modifying traits don't have full HP".

Probably also fix an old similar bug with unit created by "plague".
Unify these creation calls and give full MP to unit spawned by ":create".
This commit is contained in:
Ali El Gariani 2009-10-19 22:20:40 +00:00
parent e66c2152cf
commit 69884081ea
3 changed files with 12 additions and 4 deletions

View File

@ -1263,6 +1263,7 @@ bool attack::perform_hit(bool attacker_turn, statistics::attack_context &stats)
unit newunit(&units_, &reanimitor->second,
attacker.get_unit().side(), true, unit_race::MALE);
newunit.set_attacks(0);
newunit.set_movement(0);
// Apply variation
if (undead_variation != "null")
{

View File

@ -1404,13 +1404,12 @@ void menu_handler::create_unit_2(mouse_handler& mousehandler)
}
unit chosen(&units_, &ut, 1, true, gender, "");
chosen.new_turn();
//FIXME: the generate name option seems useless now, remove it
if(!generate_name)
chosen.set_name("");
chosen.new_turn();
const map_location& loc = mousehandler.get_last_hex();
units_.replace(loc, chosen);
@ -3264,8 +3263,11 @@ void console_handler::do_create() {
}
menu_handler_.units_.erase(loc);
menu_handler_.units_.add(loc,
unit(&menu_handler_.units_, &i->second, 1, true));
unit created(&menu_handler_.units_, &i->second, 1, true);
created.new_turn();
menu_handler_.units_.add(loc, created);
menu_handler_.gui_->invalidate(loc);
menu_handler_.gui_->invalidate_unit();
} else {

View File

@ -437,6 +437,11 @@ unit::unit(unit_map *unitmap, const unit_type *t, int side,
apply_modifications();
set_underlying_id();
// fill those after traits and modifs to have correct max
movement_ = max_movement_;
hit_points_ = max_hit_points_;
attacks_left_ = max_attacks_;
/**
* @todo Test whether the calls above modify these values if not they can
* removed, since already set in the initialization list.