summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/ArrowEntity.cpp5
-rw-r--r--src/Entities/Boat.cpp9
-rw-r--r--src/Entities/Entity.cpp5
-rw-r--r--src/Entities/EntityEffect.cpp6
-rw-r--r--src/Entities/HangingEntity.h37
-rw-r--r--src/Entities/Player.cpp53
-rw-r--r--src/Entities/ProjectileEntity.cpp5
7 files changed, 41 insertions, 79 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 2dc329f30..2db0baad6 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -66,10 +66,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
case psInSurvivalOrCreative: return (a_Player.IsGameModeSurvival() || a_Player.IsGameModeCreative());
case psInCreative: return a_Player.IsGameModeCreative();
}
- ASSERT(!"Unhandled pickup state");
- #ifndef __clang__
- return false;
- #endif
+ UNREACHABLE("Unsupported arrow pickup state");
}
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 4021f9ce8..20947dc44 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -207,10 +207,7 @@ AString cBoat::MaterialToString(eMaterial a_Material)
case bmAcacia: return "acacia";
case bmDarkOak: return "dark_oak";
}
- ASSERT(!"Unhandled boat material");
- #ifndef __clang__
- return "oak";
- #endif
+ UNREACHABLE("Unsupported boat material");
}
@@ -264,9 +261,7 @@ cItem cBoat::MaterialToItem(eMaterial a_Material)
case bmAcacia: return cItem(E_ITEM_ACACIA_BOAT);
case bmDarkOak: return cItem(E_ITEM_DARK_OAK_BOAT);
}
- #ifndef __clang__
- return cItem(E_ITEM_BOAT);
- #endif
+ UNREACHABLE("Unsupported boat material");
}
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index c811988bf..707f75cf1 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -640,10 +640,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
return true;
}
}
- ASSERT(!"Invalid damage type!");
- #ifndef __clang__
- return false;
- #endif
+ UNREACHABLE("Unsupported damage type");
}
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index fcb1fdfdb..8f0ecc395 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -217,11 +217,7 @@ std::unique_ptr<cEntityEffect> cEntityEffect::CreateEntityEffect(cEntityEffect::
case cEntityEffect::effWeakness: return cpp14::make_unique<cEntityEffectWeakness >(a_Duration, a_Intensity, a_DistanceModifier);
case cEntityEffect::effWither: return cpp14::make_unique<cEntityEffectWither >(a_Duration, a_Intensity, a_DistanceModifier);
}
-
- ASSERT(!"Unhandled entity effect type!");
- #ifndef __clang__
- return {};
- #endif
+ UNREACHABLE("Unsupported entity effect");
}
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 113d195f9..35b0117b0 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -60,40 +60,34 @@ protected:
/** Converts protocol hanging item facing to eBlockFace values */
inline static eBlockFace ProtocolFaceToBlockFace(Byte a_ProtocolFace)
{
- eBlockFace Dir;
-
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
switch (a_ProtocolFace)
{
- case 0: Dir = BLOCK_FACE_ZP; break;
- case 2: Dir = BLOCK_FACE_ZM; break;
- case 1: Dir = BLOCK_FACE_XM; break;
- case 3: Dir = BLOCK_FACE_XP; break;
+ case 0: return BLOCK_FACE_ZP;
+ case 2: return BLOCK_FACE_ZM;
+ case 1: return BLOCK_FACE_XM;
+ case 3: return BLOCK_FACE_XP;
default:
{
LOGINFO("Invalid facing (%d) in a cHangingEntity, adjusting to BLOCK_FACE_XP.", a_ProtocolFace);
ASSERT(!"Tried to convert a bad facing!");
- Dir = cHangingEntity::ProtocolFaceToBlockFace(3);
+ return cHangingEntity::ProtocolFaceToBlockFace(3);
}
}
-
- return Dir;
}
/** Converts eBlockFace values to protocol hanging item faces */
inline static Byte BlockFaceToProtocolFace(eBlockFace a_BlockFace)
{
- Byte Dir;
-
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
switch (a_BlockFace)
{
- case BLOCK_FACE_ZP: Dir = 0; break;
- case BLOCK_FACE_ZM: Dir = 2; break;
- case BLOCK_FACE_XM: Dir = 1; break;
- case BLOCK_FACE_XP: Dir = 3; break;
+ case BLOCK_FACE_ZP: return 0;
+ case BLOCK_FACE_ZM: return 2;
+ case BLOCK_FACE_XM: return 1;
+ case BLOCK_FACE_XP: return 3;
case BLOCK_FACE_YP:
case BLOCK_FACE_YM:
case BLOCK_FACE_NONE:
@@ -102,19 +96,10 @@ protected:
// LOGINFO("Invalid facing (%d) in a cHangingEntity, adjusting to BLOCK_FACE_XP.", a_BlockFace);
// ASSERT(!"Tried to convert a bad facing!");
- Dir = cHangingEntity::BlockFaceToProtocolFace(BLOCK_FACE_XP);
- break;
+ return cHangingEntity::BlockFaceToProtocolFace(BLOCK_FACE_XP);
}
- #if !defined(__clang__)
- default:
- {
- ASSERT(!"Unknown BLOCK_FACE");
- return 0;
- }
- #endif
}
-
- return Dir;
+ UNREACHABLE("Unsupported block face");
}
}; // tolua_export
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(""))
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 0649e5b95..915475f2a 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -356,10 +356,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkFirework: return "Firework";
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?
}
- ASSERT(!"Unhandled projectile entity kind!");
- #ifndef __clang__
- return "";
- #endif
+ UNREACHABLE("Unsupported projectile kind");
}