Skip to content

Commit

Permalink
Revert "Disallow units with negative HP"
Browse files Browse the repository at this point in the history
This reverts commit ef60dea.

@ln-zookeeper pointed out that units with negative HP are documented in
the wiki, and thus disallowing them is an API
change.
  • Loading branch information
jyrkive committed May 28, 2018
1 parent 050bb3f commit 0200487
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
14 changes: 1 addition & 13 deletions src/scripting/lua_unit.cpp
Expand Up @@ -391,6 +391,7 @@ static int impl_unit_set(lua_State *L)
//modify_int_attrib_check_range("side", u.set_side(value), 1, static_cast<int>(teams().size())); TODO: Figure out if this is a good idea, to refer to teams() and make this depend on having a gamestate
modify_int_attrib("side", u.set_side(value));
modify_int_attrib("moves", u.set_movement(value));
modify_int_attrib("hitpoints", u.set_hitpoints(value));
modify_int_attrib("experience", u.set_experience(value));
modify_int_attrib("recall_cost", u.set_recall_cost(value));
modify_int_attrib("attacks_left", u.set_attacks(value));
Expand All @@ -405,19 +406,6 @@ static int impl_unit_set(lua_State *L)

modify_vector_string_attrib("extra_recruit", u.set_recruits(value));
modify_vector_string_attrib("advances_to", u.set_advances_to(value));

if(strcmp(m, "hitpoints") == 0) {
int hp = luaL_checkinteger(L, 3);
if(hp >= 0) {
u.set_hitpoints(hp);
return 0;
} else {
std::string err_msg = "invalid target HP: ";
err_msg += std::to_string(hp);
return luaL_argerror(L, 3, err_msg.c_str());
}
}

if(strcmp(m, "alignment") == 0) {
u.set_alignment(lua_check<unit_type::ALIGNMENT>(L, 3));
return 0;
Expand Down
2 changes: 0 additions & 2 deletions src/units/unit.cpp
Expand Up @@ -50,7 +50,6 @@
#include "units/map.hpp" // for unit_map, etc
#include "variable.hpp" // for vconfig, etc
#include "version.hpp"
#include "wml_exception.hpp"

#include "utils/functional.hpp"
#include <boost/dynamic_bitset.hpp>
Expand Down Expand Up @@ -630,7 +629,6 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
}

if(const config::attribute_value* v = cfg.get("hitpoints")) {
VALIDATE(*v > 0, _("Unit with negative HP found"));
hit_points_ = *v;
} else {
hit_points_ = max_hit_points_;
Expand Down

0 comments on commit 0200487

Please sign in to comment.