From c9522fb740200ccef6230cec452c48efb31e5394 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 May 2023 22:05:17 +0200 Subject: Removed all Printf-family functions from StringUtils. Replaced them with fmt::format calls, including changes to the format strings. Also changed the format strings to use FMT_STRING, so that the format is checked compile-time against the arguments. Also fixed code-style violations already present in the code. --- src/Entities/Entity.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c46f9e644..b6204387b 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -2402,9 +2402,9 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) } UNREACHABLE("Unsupported damage type"); }(); - AString DeathMessage = Printf("%s %s", Name.c_str(), DamageText.c_str()); + auto DeathMessage = fmt::format(FMT_STRING("{} {}"), Name, DamageText); PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) + if (!DeathMessage.empty()) { GetWorld()->BroadcastChatDeath(DeathMessage); } @@ -2412,9 +2412,9 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) else if (a_TDI.Attacker->IsPlayer()) { cPlayer * Killer = static_cast(a_TDI.Attacker); - AString DeathMessage = Printf("%s was killed by %s", Name.c_str(), Killer->GetName().c_str()); + auto DeathMessage = fmt::format(FMT_STRING("{0} was killed by {1}"), Name, Killer->GetName()); PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) + if (!DeathMessage.empty()) { GetWorld()->BroadcastChatDeath(DeathMessage); } @@ -2426,16 +2426,16 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) AString DeathMessage; if (Monster->HasCustomName()) { - DeathMessage = Printf("%s was killed by %s", Name.c_str(), Monster->GetCustomName().c_str()); + DeathMessage = fmt::format(FMT_STRING("{0} was killed by {1}"), Name, Monster->GetCustomName()); } else { 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()); + DeathMessage = fmt::format(FMT_STRING("{0} was killed by a {1}"), Name, KillerName); } PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); - if (DeathMessage != AString("")) + if (!DeathMessage.empty()) { GetWorld()->BroadcastChatDeath(DeathMessage); } -- cgit v1.2.3