* Updates town growth state (whether it is growing or not). * @param t The town to update growth for */
| 3874 | * @param t The town to update growth for |
| 3875 | */ |
| 3876 | static void UpdateTownGrowth(Town *t) |
| 3877 | { |
| 3878 | UpdateTownGrowthRate(t); |
| 3879 | |
| 3880 | t->flags.Reset(TownFlag::IsGrowing); |
| 3881 | SetWindowDirty(WC_TOWN_VIEW, t->index); |
| 3882 | |
| 3883 | if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return; |
| 3884 | |
| 3885 | if (t->fund_buildings_months == 0) { |
| 3886 | /* Check if all goals are reached for this town to grow (given we are not funding it) */ |
| 3887 | for (int i = TAE_BEGIN; i < TAE_END; i++) { |
| 3888 | switch (t->goal[i]) { |
| 3889 | case TOWN_GROWTH_WINTER: |
| 3890 | if (TileHeight(t->xy) >= GetSnowLine() && t->received[i].old_act == 0 && t->cache.population > 90) return; |
| 3891 | break; |
| 3892 | case TOWN_GROWTH_DESERT: |
| 3893 | if (GetTropicZone(t->xy) == TROPICZONE_DESERT && t->received[i].old_act == 0 && t->cache.population > 60) return; |
| 3894 | break; |
| 3895 | default: |
| 3896 | if (t->goal[i] > t->received[i].old_act) return; |
| 3897 | break; |
| 3898 | } |
| 3899 | } |
| 3900 | } |
| 3901 | |
| 3902 | if (t->flags.Test(TownFlag::CustomGrowth)) { |
| 3903 | if (t->growth_rate != TOWN_GROWTH_RATE_NONE) t->flags.Set(TownFlag::IsGrowing); |
| 3904 | SetWindowDirty(WC_TOWN_VIEW, t->index); |
| 3905 | return; |
| 3906 | } |
| 3907 | |
| 3908 | if (t->fund_buildings_months == 0 && CountActiveStations(t) == 0 && !Chance16(1, 12)) return; |
| 3909 | |
| 3910 | t->flags.Set(TownFlag::IsGrowing); |
| 3911 | SetWindowDirty(WC_TOWN_VIEW, t->index); |
| 3912 | } |
| 3913 | |
| 3914 | /** |
| 3915 | * Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile |
no test coverage detected