diff options
author | Lars Müller <34514239+appgurueu@users.noreply.github.com> | 2022-08-13 16:35:41 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-09-14 13:39:30 +0200 |
commit | 3f3049fdba4a0a38f5c518e0a760b7e632400657 (patch) | |
tree | a571bde4b5dc10036f03bbe05b221aa062d37d6e | |
parent | 41fb7a8a7ebe9db678bb50b125972bb52b04e374 (diff) | |
download | minetest-3f3049fdba4a0a38f5c518e0a760b7e632400657.tar.gz minetest-3f3049fdba4a0a38f5c518e0a760b7e632400657.tar.bz2 minetest-3f3049fdba4a0a38f5c518e0a760b7e632400657.zip |
Check hp_max > 0 for entities (#12667)
-rw-r--r-- | src/script/common/c_content.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 166980025..fafb2edc9 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -196,6 +196,9 @@ void read_object_properties(lua_State *L, int index, int hp_max = 0; if (getintfield(L, -1, "hp_max", hp_max)) { prop->hp_max = (u16)rangelim(hp_max, 0, U16_MAX); + // hp_max = 0 is sometimes used as a hack to keep players dead, only validate for entities + if (prop->hp_max == 0 && sao->getType() != ACTIVEOBJECT_TYPE_PLAYER) + throw LuaError("The hp_max property may not be 0 for entities!"); if (prop->hp_max < sao->getHP()) { PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP_MAX); |