PlayerSAO::setHP - Don't call on_hpchange callbacks if HP hasn't changed
authorANAND <ClobberXD@gmail.com>
Sat, 27 Apr 2019 11:53:36 +0000 (17:23 +0530)
committersfan5 <sfan5@live.de>
Mon, 29 Apr 2019 12:08:34 +0000 (14:08 +0200)
src/content_sao.cpp

index cefdeb597e74610bba502d3288703ff9ce0bc0c4..84a6615ef16a602dd5b7f38135829d5200dcd631 100644 (file)
@@ -1340,11 +1340,13 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
 
        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;
+       if (oldhp != hp) {
+               s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
+               if (hp_change == 0)
+                       return;
 
-       hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
+               hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
+       }
 
        if (hp < oldhp && !g_settings->getBool("enable_damage"))
                return;