aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorANAND <ClobberXD@gmail.com>2019-04-27 17:23:36 +0530
committersfan5 <sfan5@live.de>2019-04-29 14:08:34 +0200
commitc4578aefe7dd920668ce77a99387ee3581f47311 (patch)
tree6bdc162177bbf41d99e442828644376d7873276c
parentad8d68c06aa67ba6d9249f583b9cbb9a60fe1e02 (diff)
downloadminetest-c4578aefe7dd920668ce77a99387ee3581f47311.tar.gz
minetest-c4578aefe7dd920668ce77a99387ee3581f47311.tar.bz2
minetest-c4578aefe7dd920668ce77a99387ee3581f47311.zip
PlayerSAO::setHP - Don't call on_hpchange callbacks if HP hasn't changed
-rw-r--r--src/content_sao.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index cefdeb597..84a6615ef 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -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;