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

Function UpdateTownMaxPass

src/town_cmd.cpp:2003–2020  ·  view source on GitHub ↗

* Update the maximum amount of monthly passengers and mail for a town, based on its population. * @param t The town to update. */

Source from the content-addressed store, hash-verified

2001 * @param t The town to update.
2002 */
2003void UpdateTownMaxPass(Town *t)
2004{
2005 for (const CargoSpec *cs : CargoSpec::town_production_cargoes[TPE_PASSENGERS]) {
2006 uint32_t production = ScaleByCargoScale(t->cache.population >> 3, true);
2007 if (production == 0) continue;
2008
2009 auto &supplied = t->GetOrCreateCargoSupplied(cs->Index());
2010 supplied.history[LAST_MONTH].production = production;
2011 }
2012
2013 for (const CargoSpec *cs : CargoSpec::town_production_cargoes[TPE_MAIL]) {
2014 uint32_t production = ScaleByCargoScale(t->cache.population >> 4, true);
2015 if (production == 0) continue;
2016
2017 auto &supplied = t->GetOrCreateCargoSupplied(cs->Index());
2018 supplied.history[LAST_MONTH].production = production;
2019 }
2020}
2021
2022static void UpdateTownGrowthRate(Town *t);
2023static void UpdateTownGrowth(Town *t);

Callers 3

DoCreateTownFunction · 0.85
CmdExpandTownFunction · 0.85
AfterLoadGameFunction · 0.85

Calls 2

ScaleByCargoScaleFunction · 0.85
IndexMethod · 0.45

Tested by

no test coverage detected