Change: Only resort town directory window on population change if necessary

This commit is contained in:
Jonathan G Rennison 2020-01-06 20:19:50 +00:00 committed by Charles Pigott
parent f2d230d91c
commit 22ba048c89
3 changed files with 6 additions and 1 deletions

View File

@ -161,6 +161,7 @@ enum TownRatingCheckType {
/** Special values for town list window for the data parameter of #InvalidateWindowData. */ /** Special values for town list window for the data parameter of #InvalidateWindowData. */
enum TownDirectoryInvalidateWindowData { enum TownDirectoryInvalidateWindowData {
TDIWD_FORCE_REBUILD, TDIWD_FORCE_REBUILD,
TDIWD_POPULATION_CHANGE,
TDIWD_FORCE_RESORT, TDIWD_FORCE_RESORT,
}; };

View File

@ -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 InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations
if (_settings_client.gui.population_in_label) t->UpdateVirtCoord(); 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);
} }
/** /**

View File

@ -994,6 +994,10 @@ public:
this->towns.ForceRebuild(); this->towns.ForceRebuild();
break; break;
case TDIWD_POPULATION_CHANGE:
if (this->towns.SortType() == 1) this->towns.ForceResort();
break;
default: default:
this->towns.ForceResort(); this->towns.ForceResort();
} }