diff options
author | alberth <alberth@openttd.org> | 2013-03-17 15:44:19 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2013-03-17 15:44:19 +0000 |
commit | cfa42fcdceb30e8016451532e7929a57fc5a419d (patch) | |
tree | 88a9b8a04b3ec726b02ad89051bac1d20a5251ab /src | |
parent | d62ab47c7490f4c63d8d9fc97fe9aa55e4af0745 (diff) | |
download | openttd-cfa42fcdceb30e8016451532e7929a57fc5a419d.tar.xz |
(svn r25096) -Feature: Do descending sort order on population by default, and stabilize sort of equally populated towns.
Diffstat (limited to 'src')
-rw-r--r-- | src/town_gui.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp index c93fa6583..d8ffc8262 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -682,10 +682,13 @@ private: return strnatcmp(buf, buf_cache); // Sort by name (natural sorting). } - /** Sort by population */ + /** Sort by population (default descending, as big towns are of the most interest). */ static int CDECL TownPopulationSorter(const Town * const *a, const Town * const *b) { - return (*a)->cache.population - (*b)->cache.population; + uint32 a_population = (*a)->cache.population; + uint32 b_population = (*b)->cache.population; + if (a_population == b_population) return TownDirectoryWindow::TownNameSorter(a, b); + return (a_population > b_population) ? -1 : 1; } public: |