summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2020-01-06 20:19:50 +0000
committerCharles Pigott <charlespigott@googlemail.com>2020-01-12 19:37:43 +0000
commit22ba048c89c4b594a1bf18b4d0ea9e09f38e6dbc (patch)
tree688db8a8406802a8d366887111fa54deeb6e1037 /src
parentf2d230d91cd4df4e4558948106ba3d9ccf4cf45f (diff)
downloadopenttd-22ba048c89c4b594a1bf18b4d0ea9e09f38e6dbc.tar.xz
Change: Only resort town directory window on population change if necessary
Diffstat (limited to 'src')
-rw-r--r--src/town.h1
-rw-r--r--src/town_cmd.cpp2
-rw-r--r--src/town_gui.cpp4
3 files changed, 6 insertions, 1 deletions
diff --git a/src/town.h b/src/town.h
index 7e7bcd29e..9898e3fb6 100644
--- a/src/town.h
+++ b/src/town.h
@@ -161,6 +161,7 @@ enum TownRatingCheckType {
/** Special values for town list window for the data parameter of #InvalidateWindowData. */
enum TownDirectoryInvalidateWindowData {
TDIWD_FORCE_REBUILD,
+ TDIWD_POPULATION_CHANGE,
TDIWD_FORCE_RESORT,
};
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 994977513..08ab17855 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -423,7 +423,7 @@ static void ChangePopulation(Town *t, int mod)
InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations
if (_settings_client.gui.population_in_label) t->UpdateVirtCoord();
- InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_RESORT);
+ InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_POPULATION_CHANGE);
}
/**
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index def5f7458..fc781fad0 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -994,6 +994,10 @@ public:
this->towns.ForceRebuild();
break;
+ case TDIWD_POPULATION_CHANGE:
+ if (this->towns.SortType() == 1) this->towns.ForceResort();
+ break;
+
default:
this->towns.ForceResort();
}