* Updates town grow counter after growth rate change. * Preserves relative house builting progress whenever it can. * @param t The town to calculate grow counter for * @param prev_growth_rate Town growth rate before it changed (one that was used with grow counter to be updated) */
| 3802 | * @param prev_growth_rate Town growth rate before it changed (one that was used with grow counter to be updated) |
| 3803 | */ |
| 3804 | static void UpdateTownGrowCounter(Town *t, uint16_t prev_growth_rate) |
| 3805 | { |
| 3806 | if (t->growth_rate == TOWN_GROWTH_RATE_NONE) return; |
| 3807 | if (prev_growth_rate == TOWN_GROWTH_RATE_NONE) { |
| 3808 | t->grow_counter = std::min<uint16_t>(t->growth_rate, t->grow_counter); |
| 3809 | return; |
| 3810 | } |
| 3811 | t->grow_counter = RoundDivSU((uint32_t)t->grow_counter * (t->growth_rate + 1), prev_growth_rate + 1); |
| 3812 | } |
| 3813 | |
| 3814 | /** |
| 3815 | * Calculates amount of active stations in the range of town (HZB_TOWN_EDGE). |
no test coverage detected