555 } |
555 } |
556 |
556 |
557 return 0; |
557 return 0; |
558 } |
558 } |
559 |
559 |
560 /** Goto next order of order-list. |
560 /** Goto order of order-list. |
561 * @param tile unused |
561 * @param tile unused |
562 * @param flags operation to perform |
562 * @param flags operation to perform |
563 * @param p1 The ID of the vehicle which order is skipped |
563 * @param p1 The ID of the vehicle which order is skipped |
564 * @param p2 unused |
564 * @param p2 the selected order to which we want to skip |
565 */ |
565 */ |
566 int32 CmdSkipOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
566 int32 CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
567 { |
567 { |
568 Vehicle *v; |
568 Vehicle *v; |
569 VehicleID veh_id = p1; |
569 VehicleID veh_id = p1; |
|
570 VehicleOrderID sel_ord = p2; |
570 |
571 |
571 if (!IsValidVehicleID(veh_id)) return CMD_ERROR; |
572 if (!IsValidVehicleID(veh_id)) return CMD_ERROR; |
572 |
573 |
573 v = GetVehicle(veh_id); |
574 v = GetVehicle(veh_id); |
574 |
575 |
575 if (!CheckOwnership(v->owner)) return CMD_ERROR; |
576 if (!CheckOwnership(v->owner) || sel_ord == v->cur_order_index || |
|
577 sel_ord >= v->num_orders || v->num_orders < 2) return CMD_ERROR; |
576 |
578 |
577 if (flags & DC_EXEC) { |
579 if (flags & DC_EXEC) { |
578 /* Goto next order */ |
580 v->cur_order_index = sel_ord; |
579 VehicleOrderID b = v->cur_order_index + 1; |
|
580 if (b >= v->num_orders) b = 0; |
|
581 |
|
582 v->cur_order_index = b; |
|
583 |
581 |
584 if (v->type == VEH_ROAD) ClearSlot(v); |
582 if (v->type == VEH_ROAD) ClearSlot(v); |
585 |
583 |
586 if (v->current_order.type == OT_LOADING) { |
584 if (v->current_order.type == OT_LOADING) { |
587 v->LeaveStation(); |
585 v->LeaveStation(); |