* Perform the "fund new buildings" town action. * @param t The town to fund buildings in. * @param flags Type of operation. * @return An empty cost. */
| 3550 | * @return An empty cost. |
| 3551 | */ |
| 3552 | static CommandCost TownActionFundBuildings(Town *t, DoCommandFlags flags) |
| 3553 | { |
| 3554 | /* Check if it's allowed to buy the rights */ |
| 3555 | if (!_settings_game.economy.fund_buildings) return CMD_ERROR; |
| 3556 | |
| 3557 | if (flags.Test(DoCommandFlag::Execute)) { |
| 3558 | /* And grow for 3 months */ |
| 3559 | t->fund_buildings_months = 3; |
| 3560 | |
| 3561 | /* Enable growth (also checking GameScript's opinion) */ |
| 3562 | UpdateTownGrowth(t); |
| 3563 | |
| 3564 | /* Build a new house, but add a small delay to make sure |
| 3565 | * that spamming funding doesn't let town grow any faster |
| 3566 | * than 1 house per 2 * TOWN_GROWTH_TICKS ticks. |
| 3567 | * Also emulate original behaviour when town was only growing in |
| 3568 | * TOWN_GROWTH_TICKS intervals, to make sure that it's not too |
| 3569 | * tick-perfect and gives player some time window where they can |
| 3570 | * spam funding with the exact same efficiency. |
| 3571 | */ |
| 3572 | t->grow_counter = std::min<uint16_t>(t->grow_counter, 2 * Ticks::TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % Ticks::TOWN_GROWTH_TICKS); |
| 3573 | |
| 3574 | SetWindowDirty(WC_TOWN_VIEW, t->index); |
| 3575 | } |
| 3576 | return CommandCost(); |
| 3577 | } |
| 3578 | |
| 3579 | /** |
| 3580 | * Perform the "buy exclusive transport rights" town action. |
nothing calls this directly
no test coverage detected