|
|
|
@ -469,7 +469,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|
|
|
|
Order new_order(p2);
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(veh);
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -560,8 +560,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|
|
|
|
default: return CMD_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!IsCompanyBuildableVehicleType(v)) return CMD_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR;
|
|
|
|
@ -748,7 +746,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
|
|
|
|
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -817,7 +815,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
|
|
|
|
|
|
|
|
|
if (v == NULL || sel_ord == v->cur_order_index || sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle() || sel_ord == v->cur_order_index || sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -857,7 +855,7 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|
|
|
|
VehicleOrderID target_order = GB(p2, 16, 16);
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(veh);
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -940,7 +938,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|
|
|
|
if (mof >= MOF_END) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(veh);
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -1166,7 +1164,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|
|
|
|
VehicleID veh_dst = GB(p1, 0, 16);
|
|
|
|
|
|
|
|
|
|
Vehicle *dst = Vehicle::GetIfValid(veh_dst);
|
|
|
|
|
if (dst == NULL) return CMD_ERROR;
|
|
|
|
|
if (dst == NULL || !dst->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(dst->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -1176,7 +1174,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|
|
|
|
Vehicle *src = Vehicle::GetIfValid(veh_src);
|
|
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
|
|
|
|
|
if (src == NULL || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(src->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -1218,7 +1216,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|
|
|
|
Vehicle *src = Vehicle::GetIfValid(veh_src);
|
|
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
|
if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
|
|
|
|
|
if (src == NULL || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(src->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -1294,8 +1292,10 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|
|
|
|
CargoID cargo = GB(p2, 0, 8);
|
|
|
|
|
byte subtype = GB(p2, 8, 8);
|
|
|
|
|
|
|
|
|
|
if (cargo >= NUM_CARGO) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
const Vehicle *v = Vehicle::GetIfValid(veh);
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
@ -1450,7 +1450,7 @@ CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|
|
|
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(p1);
|
|
|
|
|
/* Check the vehicle type and ownership, and if the service interval and order are in range */
|
|
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
|
|
|
|
|
CommandCost ret = CheckOwnership(v->owner);
|
|
|
|
|
if (ret.Failed()) return ret;
|
|
|
|
|