From ff7891d66afff0d54508d41414bfc9899c080757 Mon Sep 17 00:00:00 2001 From: BC Ko Date: Wed, 11 Aug 2021 00:19:02 -0700 Subject: [PATCH] cleanup manual value clamping: stores.cpp --- Source/stores.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index 4b40bc052..404f17277 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -299,9 +299,7 @@ void StartSmithBuy() storenumh++; } - stextsmax = storenumh - 4; - if (stextsmax < 0) - stextsmax = 0; + stextsmax = std::max(storenumh - 4, 0); } void ScrollSmithPremiumBuy(int boughtitems) @@ -357,9 +355,7 @@ bool StartSmithPremiumBuy() AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); OffsetSTextY(22, 6); - stextsmax = storenumh - 4; - if (stextsmax < 0) - stextsmax = 0; + stextsmax = std::max(storenumh - 4, 0); ScrollSmithPremiumBuy(stextsval); @@ -421,9 +417,7 @@ void ScrollSmithSell(int idx) idx++; } - stextsmax = storenumh - 4; - if (stextsmax < 0) - stextsmax = 0; + stextsmax = std::max(storenumh - 4, 0); } void StartSmithSell() @@ -1049,9 +1043,8 @@ void StartHealerBuy() for (int i = 0; !healitem[i].isEmpty(); i++) { storenumh++; } - stextsmax = storenumh - 4; - if (stextsmax < 0) - stextsmax = 0; + + stextsmax = std::max(storenumh - 4, 0); } void StartStoryteller()