summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-04-19 18:48:01 +0200
committerGitHub <noreply@github.com>2019-04-19 18:48:01 +0200
commit66a8db9dc5d2eaa586f19aef47b06d7bc08a732f (patch)
tree32a947c1a767a87bfcf00f3f0bcbae5046ecf6df
parentebd4f32d15c34d7191546002cd06f99ad6b43d0c (diff)
downloadopenttd-66a8db9dc5d2eaa586f19aef47b06d7bc08a732f.tar.xz
Fix #7526, 5b77102b6: FiosItem::operator< must return false for equality (#7528)
-rw-r--r--src/fios.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/fios.cpp b/src/fios.cpp
index 76a2e7430..30a505ef7 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -52,16 +52,15 @@ extern void GetOldSaveGameName(const char *file, char *title, const char *last);
*/
bool FiosItem::operator< (const FiosItem &other) const
{
- bool r = false;
+ int r = false;
if ((_savegame_sort_order & SORT_BY_NAME) == 0 && (*this).mtime != other.mtime) {
- r = (*this).mtime < other.mtime;
+ r = (*this).mtime - other.mtime;
} else {
- r = strcasecmp((*this).title, other.title) < 0;
+ r = strcasecmp((*this).title, other.title);
}
-
- if (_savegame_sort_order & SORT_DESCENDING) r = !r;
- return r;
+ if (r == 0) return false;
+ return (_savegame_sort_order & SORT_DESCENDING) ? r > 0 : r < 0;
}
FileList::~FileList()