Fix multiple death messages (#5305)
authorpresstabstart <presstabstart@users.noreply.github.com>
Fri, 7 Apr 2017 03:32:50 +0000 (04:32 +0100)
committerAuke Kok <sofar+github@foo-projects.org>
Fri, 7 Apr 2017 03:32:50 +0000 (20:32 -0700)
Fix multiple death messages (#3565) and damage server logs after death.

src/content_sao.cpp
src/network/serverpackethandler.cpp
src/server.cpp

index 69f80d35619cfb9068430247a877ed417c944e72..ea2a4ebf69cf5af0d01e7bae162fa11578e868fe 100644 (file)
@@ -919,8 +919,8 @@ void PlayerSAO::step(float dtime, bool send_recommended)
                MapNode n = m_env->getMap().getNodeNoEx(p);
                const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n);
                // If node generates drown
-               if (c.drowning > 0) {
-                       if (m_hp > 0 && m_breath > 0)
+               if (c.drowning > 0 && m_hp > 0) {
+                       if (m_breath > 0)
                                setBreath(m_breath - 1);
 
                        // No more breath, damage player
index e0ea4bf83190428c746846995a042c1a7ff940c3..95df6fc4ff39e26671bef2ff6758a82bb5e37325 100644 (file)
@@ -1107,6 +1107,13 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
        }
 
        if (g_settings->getBool("enable_damage")) {
+               if (playerSAO->isDead()) {
+                       verbosestream << "Server::ProcessData(): Info: "
+                               "Ignoring damage as player " << player->getName()
+                               << " is already dead." << std::endl;
+                       return;
+               }
+
                actionstream << player->getName() << " damaged by "
                                << (int)damage << " hp at " << PP(playersao->getBasePosition() / BS)
                                << std::endl;
index 0daa610541dbed1253d253b00f43a5c228f7ffa6..224af47a7c294ffd0e04f16dc54a805ad1d71b23 100644 (file)
@@ -1111,16 +1111,15 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
        // Send inventory
        SendInventory(playersao);
 
-       // Send HP
-       SendPlayerHPOrDie(playersao);
+       // Send HP or death screen
+       if (playersao->isDead())
+               SendDeathscreen(peer_id, false, v3f(0,0,0));
+       else
+               SendPlayerHPOrDie(playersao);
 
        // Send Breath
        SendPlayerBreath(playersao);
 
-       // Show death screen if necessary
-       if (playersao->isDead())
-               SendDeathscreen(peer_id, false, v3f(0,0,0));
-
        // Note things in chat if not in simple singleplayer mode
        if (!m_simple_singleplayer_mode && g_settings->getBool("show_statusline_on_connect")) {
                // Send information about server to player in chat