aboutsummaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-08-13 23:06:39 +0200
committerPilzAdam <pilzadam@minetest.net>2013-08-17 01:23:25 +0200
commit787b43b2183262a08726434e2597638ad85bfb72 (patch)
tree1eabaa85cdc0504343aee0a2219d15252a98c9c0 /src/content_sao.cpp
parent3ee80987086a99803f5a812089ae253ab509cb68 (diff)
downloadminetest-787b43b2183262a08726434e2597638ad85bfb72.tar.gz
minetest-787b43b2183262a08726434e2597638ad85bfb72.tar.bz2
minetest-787b43b2183262a08726434e2597638ad85bfb72.zip
Send player damage to all clients and apply [brighten
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 347e88929..9b4ae6100 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -942,6 +942,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
m_player(player_),
m_peer_id(peer_id_),
m_inventory(NULL),
+ m_damage(0),
m_last_good_position(0,0,0),
m_time_from_last_punch(0),
m_nocheat_dig_pos(32767, 32767, 32767),
@@ -1298,14 +1299,6 @@ int PlayerSAO::punch(v3f dir,
setHP(getHP() - hitparams.hp);
- if(hitparams.hp != 0)
- {
- std::string str = gob_cmd_punched(hitparams.hp, getHP());
- // create message and add to list
- ActiveObjectMessage aom(getId(), true, str);
- m_messages_out.push_back(aom);
- }
-
return hitparams.wear;
}
@@ -1318,6 +1311,13 @@ s16 PlayerSAO::getHP() const
return m_player->hp;
}
+s16 PlayerSAO::readDamage()
+{
+ s16 damage = m_damage;
+ m_damage = 0;
+ return damage;
+}
+
void PlayerSAO::setHP(s16 hp)
{
s16 oldhp = m_player->hp;
@@ -1335,19 +1335,15 @@ void PlayerSAO::setHP(s16 hp)
m_player->hp = hp;
- if(hp != oldhp)
+ if(hp != oldhp) {
m_hp_not_sent = true;
+ if(oldhp > hp)
+ m_damage += oldhp - hp;
+ }
- // On death or reincarnation send an active object message
+ // Update properties on death
if((hp == 0) != (oldhp == 0))
- {
- // Will send new is_visible value based on (getHP()!=0)
m_properties_sent = false;
- // Send new HP
- std::string str = gob_cmd_punched(0, getHP());
- ActiveObjectMessage aom(getId(), true, str);
- m_messages_out.push_back(aom);
- }
}
u16 PlayerSAO::getBreath() const