|
@@ -168,49 +168,49 @@ static void DeleteOrderWarnings(const Ve
|
|
|
* only the first 8 bits used currently (bit 16 - 23) (max 255)
|
|
|
* @param p2 packed order to insert
|
|
|
*/
|
|
|
int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
VehicleID veh = GB(p1, 0, 16);
|
|
|
OrderID sel_ord = GB(p1, 16, 16);
|
|
|
Order new_order = UnpackOrder(p2);
|
|
|
|
|
|
if (!IsVehicleIndex(veh)) return CMD_ERROR;
|
|
|
v = GetVehicle(veh);
|
|
|
if (v->type == 0 || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
|
|
|
/* Check if the inserted order is to the correct destination (owner, type),
|
|
|
* and has the correct flags if any */
|
|
|
switch (new_order.type) {
|
|
|
case OT_GOTO_STATION: {
|
|
|
const Station *st;
|
|
|
|
|
|
if (!IsStationIndex(new_order.station)) return CMD_ERROR;
|
|
|
st = GetStation(new_order.station);
|
|
|
|
|
|
if (!IsValidStation(st) ||
|
|
|
(st->airport_type != AT_OILRIG && !(IsBuoy(st)) && !CheckOwnership(st->owner))) {
|
|
|
(st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner))) {
|
|
|
return CMD_ERROR;
|
|
|
}
|
|
|
|
|
|
switch (v->type) {
|
|
|
case VEH_Train:
|
|
|
if (!(st->facilities & FACIL_TRAIN)) return CMD_ERROR;
|
|
|
break;
|
|
|
|
|
|
case VEH_Road:
|
|
|
if (v->cargo_type == CT_PASSENGERS) {
|
|
|
if (!(st->facilities & FACIL_BUS_STOP)) return CMD_ERROR;
|
|
|
} else {
|
|
|
if (!(st->facilities & FACIL_TRUCK_STOP)) return CMD_ERROR;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case VEH_Ship:
|
|
|
if (!(st->facilities & FACIL_DOCK)) return CMD_ERROR;
|
|
|
break;
|
|
|
|
|
|
case VEH_Aircraft:
|
|
|
if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR;
|
|
|
break;
|
|
|
|