diff -r e17a18bb827f src/lang/english.txt --- a/src/lang/english.txt Sat Oct 25 22:00:51 2008 +0000 +++ b/src/lang/english.txt Sun Oct 26 16:32:18 2008 +0100 @@ -2939,7 +2939,7 @@ STR_TIMETABLE_TOTAL_TIME STR_TIMETABLE_TOTAL_TIME :This timetable will take {STRING1} to complete STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :This timetable will take at least {STRING1} to complete (not all timetabled) STR_TIMETABLE_AUTOFILL :{BLACK}Autofill -STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the timetable automatically with the values from the first journey +STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the timetable automatically with the values from the first journey (CTRL-click to avoid clearing the timetable) ##id 0x9000 STR_9000_ROAD_VEHICLE_IN_THE_WAY :{WHITE}Road vehicle in the way diff -r e17a18bb827f src/timetable_cmd.cpp --- a/src/timetable_cmd.cpp Sat Oct 25 22:00:51 2008 +0000 +++ b/src/timetable_cmd.cpp Sun Oct 26 16:32:18 2008 +0100 @@ -133,7 +133,9 @@ CommandCost CmdSetVehicleOnTime(TileInde * @param tile Not used. * @param flags Operation to perform. * @param p1 Vehicle index. - * @param p2 Set to 1 to enable, 0 to disable. + * @param p2 Various bitstuffed elements + * - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill. + * - p2 = (bit 1) - Set to 1 for non-destructive mode (do not clear timetable) */ CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -146,19 +148,23 @@ CommandCost CmdAutofillTimetable(TileInd if (!CheckOwnership(v->owner)) return CMD_ERROR; if (flags & DC_EXEC) { - if (p2 == 1) { + if (HasBit(p2, 0)) { /* Start autofilling the timetable, which clears all the current * timings and clears the "timetable has started" bit. */ SetBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE); ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED); - for (Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) { - order->wait_time = 0; - order->travel_time = 0; + if (!HasBit(p2, 1)) { + for (Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) { + order->wait_time = 0; + order->travel_time = 0; + } + + v->current_order.wait_time = 0; + v->current_order.travel_time = 0; } - v->current_order.wait_time = 0; - v->current_order.travel_time = 0; + v->lateness_counter = 0; } else { ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE); } @@ -179,33 +185,45 @@ void UpdateVehicleTimetable(Vehicle *v, v->current_order_time = 0; if (!_settings_game.order.timetabling) return; + + bool just_started = false; /* Make sure the timetable only starts when the vehicle reaches the first * order, not when travelling from the depot to the first station. */ if (v->cur_order_index == 0 && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) { SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED); - return; + just_started = true; } if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return; if (HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) { - if (timetabled == 0) { + if (travelling) { + /* Need to clear that now as otherwise we are not able to reduce the wait time */ + v->current_order.wait_time = 0; + } + + if (just_started) return; + + if (!v->current_order.IsType(OT_CONDITIONAL)) { /* Round the time taken up to the nearest day, as this will avoid * confusion for people who are timetabling in days, and can be * adjusted later by people who aren't. */ time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS; - if (!v->current_order.IsType(OT_CONDITIONAL)) { - ChangeTimetable(v, v->cur_order_index, time_taken, travelling); - } - return; - } else if (v->cur_order_index == 0) { - /* Otherwise if we're at the beginning and it already has a value, - * assume that autofill is finished and turn it off again. */ + ChangeTimetable(v, v->cur_order_index, time_taken, travelling); + } + + if (v->cur_order_index == 0 && travelling) { + /* If we just started we would have returned earlier and have not reached + * this code. So obviously, we have completed our round: So turn autofill + * off again. */ ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE); } - } + return; + } + + if (just_started) return; /* Vehicles will wait at stations if they arrive early even if they are not * timetabled to wait there, so make sure the lateness counter is updated diff -r e17a18bb827f src/timetable_gui.cpp --- a/src/timetable_gui.cpp Sat Oct 25 22:00:51 2008 +0000 +++ b/src/timetable_gui.cpp Sun Oct 26 16:32:18 2008 +0100 @@ -301,9 +301,12 @@ struct TimetableWindow : Window { DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); break; - case TTV_AUTOFILL: /* Autofill the timetable. */ - DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); - break; + case TTV_AUTOFILL: { /* Autofill the timetable. */ + uint32 p2 = 0; + if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0); + if (_ctrl_pressed) SetBit(p2, 1); + DoCommandP(0, v->index, p2, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); + } break; } this->SetDirty();