diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Entities/Entity.cpp | 4 | ||||
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.cpp | 28 | ||||
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.h | 3 |
3 files changed, 22 insertions, 13 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 000a7715a..8788a8ce5 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -2365,7 +2365,7 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) } else { - Name = NamespaceSerializer::Prettify(AString(NamespaceSerializer::From(Monster->GetMobType())), Monster->IsTame()); + Name = NamespaceSerializer::PrettifyEntityName(AString(NamespaceSerializer::From(Monster->GetMobType())), Monster->IsTame()); } } else @@ -2431,7 +2431,7 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) } else { - AString KillerName = NamespaceSerializer::Prettify(AString(NamespaceSerializer::From(Monster->GetMobType())), Monster->IsTame()); + AString KillerName = NamespaceSerializer::PrettifyEntityName(AString(NamespaceSerializer::From(Monster->GetMobType())), Monster->IsTame()); DeathMessage = Printf("%s was killed by a %s", Name.c_str(), KillerName.c_str()); } diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp index 910054ff7..fd02fec68 100644 --- a/src/WorldStorage/NamespaceSerializer.cpp +++ b/src/WorldStorage/NamespaceSerializer.cpp @@ -1,7 +1,6 @@ #include "Globals.h" #include "NamespaceSerializer.h" -#include <cctype> @@ -552,17 +551,11 @@ eMonsterType NamespaceSerializer::ToMonsterType(const std::string_view a_ID) -AString NamespaceSerializer::Prettify(AString a_Name, const bool a_IsTamed) +AString NamespaceSerializer::Prettify(AString a_ID) { - // In older vanilla Minecraft version (before 1.14) ocelots and cats were the same mob. - // So after killing a tamed ocelot without a custom name the message will say "Cat was slain by [PlayerName]". - if ((a_Name == "ocelot") && a_IsTamed) - { - return "Cat"; - } bool NextLetterCapitalized = true; - std::for_each(a_Name.begin(), a_Name.end(), [&](char & a_Letter) + std::for_each(a_ID.begin(), a_ID.end(), [&](char & a_Letter) { if (NextLetterCapitalized) { @@ -575,5 +568,20 @@ AString NamespaceSerializer::Prettify(AString a_Name, const bool a_IsTamed) NextLetterCapitalized = true; } }); - return a_Name; + return a_ID; +} + + + + + +AString NamespaceSerializer::PrettifyEntityName(const AString & a_ID, const bool a_IsTamed) +{ + // In older vanilla Minecraft version (before 1.14) ocelots and cats were the same mob. + // So after killing a tamed ocelot without a custom name the message will say "Cat was slain by [PlayerName]". + if ((a_ID == "ocelot") && a_IsTamed) + { + return "Cat"; + } + return Prettify(a_ID); } diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h index 64739a7cd..625d348be 100644 --- a/src/WorldStorage/NamespaceSerializer.h +++ b/src/WorldStorage/NamespaceSerializer.h @@ -25,5 +25,6 @@ namespace NamespaceSerializer std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID); // Examples: Input: "wolf" -> Output: "Wolf", Input: "iron_golem" -> Output: "Iron Golem" - AString Prettify(AString a_Name, const bool a_IsTamed = false); + AString Prettify(AString a_ID); + AString PrettifyEntityName(const AString & a_ID, const bool a_IsTamed = false); } |