Skip to content

Commit

Permalink
Range-limit value passed to PlayerSAO::set{HP|Breath} (#8264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClobberXD authored and SmallJoker committed Apr 27, 2019
1 parent 695d9ed commit d0f0cea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/content_sao.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit d0f0cea

Please sign in to comment.