summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-02-05 00:07:12 +0100
committerGitHub <noreply@github.com>2018-02-05 00:07:12 +0100
commitd3c1c626f569e5aa58085425924cca45927b6199 (patch)
treec65dee850358467c9afebdd37fcd4f6fb95a475a /src/Entities/Player.cpp
parentcChunk and cChunkData: Use vectors for block get and set functions (#4172) (diff)
downloadcuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.gz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.bz2
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.lz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.xz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.zst
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 7b6719f55..b4bf95f5b 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1060,36 +1060,31 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages())
{
- AString DamageText;
- switch (a_TDI.DamageType)
- {
- case dtRangedAttack: DamageText = "was shot"; break;
- case dtLightning: DamageText = "was plasmified by lightining"; break;
- case dtFalling: DamageText = GetRandomProvider().RandBool() ? "fell to death" : "hit the ground too hard"; break;
- case dtDrowning: DamageText = "drowned"; break;
- case dtSuffocating: DamageText = GetRandomProvider().RandBool() ? "git merge'd into a block" : "fused with a block"; break;
- case dtStarving: DamageText = "forgot the importance of food"; break;
- case dtCactusContact: DamageText = "was impaled on a cactus"; break;
- case dtLavaContact: DamageText = "was melted by lava"; break;
- case dtPoisoning: DamageText = "died from septicaemia"; break;
- case dtWithering: DamageText = "is a husk of their former selves"; break;
- case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break;
- case dtFireContact: DamageText = "burnt themselves to death"; break;
- case dtInVoid: DamageText = "somehow fell out of the world"; break;
- case dtPotionOfHarming: DamageText = "was magicked to death"; break;
- case dtEnderPearl: DamageText = "misused an ender pearl"; break;
- case dtAdmin: DamageText = "was administrator'd"; break;
- case dtExplosion: DamageText = "blew up"; break;
- case dtAttack: DamageText = "was attacked by thin air"; break;
- #ifndef __clang__
- default:
+ const AString DamageText = [&]
{
- ASSERT(!"Unknown damage type");
- DamageText = "died, somehow; we've no idea how though";
- break;
- }
- #endif // __clang__
- }
+ switch (a_TDI.DamageType)
+ {
+ case dtRangedAttack: return "was shot";
+ case dtLightning: return "was plasmified by lightining";
+ case dtFalling: return GetRandomProvider().RandBool() ? "fell to death" : "hit the ground too hard";
+ case dtDrowning: return "drowned";
+ case dtSuffocating: return GetRandomProvider().RandBool() ? "git merge'd into a block" : "fused with a block";
+ case dtStarving: return "forgot the importance of food";
+ case dtCactusContact: return "was impaled on a cactus";
+ case dtLavaContact: return "was melted by lava";
+ case dtPoisoning: return "died from septicaemia";
+ case dtWithering: return "is a husk of their former selves";
+ case dtOnFire: return "forgot to stop, drop, and roll";
+ case dtFireContact: return "burnt themselves to death";
+ case dtInVoid: return "somehow fell out of the world";
+ case dtPotionOfHarming: return "was magicked to death";
+ case dtEnderPearl: return "misused an ender pearl";
+ case dtAdmin: return "was administrator'd";
+ case dtExplosion: return "blew up";
+ case dtAttack: return "was attacked by thin air";
+ }
+ UNREACHABLE("Unsupported damage type");
+ }();
AString DeathMessage = Printf("%s %s", GetName().c_str(), DamageText.c_str());
PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
if (DeathMessage != AString(""))