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

Function TownTickHandler

src/town_cmd.cpp:921–937  ·  view source on GitHub ↗

* Handle the town tick for a single town, by growing the town if desired. * @param t The town to try growing. */

Source from the content-addressed store, hash-verified

919 * @param t The town to try growing.
920 */
921static void TownTickHandler(Town *t)
922{
923 if (t->flags.Test(TownFlag::IsGrowing)) {
924 TownExpandModes modes{TownExpandMode::Buildings};
925 if (_settings_game.economy.allow_town_roads) modes.Set(TownExpandMode::Roads);
926 int i = (int)t->grow_counter - 1;
927 if (i < 0) {
928 if (GrowTown(t, modes)) {
929 i = t->growth_rate;
930 } else {
931 /* If growth failed wait a bit before retrying */
932 i = std::min<uint16_t>(t->growth_rate, Ticks::TOWN_GROWTH_TICKS - 1);
933 }
934 }
935 t->grow_counter = i;
936 }
937}
938
939/** Iterate through all towns and call their tick handler. */
940void OnTick_Town()

Callers 1

OnTick_TownFunction · 0.85

Calls 3

GrowTownFunction · 0.85
TestMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected