mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
PlayerSAO::setHP - Don't call on_hpchange callbacks if HP hasn't changed
This commit is contained in:
parent
ad8d68c06a
commit
c4578aefe7
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user