From f496c110500857ebda61bc7a0347c436a3bc509a Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 04:09:36 +0000 Subject: [PATCH] Decompile fn_17182 (IntToSignedString) Batch #7100 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_17182 IntToSignedString: logic confirmed by peer review Peer-reviewed-by: Lumen, Snow, Landruca Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Utility/Text/FormatString.cpp | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Source/Utility/Text/FormatString.cpp b/Source/Utility/Text/FormatString.cpp index e9d8fb37..25dc8d2f 100644 --- a/Source/Utility/Text/FormatString.cpp +++ b/Source/Utility/Text/FormatString.cpp @@ -103,3 +103,35 @@ std::string IntToString(int value, unsigned int digits) { return text; } + +// OFFSET: 0x00A95790 +// FUNCTION: fn_17182 +std::string IntToSignedString(int value, bool grouped, bool showPlus) { + if (!grouped) { + return IntToString(value, 0); + } + + const unsigned int bits = static_cast(value); + const unsigned int magnitude = value < 0 ? 0u - bits : bits; + std::string digits = IntToString(static_cast(magnitude), 0); + std::string text; + const bool negative = value < 0; + for (std::size_t i = 0; i < digits.size(); ++i) { + if ((digits.size() - i) % 3 == 0) { + text += std::string(","); + } + text += digits.at(i); + } + + if (text.at(0) == ',') { + text.erase(0, 1); + } + + if (negative) { + text.insert(text.begin(), '-'); + } else if (showPlus && value != 0) { + text.insert(text.begin(), '+'); + } + + return text; +}