summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-04-10 20:55:53 +0200
committerGitHub <noreply@github.com>2019-04-10 20:55:53 +0200
commit3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (patch)
tree32d1734adb63f4836e2671c153a6cb499e8224ec /src
parent87d588f22fc129b36fb42ec6fd7413b44cc8766c (diff)
downloadopenttd-3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc.tar.xz
Fix #7494: std::sort() and qsort() use different comparators (#7495)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dropdown.cpp4
-rw-r--r--src/widgets/dropdown_type.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index cb1382dd6..b123d7d94 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -51,12 +51,12 @@ void DropDownListStringItem::Draw(int left, int right, int top, int bottom, bool
* @return true if \a first precedes \a second.
* @warning All items in the list need to be derivates of DropDownListStringItem.
*/
-/* static */ int DropDownListStringItem::NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second)
+/* static */ bool DropDownListStringItem::NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second)
{
char buffer1[512], buffer2[512];
GetString(buffer1, static_cast<const DropDownListStringItem*>(first.get())->String(), lastof(buffer1));
GetString(buffer2, static_cast<const DropDownListStringItem*>(second.get())->String(), lastof(buffer2));
- return strnatcmp(buffer1, buffer2);
+ return strnatcmp(buffer1, buffer2) < 0;
}
StringID DropDownListParamStringItem::String() const
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index 26c699f16..27c85cbe2 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -49,7 +49,7 @@ public:
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override;
virtual StringID String() const { return this->string; }
- static int NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second);
+ static bool NatSortFunc(std::unique_ptr<const DropDownListItem> const &first, std::unique_ptr<const DropDownListItem> const &second);
};
/**