[Bug Fix] Fix Strings::Commify bug with #mystats (#4547)

* Fix a formatting bug with #mystats

When using values larger than 1,000, we were calling commify on a string that already had commas. This resulted in the value 1005 looking like 1,,005.

* Update mob.cpp

---------

Co-authored-by: Alex King <89047260+Kinglykrab@users.noreply.github.com>
This commit is contained in:
carolus21rex 2024-11-22 16:23:48 -05:00 committed by GitHub
parent 62ac015fff
commit b2d0fa6a2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2048,19 +2048,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
case 0: { case 0: {
mod2a_name = "Avoidance"; mod2a_name = "Avoidance";
mod2b_name = "Combat Effects"; mod2b_name = "Combat Effects";
mod2a_cap = Strings::Commify(RuleI(Character, ItemAvoidanceCap)); mod2a_cap = RuleI(Character, ItemAvoidanceCap);
mod2b_cap = Strings::Commify(RuleI(Character, ItemCombatEffectsCap)); mod2b_cap = RuleI(Character, ItemCombatEffectsCap);
if (IsBot()) { if (IsBot()) {
mod2a = Strings::Commify(CastToBot()->GetAvoidance()); mod2a = CastToBot()->GetAvoidance();
} else if (IsClient()) { } else if (IsClient()) {
mod2a = Strings::Commify(CastToClient()->GetAvoidance()); mod2a = CastToClient()->GetAvoidance();
} }
if (IsBot()) { if (IsBot()) {
mod2b = Strings::Commify(CastToBot()->GetCombatEffects()); mod2b = CastToBot()->GetCombatEffects();
} else if (IsClient()) { } else if (IsClient()) {
mod2b = Strings::Commify(CastToClient()->GetCombatEffects()); mod2b = CastToClient()->GetCombatEffects();
} }
break; break;
@ -2068,19 +2068,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
case 1: { case 1: {
mod2a_name = "Accuracy"; mod2a_name = "Accuracy";
mod2b_name = "Strikethrough"; mod2b_name = "Strikethrough";
mod2a_cap = Strings::Commify(RuleI(Character, ItemAccuracyCap)); mod2a_cap = RuleI(Character, ItemAccuracyCap);
mod2b_cap = Strings::Commify(RuleI(Character, ItemStrikethroughCap)); mod2b_cap = RuleI(Character, ItemStrikethroughCap);
if (IsBot()) { if (IsBot()) {
mod2a = Strings::Commify(CastToBot()->GetAccuracy()); mod2a = CastToBot()->GetAccuracy();
} else if (IsClient()) { } else if (IsClient()) {
mod2a = Strings::Commify(CastToClient()->GetAccuracy()); mod2a = CastToClient()->GetAccuracy();
} }
if (IsBot()) { if (IsBot()) {
mod2b = Strings::Commify(CastToBot()->GetStrikeThrough()); mod2b = CastToBot()->GetStrikeThrough();
} else if (IsClient()) { } else if (IsClient()) {
mod2b = Strings::Commify(CastToClient()->GetStrikeThrough()); mod2b = CastToClient()->GetStrikeThrough();
} }
break; break;
@ -2088,20 +2088,20 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
case 2: { case 2: {
mod2a_name = "Shielding"; mod2a_name = "Shielding";
mod2b_name = "Spell Shielding"; mod2b_name = "Spell Shielding";
mod2a_cap = Strings::Commify(RuleI(Character, ItemShieldingCap)); mod2a_cap = RuleI(Character, ItemShieldingCap);
mod2b_cap = Strings::Commify(RuleI(Character, ItemSpellShieldingCap)); mod2b_cap = RuleI(Character, ItemSpellShieldingCap);
if (IsBot()) { if (IsBot()) {
mod2a = Strings::Commify(CastToBot()->GetShielding()); mod2a = CastToBot()->GetShielding();
} else if (IsClient()) { } else if (IsClient()) {
mod2a = Strings::Commify(CastToClient()->GetShielding()); mod2a = CastToClient()->GetShielding();
} }
if (IsBot()) { if (IsBot()) {
mod2b = Strings::Commify(CastToBot()->GetSpellShield()); mod2b = CastToBot()->GetSpellShield();
} else if (IsClient()) { } else if (IsClient()) {
mod2b = Strings::Commify(CastToClient()->GetSpellShield()); mod2b = CastToClient()->GetSpellShield();
} }
break; break;
@ -2109,19 +2109,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
case 3: { case 3: {
mod2a_name = "Stun Resist"; mod2a_name = "Stun Resist";
mod2b_name = "DOT Shielding"; mod2b_name = "DOT Shielding";
mod2a_cap = Strings::Commify(RuleI(Character, ItemStunResistCap)); mod2a_cap = RuleI(Character, ItemStunResistCap);
mod2b_cap = Strings::Commify(RuleI(Character, ItemDoTShieldingCap)); mod2b_cap = RuleI(Character, ItemDoTShieldingCap);
if (IsBot()) { if (IsBot()) {
mod2a = Strings::Commify(CastToBot()->GetStunResist()); mod2a = CastToBot()->GetStunResist();
} else if (IsClient()) { } else if (IsClient()) {
mod2a = Strings::Commify(CastToClient()->GetStunResist()); mod2a = CastToClient()->GetStunResist();
} }
if (IsBot()) { if (IsBot()) {
mod2b = Strings::Commify(CastToBot()->GetDoTShield()); mod2b = CastToBot()->GetDoTShield();
} else if (IsClient()) { } else if (IsClient()) {
mod2b = Strings::Commify(CastToClient()->GetDoTShield()); mod2b = CastToClient()->GetDoTShield();
} }
break; break;