summaryrefslogtreecommitdiff
path: root/src/network/network_content_gui.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-04-11 21:26:02 +0200
committerPeterN <peter@fuzzle.org>2019-04-13 12:49:18 +0100
commit2db88953e7e0e521b4514f356038eeb36b299dff (patch)
tree0f058052645065811ffa58deaee2e592583587b5 /src/network/network_content_gui.cpp
parentb9b34f676b96e29ec91711bd7ff74d2492424655 (diff)
downloadopenttd-2db88953e7e0e521b4514f356038eeb36b299dff.tar.xz
Codechange: use std::sort() in GUIList
Diffstat (limited to 'src/network/network_content_gui.cpp')
-rw-r--r--src/network/network_content_gui.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index f3eb597a6..875a5b77c 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -405,28 +405,28 @@ class NetworkContentListWindow : public Window, ContentCallback {
}
/** Sort content by name. */
- static int CDECL NameSorter(const ContentInfo * const *a, const ContentInfo * const *b)
+ static bool NameSorter(const ContentInfo * const &a, const ContentInfo * const &b)
{
- return strnatcmp((*a)->name, (*b)->name, true); // Sort by name (natural sorting).
+ return strnatcmp(a->name, b->name, true) < 0; // Sort by name (natural sorting).
}
/** Sort content by type. */
- static int CDECL TypeSorter(const ContentInfo * const *a, const ContentInfo * const *b)
+ static bool TypeSorter(const ContentInfo * const &a, const ContentInfo * const &b)
{
int r = 0;
- if ((*a)->type != (*b)->type) {
- r = strnatcmp(content_type_strs[(*a)->type], content_type_strs[(*b)->type]);
+ if (a->type != b->type) {
+ r = strnatcmp(content_type_strs[a->type], content_type_strs[b->type]);
}
- if (r == 0) r = NameSorter(a, b);
- return r;
+ if (r == 0) return NameSorter(a, b);
+ return r < 0;
}
/** Sort content by state. */
- static int CDECL StateSorter(const ContentInfo * const *a, const ContentInfo * const *b)
+ static bool StateSorter(const ContentInfo * const &a, const ContentInfo * const &b)
{
- int r = (*a)->state - (*b)->state;
- if (r == 0) r = TypeSorter(a, b);
- return r;
+ int r = a->state - b->state;
+ if (r == 0) return TypeSorter(a, b);
+ return r < 0;
}
/** Sort the content list */