diff options
author | presstabstart <presstabstart@users.noreply.github.com> | 2017-04-07 04:32:50 +0100 |
---|---|---|
committer | Auke Kok <sofar+github@foo-projects.org> | 2017-04-06 20:32:50 -0700 |
commit | 351cc2e79a7d78f7ec97ff9b33e4f0bad4042b19 (patch) | |
tree | c0f1bedcd3ebfaf1d80ebf11fee78ecb85bdd2be /src | |
parent | 63e175dd70898e2ae714a025d1eaee45a453d41c (diff) | |
download | minetest-351cc2e79a7d78f7ec97ff9b33e4f0bad4042b19.tar.gz minetest-351cc2e79a7d78f7ec97ff9b33e4f0bad4042b19.tar.bz2 minetest-351cc2e79a7d78f7ec97ff9b33e4f0bad4042b19.zip |
Fix multiple death messages (#5305)
Fix multiple death messages (#3565) and damage server logs after death.
Diffstat (limited to 'src')
-rw-r--r-- | src/content_sao.cpp | 4 | ||||
-rw-r--r-- | src/network/serverpackethandler.cpp | 7 | ||||
-rw-r--r-- | src/server.cpp | 11 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 69f80d356..ea2a4ebf6 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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 diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index e0ea4bf83..95df6fc4f 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -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; diff --git a/src/server.cpp b/src/server.cpp index 0daa61054..224af47a7 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -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 |