Range-limit value passed to PlayerSAO::set{HP|Breath} (#8264)
authorANAND <ClobberXD@gmail.com>
Sat, 27 Apr 2019 10:45:20 +0000 (16:15 +0530)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Sat, 27 Apr 2019 10:45:20 +0000 (12:45 +0200)
src/content_sao.cpp

index f0d7fbf5d6e73eeab647e8ae738ea4f6db5dccf2..7acf03684c7171689db2443cc295bfbe15fe7418 100644 (file)
@@ -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);