* Handle the town tick for a single town, by growing the town if desired. * @param t The town to try growing. */
| 919 | * @param t The town to try growing. |
| 920 | */ |
| 921 | static 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. */ |
| 940 | void OnTick_Town() |
no test coverage detected