mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-03 21:06:58 +00:00
(svn r19657) -Fix: Add saneness checks for front vehicles.
This commit is contained in:
parent
5ecf2f7f8c
commit
2365a4dea0
@ -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;
|
||||
|
@ -410,7 +410,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
uint32 build_argument = 2;
|
||||
|
||||
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
if (v == NULL) return CMD_ERROR;
|
||||
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
Vehicle *v_front = v;
|
||||
Vehicle *w = NULL;
|
||||
Vehicle *w_front = NULL;
|
||||
@ -629,7 +629,7 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s
|
||||
CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
if (v == NULL) return CMD_ERROR;
|
||||
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
||||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
@ -663,7 +663,7 @@ CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
if (v == NULL) return CMD_ERROR;
|
||||
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
||||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user