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

Function ChangePopulation

src/town_cmd.cpp:442–451  ·  view source on GitHub ↗

* Change the town's population as recorded in the town cache, town label, and town directory. * @param t The town which has changed. * @param mod The population change (can be positive or negative). */

Source from the content-addressed store, hash-verified

440 * @param mod The population change (can be positive or negative).
441 */
442static void ChangePopulation(Town *t, int mod)
443{
444 t->cache.population += mod;
445 if (_generating_town) [[unlikely]] return;
446
447 InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations
448 if (_settings_client.gui.population_in_label) t->UpdateVirtCoord();
449
450 InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_POPULATION_CHANGE);
451}
452
453/**
454 * Get the total population, the sum of all towns in the world.

Callers 3

BuildTownHouseFunction · 0.85
ClearTownHouseFunction · 0.85

Calls 2

InvalidateWindowDataFunction · 0.70
UpdateVirtCoordMethod · 0.45

Tested by

no test coverage detected