diff --git a/src/town.h b/src/town.h index c649d5894d..35139ca2c0 100644 --- a/src/town.h +++ b/src/town.h @@ -204,6 +204,7 @@ enum TownRatingCheckType { enum TownDirectoryInvalidateWindowData { TDIWD_FORCE_REBUILD, TDIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox) + TDIWD_POPULATION_CHANGE, TDIWD_FORCE_RESORT, }; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 6d1c2c5f25..b36231113b 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -548,7 +548,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 e471710aaa..774ab82dbf 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1001,6 +1001,11 @@ public: this->vscroll->SetCount((int)this->towns.size()); // Update scrollbar as well. } break; + + case TDIWD_POPULATION_CHANGE: + if (this->towns.SortType() == 1) this->towns.ForceResort(); + break; + default: this->towns.ForceResort(); }