Changeset - r26871:14e8578f092a
[Not reviewed]
master
0 4 0
Bilongozhko, Serhii (Contractor) - 16 months ago 2023-02-10 18:29:29
Serhii_Bilongozhko@comcast.com
Feature: Ctrl+Click to reset late counter for the entire vehicle group.
4 files changed with 22 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -4529,7 +4529,7 @@ STR_TIMETABLE_CLEAR_SPEED               
 
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
src/timetable_cmd.cpp
Show inline comments
 
@@ -211,9 +211,10 @@ CommandCost CmdBulkChangeTimetable(DoCom
 
 * 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(DoComman
 
	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();
src/timetable_cmd.h
Show inline comments
 
@@ -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);
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)