Revert "Allow modifying dead units in last_breath and die event handlers"

This reverts commit 15446acb2a.
This commit is contained in:
Jyrki Vesterinen 2018-05-28 22:12:22 +03:00
parent 58dca3a884
commit 050bb3fa2c
3 changed files with 1 additions and 19 deletions

View file

@ -1287,8 +1287,6 @@ void attack::unit_killed(unit_info& attacker,
std::string undead_variation = defender.get_unit().undead_variation();
unit::dying_unit_loc = defender.loc_;
fire_event("attack_end");
refresh_bc();
@ -1313,7 +1311,6 @@ void attack::unit_killed(unit_info& attacker,
// WML has invalidated the dying unit, abort.
if(!defender.valid() || defender.get_unit().hitpoints() > 0) {
unit::dying_unit_loc = map_location::null_location();
return;
}
@ -1338,8 +1335,6 @@ void attack::unit_killed(unit_info& attacker,
resources::game_events->pump().fire("die", death_loc, attacker_loc, dat);
refresh_bc();
unit::dying_unit_loc = map_location::null_location();
if(!defender.valid() || defender.get_unit().hitpoints() > 0) {
// WML has invalidated the dying unit, abort
return;

View file

@ -207,8 +207,6 @@ namespace
}
} // end anon namespace
map_location unit::dying_unit_loc;
/**
* Intrusive Pointer interface
*
@ -632,9 +630,7 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
}
if(const config::attribute_value* v = cfg.get("hitpoints")) {
if(loc_ != dying_unit_loc) {
VALIDATE(*v > 0, _("Unit with negative HP found"));
}
VALIDATE(*v > 0, _("Unit with negative HP found"));
hit_points_ = *v;
} else {
hit_points_ = max_hit_points_;

View file

@ -1598,15 +1598,6 @@ public:
void set_appearance_changed(bool value) { appearance_changed_ = value; }
bool appearance_changed() const { return appearance_changed_; }
/**
* The location of the dying unit for the duration of last_breath and die events.
* Null location when neither of those events is running.
* This exists in order to detect at unit creation time whether the WML/Lua code is unstoring a unit
* that was already dead (e.g. as a result of [modify_unit], which is implemented with unstoring
* under the hood). That's the only situation where creating a unit with negative HP is allowed.
*/
static map_location dying_unit_loc;
protected:
mutable long ref_count_; // used by intrusive_ptr