Changeset - r24052:244e2e7792f4
[Not reviewed]
master
0 3 0
Jonathan G Rennison - 5 years ago 2020-01-06 20:19:50
j.g.rennison@gmail.com
Change: Only resort town directory window on population change if necessary
3 files changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/town.h
Show inline comments
 
@@ -158,12 +158,13 @@ enum TownRatingCheckType {
 
	TOWN_RATING_CHECK_TYPE_COUNT, ///< Number of town checking action types.
 
};
 

	
 
/** Special values for town list window for the data parameter of #InvalidateWindowData. */
 
enum TownDirectoryInvalidateWindowData {
 
	TDIWD_FORCE_REBUILD,
 
	TDIWD_POPULATION_CHANGE,
 
	TDIWD_FORCE_RESORT,
 
};
 

	
 
/**
 
 * This enum is used in conjunction with town->flags.
 
 * IT simply states what bit is used for.
src/town_cmd.cpp
Show inline comments
 
@@ -420,13 +420,13 @@ void UpdateAllTownVirtCoords()
 
static void ChangePopulation(Town *t, int mod)
 
{
 
	t->cache.population += 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);
 
}
 

	
 
/**
 
 * Determines the world population
 
 * Basically, count population of all towns, one by one
 
 * @return uint32 the calculated population of the world
src/town_gui.cpp
Show inline comments
 
@@ -991,12 +991,16 @@ public:
 
		switch (data) {
 
			case TDIWD_FORCE_REBUILD:
 
				/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
				this->towns.ForceRebuild();
 
				break;
 

	
 
			case TDIWD_POPULATION_CHANGE:
 
				if (this->towns.SortType() == 1) this->towns.ForceResort();
 
				break;
 

	
 
			default:
 
				this->towns.ForceResort();
 
		}
 
	}
 
};
 

	
0 comments (0 inline, 0 general)