summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/NamespaceSerializer.cpp
diff options
context:
space:
mode:
authorTheHyper45 <dawid.priv@o2.pl>2021-06-20 13:12:12 +0200
committerAlexander Harkness <me@bearbin.net>2022-04-12 01:06:40 +0200
commit5500314fbea50f6200a7e3d045541224e3d9bb78 (patch)
treeb5ae4912c9a054c6a1f862b52b1bf32ccff55f5e /src/WorldStorage/NamespaceSerializer.cpp
parentThe proper style fix (diff)
downloadcuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar.gz
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar.bz2
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar.lz
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar.xz
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.tar.zst
cuberite-5500314fbea50f6200a7e3d045541224e3d9bb78.zip
Diffstat (limited to 'src/WorldStorage/NamespaceSerializer.cpp')
-rw-r--r--src/WorldStorage/NamespaceSerializer.cpp103
1 files changed, 28 insertions, 75 deletions
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp
index 969f9b5de..52a2973a0 100644
--- a/src/WorldStorage/NamespaceSerializer.cpp
+++ b/src/WorldStorage/NamespaceSerializer.cpp
@@ -551,82 +551,35 @@ eMonsterType NamespaceSerializer::ToMonsterType(const std::string_view a_ID)
-std::string_view NamespaceSerializer::Prettify(const eMonsterType a_ID, const bool a_IsTamed)
+AString NamespaceSerializer::Prettify(AString a_Name, const bool a_IsTamed)
{
- switch (a_ID)
+ /**
+ Examples:
+ Input: "wolf", Output: "Wolf"
+ Input: "snow_golem", Output: "Snow Golem"
+ Input: "skeleton_horse", Output: "Skeleton Horse"
+ */
+
+ // 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)
{
- case mtBat: return "Bat";
- case mtBlaze: return "Blaze";
- case mtCat: return "Cat";
- case mtCaveSpider: return "Cave Spider";
- case mtChicken: return "Chicken";
- case mtCod: return "Cod";
- case mtCow: return "Cow";
- case mtCreeper: return "Creeper";
- case mtDolphin: return "Dolphin";
- case mtDonkey: return "Donkey";
- case mtDrowned: return "Drowned";
- case mtElderGuardian: return "Elder Guardian";
- case mtEnderDragon: return "Ender Dragon";
- case mtEnderman: return "Enderman";
- case mtEndermite: return "Endermite";
- case mtEvoker: return "Evoker";
- case mtFox: return "Fox";
- case mtGhast: return "Ghast";
- case mtGiant: return "Giant";
- case mtGuardian: return "Guardian";
- case mtHorse: return "Horse";
- case mtHoglin: return "Hoglin";
- case mtHusk: return "Husk";
- case mtIllusioner: return "Illusioner";
- case mtIronGolem: return "Iron Golem";
- case mtLlama: return "Llama";
- case mtMagmaCube: return "Magma Cube";
- case mtMooshroom: return "Mooshroom";
- case mtMule: return "Mule";
- // 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]".
- case mtOcelot: return (a_IsTamed ? "Cat" : "Ocelot");
- case mtPanda: return "Panda";
- case mtParrot: return "Parrot";
- case mtPhantom: return "Phantom";
- case mtPig: return "Pig";
- case mtPiglin: return "Piglin";
- case mtPiglinBrute: return "Piglin_brute";
- case mtPillager: return "Pillager";
- case mtPolarBear: return "Polar Bear";
- case mtPufferfish: return "Pufferfish";
- case mtRabbit: return "Rabbit";
- case mtRavager: return "Ravager";
- case mtSalmon: return "Salmon";
- case mtSheep: return "Sheep";
- case mtShulker: return "Shulker";
- case mtSilverfish: return "Silverfish";
- case mtSkeleton: return "Skeleton";
- case mtSkeletonHorse: return "Skeleton Horse";
- case mtSlime: return "Slime";
- case mtSnowGolem: return "Snow Golem";
- case mtSpider: return "Spider";
- case mtSquid: return "Squid";
- case mtStray: return "Stray";
- case mtStrider: return "Strider";
- case mtTraderLlama: return "Trader Llama";
- case mtTropicalFish: return "Tropical Fish";
- case mtTurtle: return "Turtle";
- case mtVex: return "Vex";
- case mtVillager: return "Villager";
- case mtVindicator: return "Vindicator";
- case mtWanderingTrader:return "Wandering Trader";
- case mtWitch: return "Witch";
- case mtWither: return "Wither";
- case mtWitherSkeleton: return "Wither Skeleton";
- case mtWolf: return "Wolf";
- case mtZoglin: return "Zoglin";
- case mtZombie: return "Zombie";
- case mtZombieHorse: return "Zombie Horse";
- case mtZombiePigman: return "Zombified Piglin";
- case mtZombieVillager: return "Zombie Villager";
- case mtInvalidType: break;
+ return "Cat";
}
- UNREACHABLE("Tried to save unknown monster type");
+
+ bool NextLetterCapitalized = true;
+ std::for_each(a_Name.begin(), a_Name.end(), [&](char & a_Letter)
+ {
+ if (NextLetterCapitalized)
+ {
+ a_Letter = std::toupper(a_Letter);
+ NextLetterCapitalized = false;
+ }
+ else if (a_Letter == '_')
+ {
+ a_Letter = ' ';
+ NextLetterCapitalized = true;
+ }
+ });
+ return a_Name;
}