1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-15 09:25:37 +02:00

Fix player HP desync between client and server

This commit is contained in:
savilli
2021-10-12 21:12:49 +03:00
committed by GitHub
parent ecc6f4ba25
commit 6ea558f8ac
3 changed files with 10 additions and 4 deletions

View File

@@ -462,7 +462,7 @@ void PlayerSAO::rightClick(ServerActiveObject *clicker)
m_env->getScriptIface()->on_rightclickplayer(this, clicker);
}
void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason, bool send)
{
if (hp == (s32)m_hp)
return; // Nothing to do
@@ -490,7 +490,8 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
if ((hp == 0) != (oldhp == 0))
m_properties_sent = false;
m_env->getGameDef()->SendPlayerHPOrDie(this, reason);
if (send)
m_env->getGameDef()->SendPlayerHPOrDie(this, reason);
}
void PlayerSAO::setBreath(const u16 breath, bool send)