Skip to content

Commit c4578ae

Browse files
ClobberXDsfan5
authored andcommittedApr 29, 2019
PlayerSAO::setHP - Don't call on_hpchange callbacks if HP hasn't changed
1 parent ad8d68c commit c4578ae

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

Diff for: ‎src/content_sao.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1340,11 +1340,13 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
13401340

13411341
hp = rangelim(hp, 0, m_prop.hp_max);
13421342

1343-
s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
1344-
if (hp_change == 0)
1345-
return;
1343+
if (oldhp != hp) {
1344+
s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
1345+
if (hp_change == 0)
1346+
return;
13461347

1347-
hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
1348+
hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
1349+
}
13481350

13491351
if (hp < oldhp && !g_settings->getBool("enable_damage"))
13501352
return;

0 commit comments

Comments
 (0)
Please sign in to comment.