From 60a663ef58dfed6f84d613942266b397d61cb420 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 6 Mar 2018 16:14:29 +0300 Subject: [PATCH 1/2] Account for all possible count values in getCountString (Bug #4346) --- apps/openmw/mwgui/itemwidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index a31eb9c767..e793dbf581 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -16,7 +16,12 @@ namespace { if (count == 1) return ""; - if (count > 9999) + + if (count > 999999999) + return MyGUI::utility::toString(int(count/1000000000.f)) + "b"; + else if (count > 999999) + return MyGUI::utility::toString(int(count/1000000.f)) + "m"; + else if (count > 9999) return MyGUI::utility::toString(int(count/1000.f)) + "k"; else return MyGUI::utility::toString(count); From 3b922d810a01401d8a8d9b138375c5dbaed63beb Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 7 Mar 2018 14:10:58 +0300 Subject: [PATCH 2/2] Don't use floating point arithmetics for formatted count (Bug #4346) --- apps/openmw/mwgui/itemwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index e793dbf581..6b5be0314b 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -18,11 +18,11 @@ namespace return ""; if (count > 999999999) - return MyGUI::utility::toString(int(count/1000000000.f)) + "b"; + return MyGUI::utility::toString(count/1000000000) + "b"; else if (count > 999999) - return MyGUI::utility::toString(int(count/1000000.f)) + "m"; + return MyGUI::utility::toString(count/1000000) + "m"; else if (count > 9999) - return MyGUI::utility::toString(int(count/1000.f)) + "k"; + return MyGUI::utility::toString(count/1000) + "k"; else return MyGUI::utility::toString(count); }