Changeset - r26320:5d6742b81c27
[Not reviewed]
master
0 2 0
Nicolas Chappe - 23 months ago 2022-07-23 13:48:04
74881848+nchappe@users.noreply.github.com
Fix #8584: Vehicles with shared orders getting invalid or unexpected start dates
2 files changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -4468,7 +4468,7 @@ STR_TIMETABLE_STATUS_NOT_STARTED        
 
STR_TIMETABLE_STATUS_START_AT                                   :{BLACK}This timetable will start at {STRING1}
 

	
 
STR_TIMETABLE_STARTING_DATE                                     :{BLACK}Start date
 
STR_TIMETABLE_STARTING_DATE_TOOLTIP                             :{BLACK}Select a date as starting point of this timetable. Ctrl+Click sets the starting point of this timetable and distributes all vehicles sharing this order evenly based on their relative order, if the order is completely timetabled
 
STR_TIMETABLE_STARTING_DATE_TOOLTIP                             :{BLACK}Select a date as starting point of this timetable. Ctrl+Click distributes all vehicles sharing this order evenly from the given date based on their relative order, if the order is completely timetabled
 

	
 
STR_TIMETABLE_CHANGE_TIME                                       :{BLACK}Change Time
 
STR_TIMETABLE_WAIT_TIME_TOOLTIP                                 :{BLACK}Change the amount of time that the highlighted order should take
src/timetable_cmd.cpp
Show inline comments
 
@@ -249,11 +249,14 @@ CommandCost CmdSetTimetableStart(DoComma
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	int total_duration = v->orders->GetTimetableTotalDuration();
 

	
 
	/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
 
	if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
 
	if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (timetable_all && !v->orders->IsCompleteTimetable()) return CMD_ERROR;
 
	if (timetable_all && start_date + total_duration / DAY_TICKS > MAX_DAY) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		std::vector<Vehicle *> vehs;
 
@@ -266,14 +269,13 @@ CommandCost CmdSetTimetableStart(DoComma
 
			vehs.push_back(v);
 
		}
 

	
 
		int total_duration = v->orders->GetTimetableTotalDuration();
 
		int num_vehs = (uint)vehs.size();
 

	
 
		if (num_vehs >= 2) {
 
			std::sort(vehs.begin(), vehs.end(), &VehicleTimetableSorter);
 
		}
 

	
 
		int idx = vehs.begin() - std::find(vehs.begin(), vehs.end(), v);
 
		int idx = 0;
 

	
 
		for (Vehicle *w : vehs) {
 

	
0 comments (0 inline, 0 general)