* Change the cargo goal of a town. * @param flags Type of operation. * @param town_id Town ID to cargo game of. * @param tae TownEffect to change the game of. * @param goal The new goal value. * @return Empty cost or an error. */
| 3141 | * @return Empty cost or an error. |
| 3142 | */ |
| 3143 | CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal) |
| 3144 | { |
| 3145 | if (_current_company != OWNER_DEITY) return CMD_ERROR; |
| 3146 | |
| 3147 | if (tae < TAE_BEGIN || tae >= TAE_END) return CMD_ERROR; |
| 3148 | |
| 3149 | Town *t = Town::GetIfValid(town_id); |
| 3150 | if (t == nullptr) return CMD_ERROR; |
| 3151 | |
| 3152 | /* Validate if there is a cargo which is the requested TownEffect */ |
| 3153 | const CargoSpec *cargo = FindFirstCargoWithTownAcceptanceEffect(tae); |
| 3154 | if (cargo == nullptr) return CMD_ERROR; |
| 3155 | |
| 3156 | if (flags.Test(DoCommandFlag::Execute)) { |
| 3157 | t->goal[tae] = goal; |
| 3158 | UpdateTownGrowth(t); |
| 3159 | InvalidateWindowData(WC_TOWN_VIEW, town_id); |
| 3160 | } |
| 3161 | |
| 3162 | return CommandCost(); |
| 3163 | } |
| 3164 | |
| 3165 | /** |
| 3166 | * Set a custom text in the Town window. |
nothing calls this directly
no test coverage detected