From ac7b1800f058197ea5f0b3b920b721d7a3a1ce7f Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Tue, 8 Oct 2024 12:03:33 -0700 Subject: [PATCH] Add FORMATTING_RETRIES constexpr --- .../Game/T6/AssetDumpers/AssetDumperSndBank.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 39ee1e4b..10805b9c 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -194,6 +194,8 @@ namespace const auto CONTEXT_VALUES_MAP = CreateSoundHashMap(KNOWN_CONTEXT_VALUES, std::extent_v); const auto FUTZ_IDS_MAP = CreateSoundHashMap(KNOWN_FUTZ_IDS, std::extent_v); + constexpr auto FORMATTING_RETRIES = 5; + class LoadedSoundBankHashes { public: @@ -385,7 +387,7 @@ namespace const auto dbSpl = std::clamp(Common::LinearToDbspl(linear), 0.0f, 100.0f); std::string dbSplFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { dbSplFormat = std::format("{:.{}f}", dbSpl, i); const auto dbSplRound = std::stof(dbSplFormat); @@ -404,7 +406,7 @@ namespace const auto cents = std::clamp(Common::HertzToCents(hertz), -2400.0f, 1200.0f); std::string centsFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { centsFormat = std::format("{:.{}f}", cents, i); const auto centsRound = std::stof(centsFormat); @@ -422,7 +424,7 @@ namespace const auto normValue = static_cast(value) / static_cast(std::numeric_limits::max()); std::string normValueFormat; - for (auto i = 0; i <= 4; i++) + for (auto i = 0; i < FORMATTING_RETRIES; i++) { normValueFormat = std::format("{:.{}f}", normValue, i); const auto normValueRound = std::stof(normValueFormat);