Use the new Player::isDead function when it's the case
authorLoic Blot <loic.blot@unix-experience.fr>
Fri, 13 Mar 2015 07:57:19 +0000 (08:57 +0100)
committerLoic Blot <loic.blot@unix-experience.fr>
Fri, 13 Mar 2015 07:57:58 +0000 (08:57 +0100)
src/environment.cpp
src/network/packethandlers/server.cpp
src/server.cpp

index f75e7a0b78fe2606909312876a1eb60377f18d57..953fa2860d6ace5ad4757be50dd28a2fd09aafb6 100644 (file)
@@ -2563,9 +2563,11 @@ void ClientEnvironment::damageLocalPlayer(u8 damage, bool handle_hp)
        LocalPlayer *lplayer = getLocalPlayer();
        assert(lplayer);
        
-       if(handle_hp){
-               if (lplayer->hp == 0) // Don't damage a dead player
+       if(handle_hp) {
+               // Don't damage a dead player
+               if (lplayer->isDead()) 
                        return;
+
                if(lplayer->hp > damage)
                        lplayer->hp -= damage;
                else
index b188bb931ac3be6da049411e5a22671aac3d5813..537858e5259d05bc2690a2ba52fbe9779a240370 100644 (file)
@@ -556,7 +556,9 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
        }
 
        // If player is dead we don't care of this packet
-       if (player->hp == 0) {
+       if (player->isDead()) {
+               verbosestream << "TOSERVER_PLAYERPOS: " << player->getName()
+                       << " is dead. Ignoring packet";
                return;
        }
 
@@ -921,6 +923,8 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
         * He is dead !
         */
        if (player->isDead()) {
+               verbosestream << "TOSERVER_BREATH: " << player->getName()
+                       << " is dead. Ignoring packet";
                return;
        }
 
@@ -1051,7 +1055,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
                return;
        }
 
-       if (player->hp != 0 || !g_settings->getBool("enable_damage"))
+       if (!player->isDead() || !g_settings->getBool("enable_damage"))
                return;
 
        RespawnPlayer(pkt->getPeerId());
@@ -1108,9 +1112,9 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
                return;
        }
 
-       if (player->hp == 0) {
+       if (player->isDead()) {
                verbosestream << "TOSERVER_INTERACT: " << player->getName()
-                       << " tried to interact, but is dead!" << std::endl;
+                       << " is dead. Ignoring packet";
                return;
        }
 
index 1e2c445f7e21b66bf8b65f9f25d94502266441a1..a21d12e6a0f3be7de0175d748047a52acc7a3328 100644 (file)
@@ -1106,7 +1106,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
        SendPlayerBreath(peer_id);
 
        // Show death screen if necessary
-       if(player->hp == 0)
+       if(player->isDead())
                SendDeathscreen(peer_id, false, v3f(0,0,0));
 
        // Note things in chat if not in simple singleplayer mode