equal
deleted
inserted
replaced
52 * Travelling time if p1 bit 25 is set. |
52 * Travelling time if p1 bit 25 is set. |
53 * - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set |
53 * - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set |
54 */ |
54 */ |
55 CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
55 CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
56 { |
56 { |
57 if (!_patches.timetabling) return CMD_ERROR; |
57 if (!_settings.order.timetabling) return CMD_ERROR; |
58 |
58 |
59 VehicleID veh = GB(p1, 0, 16); |
59 VehicleID veh = GB(p1, 0, 16); |
60 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
60 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
61 |
61 |
62 Vehicle *v = GetVehicle(veh); |
62 Vehicle *v = GetVehicle(veh); |
88 * @param p1 Various bitstuffed elements |
88 * @param p1 Various bitstuffed elements |
89 * - p1 = (bit 0-15) - Vehicle with the orders to change. |
89 * - p1 = (bit 0-15) - Vehicle with the orders to change. |
90 */ |
90 */ |
91 CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
91 CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
92 { |
92 { |
93 if (!_patches.timetabling) return CMD_ERROR; |
93 if (!_settings.order.timetabling) return CMD_ERROR; |
94 |
94 |
95 VehicleID veh = GB(p1, 0, 16); |
95 VehicleID veh = GB(p1, 0, 16); |
96 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
96 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
97 |
97 |
98 Vehicle *v = GetVehicle(veh); |
98 Vehicle *v = GetVehicle(veh); |
114 * @param p1 Vehicle index. |
114 * @param p1 Vehicle index. |
115 * @param p2 Set to 1 to enable, 0 to disable. |
115 * @param p2 Set to 1 to enable, 0 to disable. |
116 */ |
116 */ |
117 CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
117 CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
118 { |
118 { |
119 if (!_patches.timetabling) return CMD_ERROR; |
119 if (!_settings.order.timetabling) return CMD_ERROR; |
120 |
120 |
121 VehicleID veh = GB(p1, 0, 16); |
121 VehicleID veh = GB(p1, 0, 16); |
122 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
122 if (!IsValidVehicleID(veh)) return CMD_ERROR; |
123 |
123 |
124 Vehicle *v = GetVehicle(veh); |
124 Vehicle *v = GetVehicle(veh); |
155 uint timetabled = travelling ? v->current_order.travel_time : v->current_order.wait_time; |
155 uint timetabled = travelling ? v->current_order.travel_time : v->current_order.wait_time; |
156 uint time_taken = v->current_order_time; |
156 uint time_taken = v->current_order_time; |
157 |
157 |
158 v->current_order_time = 0; |
158 v->current_order_time = 0; |
159 |
159 |
160 if (!_patches.timetabling) return; |
160 if (!_settings.order.timetabling) return; |
161 |
161 |
162 /* Make sure the timetable only starts when the vehicle reaches the first |
162 /* Make sure the timetable only starts when the vehicle reaches the first |
163 * order, not when travelling from the depot to the first station. */ |
163 * order, not when travelling from the depot to the first station. */ |
164 if (v->cur_order_index == 0 && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) { |
164 if (v->cur_order_index == 0 && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) { |
165 SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED); |
165 SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED); |