aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorANAND <ClobberXD@gmail.com>2019-04-27 16:15:20 +0530
committerSmallJoker <SmallJoker@users.noreply.github.com>2019-04-27 12:45:20 +0200
commitd0f0ceaf6672d737b071b7dbc37fa3f3e964125b (patch)
tree9f7754a306fb1d1ca5cdb3d1b27365e1366b93c9 /src
parent695d9edcd423319038c2fec1e6503dd5282928c4 (diff)
downloadminetest-d0f0ceaf6672d737b071b7dbc37fa3f3e964125b.tar.gz
minetest-d0f0ceaf6672d737b071b7dbc37fa3f3e964125b.tar.bz2
minetest-d0f0ceaf6672d737b071b7dbc37fa3f3e964125b.zip
Range-limit value passed to PlayerSAO::set{HP|Breath} (#8264)
Diffstat (limited to 'src')
-rw-r--r--src/content_sao.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index f0d7fbf5d..7acf03684 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -1334,6 +1334,8 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
{
s32 oldhp = m_hp;
+ hp = rangelim(hp, 0, m_prop.hp_max);
+
s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
if (hp_change == 0)
return;
@@ -1355,7 +1357,7 @@ void PlayerSAO::setBreath(const u16 breath, bool send)
if (m_player && breath != m_breath)
m_player->setDirty(true);
- m_breath = MYMIN(breath, m_prop.breath_max);
+ m_breath = rangelim(breath, 0, m_prop.breath_max);
if (send)
m_env->getGameDef()->SendPlayerBreath(this);