From c729d7abde7773df1bd88ce8d2c064ec5a3ae77f Mon Sep 17 00:00:00 2001 From: NiLSPACE Date: Thu, 11 Mar 2021 22:26:35 +0100 Subject: Fixed some death messages showing up even when they are disabled. (#5153) --- src/Broadcaster.cpp | 5 +++++ src/Entities/Player.cpp | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp index c8d2de615..1e9f9b876 100644 --- a/src/Broadcaster.cpp +++ b/src/Broadcaster.cpp @@ -186,6 +186,11 @@ void cWorld::BroadcastBossBarUpdateHealth(const cEntity & a_Entity, UInt32 a_Uni void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude, eMessageType a_ChatPrefix) { + if ((a_ChatPrefix == mtDeath) && !ShouldBroadcastDeathMessages()) + { + return; + } + ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) { a_Client.SendChat(a_Message, a_ChatPrefix); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e3994e88c..b7ffbc9e4 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -809,7 +809,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) SaveToDisk(); // Save it, yeah the world is a tough place ! cPluginManager * PluginManager = cRoot::Get()->GetPluginManager(); - if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages()) + if (a_TDI.Attacker == nullptr) { const AString DamageText = [&] { @@ -845,10 +845,6 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) GetWorld()->BroadcastChatDeath(DeathMessage); } } - else if (a_TDI.Attacker == nullptr) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough - { - // no-op - } else if (a_TDI.Attacker->IsPlayer()) { cPlayer * Killer = static_cast(a_TDI.Attacker); -- cgit v1.2.3