67 if (order == NULL) return CMD_ERROR; |
67 if (order == NULL) return CMD_ERROR; |
68 |
68 |
69 bool packed_time = HasBit(p1, 25); |
69 bool packed_time = HasBit(p1, 25); |
70 bool is_journey = HasBit(p1, 24) || packed_time; |
70 bool is_journey = HasBit(p1, 24) || packed_time; |
71 if (!is_journey) { |
71 if (!is_journey) { |
72 if (!order->IsType(OT_GOTO_STATION)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS); |
72 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_CONDITIONAL)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS); |
73 if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE); |
73 if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE); |
|
74 } else { |
|
75 if (order->IsType(OT_CONDITIONAL)) return CMD_ERROR; |
74 } |
76 } |
75 |
77 |
76 if (flags & DC_EXEC) { |
78 if (flags & DC_EXEC) { |
77 ChangeTimetable(v, order_number, GB(p2, 0, 16), is_journey); |
79 ChangeTimetable(v, order_number, GB(p2, 0, 16), is_journey); |
78 if (packed_time) ChangeTimetable(v, order_number, GB(p2, 16, 16), false); |
80 if (packed_time) ChangeTimetable(v, order_number, GB(p2, 16, 16), false); |
173 /* Round the time taken up to the nearest day, as this will avoid |
175 /* Round the time taken up to the nearest day, as this will avoid |
174 * confusion for people who are timetabling in days, and can be |
176 * confusion for people who are timetabling in days, and can be |
175 * adjusted later by people who aren't. */ |
177 * adjusted later by people who aren't. */ |
176 time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS; |
178 time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS; |
177 |
179 |
178 ChangeTimetable(v, v->cur_order_index, time_taken, travelling); |
180 if (!v->current_order.IsType(OT_CONDITIONAL)) { |
|
181 ChangeTimetable(v, v->cur_order_index, time_taken, travelling); |
|
182 } |
179 return; |
183 return; |
180 } else if (v->cur_order_index == 0) { |
184 } else if (v->cur_order_index == 0) { |
181 /* Otherwise if we're at the beginning and it already has a value, |
185 /* Otherwise if we're at the beginning and it already has a value, |
182 * assume that autofill is finished and turn it off again. */ |
186 * assume that autofill is finished and turn it off again. */ |
183 ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE); |
187 ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE); |