MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateVirtCoord

Method UpdateVirtCoord

src/town_cmd.cpp:398–419  ·  view source on GitHub ↗

Resize the sign (label) of the town after it changes population. */

Source from the content-addressed store, hash-verified

396
397/** Resize the sign (label) of the town after it changes population. */
398void Town::UpdateVirtCoord()
399{
400 Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
401
402 if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index));
403
404 std::string town_string;
405 if (this->larger_town) {
406 town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_CITY_POP : STR_VIEWPORT_TOWN_CITY, this->index, this->cache.population);
407 } else {
408 town_string = GetString(_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_TOWN_NAME, this->index, this->cache.population);
409 }
410
411 this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_BASE,
412 town_string,
413 GetString(STR_TOWN_NAME, this->index, this->cache.population)
414);
415
416 _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index));
417
418 SetWindowDirty(WC_TOWN_VIEW, this->index);
419}
420
421/** Update the virtual coords needed to draw the town sign for all towns. */
422void UpdateAllTownVirtCoords()

Callers 5

UpdateAllTownVirtCoordsFunction · 0.45
ChangePopulationFunction · 0.45
DoCreateTownFunction · 0.45
CmdFoundTownFunction · 0.45
CmdRenameTownFunction · 0.45

Calls 8

RemapCoords2Function · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
SetWindowDirtyFunction · 0.85
GetStringFunction · 0.70
RemoveMethod · 0.45
UpdatePositionMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected