mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Send Player HP when setHP (or a setHP caller) is called instead of looping and testing the state change.
This commit is contained in:
parent
056e8f7839
commit
64ff966bae
6 changed files with 54 additions and 42 deletions
|
@ -718,7 +718,6 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
|
|||
// public
|
||||
m_moved(false),
|
||||
m_inventory_not_sent(false),
|
||||
m_hp_not_sent(false),
|
||||
m_breath_not_sent(false),
|
||||
m_wielded_item_not_sent(false),
|
||||
m_physics_override_speed(1),
|
||||
|
@ -1081,27 +1080,18 @@ void PlayerSAO::setHP(s16 hp)
|
|||
{
|
||||
s16 oldhp = m_player->hp;
|
||||
|
||||
if(hp < 0)
|
||||
if (hp < 0)
|
||||
hp = 0;
|
||||
else if(hp > PLAYER_MAX_HP)
|
||||
else if (hp > PLAYER_MAX_HP)
|
||||
hp = PLAYER_MAX_HP;
|
||||
|
||||
if(hp < oldhp && g_settings->getBool("enable_damage") == false)
|
||||
{
|
||||
m_hp_not_sent = true; // fix wrong prediction on client
|
||||
return;
|
||||
}
|
||||
|
||||
m_player->hp = hp;
|
||||
|
||||
if(hp != oldhp) {
|
||||
m_hp_not_sent = true;
|
||||
if(oldhp > hp)
|
||||
m_damage += oldhp - hp;
|
||||
}
|
||||
if (oldhp > hp)
|
||||
m_damage += (oldhp - hp);
|
||||
|
||||
// Update properties on death
|
||||
if((hp == 0) != (oldhp == 0))
|
||||
if ((hp == 0) != (oldhp == 0))
|
||||
m_properties_sent = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue