mirror of https://github.com/OpenTTD/OpenTTD
Feature: Ctrl+Click to reset late counter for the entire vehicle group.
parent
231935fccd
commit
35ad964c6b
|
@ -4529,7 +4529,7 @@ STR_TIMETABLE_CLEAR_SPEED :{BLACK}Clear Sp
|
|||
STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Clear the maximum travel speed of the highlighted order. Ctrl+Click clears the speed for all orders
|
||||
|
||||
STR_TIMETABLE_RESET_LATENESS :{BLACK}Reset Late Counter
|
||||
STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Reset the lateness counter, so the vehicle will be on time
|
||||
STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Reset the lateness counter, so the vehicle will be on time. Ctrl+Click will reset the entire group so the latest vehicle will be on time and all others will be early
|
||||
|
||||
STR_TIMETABLE_AUTOFILL :{BLACK}Autofill
|
||||
STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the timetable automatically with the values from the next journey. Ctrl+Click to try to keep waiting times
|
||||
|
|
|
@ -211,9 +211,10 @@ CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTim
|
|||
* Clear the lateness counter to make the vehicle on time.
|
||||
* @param flags Operation to perform.
|
||||
* @param veh Vehicle with the orders to change.
|
||||
* @param apply_to_group Set to reset the late counter for all vehicles sharing the orders.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh)
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_to_group)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR;
|
||||
|
@ -222,8 +223,23 @@ CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh)
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
v->lateness_counter = 0;
|
||||
SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
|
||||
if (apply_to_group) {
|
||||
int32 most_late = 0;
|
||||
for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) {
|
||||
if (u->lateness_counter > most_late) {
|
||||
most_late = u->lateness_counter;
|
||||
}
|
||||
}
|
||||
if (most_late > 0) {
|
||||
for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) {
|
||||
u->lateness_counter -= most_late;
|
||||
SetWindowDirty(WC_VEHICLE_TIMETABLE, u->index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
v->lateness_counter = 0;
|
||||
SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
|
||||
}
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16 data);
|
||||
CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16 data);
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh);
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_to_group);
|
||||
CommandCost CmdAutofillTimetable(DoCommandFlag flags, VehicleID veh, bool autofill, bool preserve_wait_time);
|
||||
CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool timetable_all, Date start_date);
|
||||
|
||||
|
|
|
@ -600,7 +600,7 @@ struct TimetableWindow : Window {
|
|||
}
|
||||
|
||||
case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter.
|
||||
Command<CMD_SET_VEHICLE_ON_TIME>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index);
|
||||
Command<CMD_SET_VEHICLE_ON_TIME>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _ctrl_pressed);
|
||||
break;
|
||||
|
||||
case WID_VT_AUTOFILL: { // Autofill the timetable.
|
||||
|
|
Loading…
Reference in New Issue