summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-02 17:31:31 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-03 16:06:04 +0100
commit64ff966bae99813229dff6629fd9131a91ba7484 (patch)
treead63765181af40910873520fc45cfe56a1380779 /src/content_sao.cpp
parent056e8f7839d72dfc2e8aa0a68c5d19d7cc30a282 (diff)
downloadminetest-64ff966bae99813229dff6629fd9131a91ba7484.tar.gz
minetest-64ff966bae99813229dff6629fd9131a91ba7484.tar.bz2
minetest-64ff966bae99813229dff6629fd9131a91ba7484.zip
Send Player HP when setHP (or a setHP caller) is called instead of looping and testing the state change.
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 8cb8fa788..835996cc7 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -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;
}