summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2013-03-17 15:44:19 +0000
committeralberth <alberth@openttd.org>2013-03-17 15:44:19 +0000
commitcfa42fcdceb30e8016451532e7929a57fc5a419d (patch)
tree88a9b8a04b3ec726b02ad89051bac1d20a5251ab /src
parentd62ab47c7490f4c63d8d9fc97fe9aa55e4af0745 (diff)
downloadopenttd-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.cpp7
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: