@@ -650,25 +650,24 @@ static void SetGroupFlag(Group *g, Group
}
if (!children) return;
for (Group *pg : Group::Iterate()) {
if (pg->parent == g->index) SetGroupFlag(pg, flag, set, true);
/**
* (Un)set group flag from a group
* @param flags type of operation
* @param tile unused
* @param group_id index of group array
* @param flag flag to set, by value not bit.
* @param value value to set the flag to.
* @param recursive to apply to sub-groups.
* @return the cost of this operation or an error
*/
CommandCost CmdSetGroupFlag(DoCommandFlag flags, GroupID group_id, GroupFlags flag, bool value, bool recursive)
{
Group *g = Group::GetIfValid(group_id);
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
if (flag >= GroupFlags::GF_END) return CMD_ERROR;
@@ -720,25 +720,24 @@ uint GetOrderDistance(const Order *prev,
return std::max(dist1, dist2);
TileIndex prev_tile = prev->GetLocation(v, true);
TileIndex cur_tile = cur->GetLocation(v, true);
if (prev_tile == INVALID_TILE || cur_tile == INVALID_TILE) return 0;
return v->type == VEH_AIRCRAFT ? DistanceSquare(prev_tile, cur_tile) : DistanceManhattan(prev_tile, cur_tile);
* Add an order to the orderlist of a vehicle.
* @param flags operation to perform
* @param p1 various bitstuffed elements
* @param veh ID of the vehicle
* @param sel_ord the selected order (if any). If the last order is given,
* the order will be inserted before that one
* the maximum vehicle order id is 254.
* @param new_order order to insert
CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
@@ -949,25 +949,24 @@ CommandCost CmdBuildRailroadTrack(DoComm
CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track)
return CmdRailTrackHelper(flags, tile, end_tile, INVALID_RAILTYPE, track, true, false, false);
* Build a train depot
* @param tile position of the train depot
* @param railtype rail type
* @param dir entrance direction
* @param text unused
*
* @todo When checking for the tile slope,
* distinguish between "Flat land required" and "land sloped in wrong direction"
CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir)
/* check railtype and valid direction for depot (0 through 3), 4 in total */
if (!ValParamRailtype(railtype) || !IsEnumValid(dir)) return CMD_ERROR;
Slope tileh = GetTileSlope(tile);
@@ -2773,30 +2773,27 @@ CommandCost CmdRenameTown(DoCommandFlag
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect)
for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (cs->town_effect == effect) return cs;
return nullptr;
* Change the cargo goal of a town.
* @param flags Type of operation.
* @param tile Unused.
* @param town_id Town ID to cargo game of.
* @param te TownEffect to change the game of.
* @param goal The new goal value.
* @param text Unused.
* @return Empty cost or an error.
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32 goal)
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (te < TE_BEGIN || te >= TE_END) return CMD_ERROR;
Town *t = Town::GetIfValid(town_id);
if (t == nullptr) return CMD_ERROR;
/* Validate if there is a cargo which is the requested TownEffect */
@@ -189,29 +189,28 @@ std::tuple<CommandCost, VehicleID, uint,
/* Only restore if we actually did some refitting */
if (flags != subflags) RestoreRandomSeeds(saved_seeds);
return { value, veh_id, refitted_capacity, refitted_mail_capacity };
* Sell a vehicle.
* @param flags for command.
* @aram v_id vehicle ID being sold.
* @param v_id vehicle ID being sold.
* @param sell_chain sell the vehicle and all vehicles following it in the chain.
* @param backup_order make a backup of the vehicle's order (if an engine).
* @param client_id User.
* @param text unused.
* @return the cost of this operation or an error.
CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id)
Vehicle *v = Vehicle::GetIfValid(v_id);
if (v == nullptr) return CMD_ERROR;
Vehicle *front = v->First();
CommandCost ret = CheckOwnership(front->owner);
if (ret.Failed()) return ret;
Status change: