MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CmdTownCargoGoal

Function CmdTownCargoGoal

src/town_cmd.cpp:3143–3163  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

3141 * @return Empty cost or an error.
3142 */
3143CommandCost 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.

Callers

nothing calls this directly

Calls 5

UpdateTownGrowthFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80
InvalidateWindowDataFunction · 0.70

Tested by

no test coverage detected