Do not unnecessarily update town label if local rating unchanged
This commit is contained in:
@@ -168,7 +168,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
|||||||
return ClampTo<uint16_t>((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
|
return ClampTo<uint16_t>((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateVirtCoord();
|
void UpdateVirtCoord(bool only_if_label_changed = false);
|
||||||
|
|
||||||
inline const char *GetCachedName() const
|
inline const char *GetCachedName() const
|
||||||
{
|
{
|
||||||
|
@@ -532,10 +532,14 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Resize the sign (label) of the town after it changes population. */
|
/** Resize the sign (label) of the town after it changes population. */
|
||||||
void Town::UpdateVirtCoord()
|
void Town::UpdateVirtCoord(bool only_if_label_changed)
|
||||||
{
|
{
|
||||||
if (IsHeadless()) return;
|
if (IsHeadless()) return;
|
||||||
|
|
||||||
|
auto label_rating = this->town_label_rating;
|
||||||
this->UpdateLabel();
|
this->UpdateLabel();
|
||||||
|
if (only_if_label_changed && label_rating == this->town_label_rating) return;
|
||||||
|
|
||||||
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
||||||
|
|
||||||
if (_viewport_sign_kdtree_valid && this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index));
|
if (_viewport_sign_kdtree_valid && this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index));
|
||||||
@@ -4142,7 +4146,7 @@ static void UpdateTownRating(Town *t)
|
|||||||
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
|
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
t->UpdateVirtCoord();
|
t->UpdateVirtCoord(true);
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user