Import departure boards patch
This commit is contained in:

committed by
Jonathan G Rennison

parent
4dbabbd9e2
commit
79138de1b9
@@ -17,6 +17,7 @@
|
||||
#include "vehicle_base.h"
|
||||
#include "cmd_helper.h"
|
||||
#include "core/sort_func.hpp"
|
||||
#include "settings_type.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -257,12 +258,17 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
DateTicks start_date = (Date)p2 / DAY_TICKS;
|
||||
|
||||
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
|
||||
Date start_date = (Date)p2;
|
||||
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.list->IsCompleteTimetable()) return CMD_ERROR;
|
||||
#else
|
||||
start_date = ((DateTicks)_date * DAY_TICKS) + _date_fract + (DateTicks)(int32)p2;
|
||||
#endif
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
SmallVector<Vehicle *, 8> vehs;
|
||||
@@ -384,7 +390,11 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
||||
just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
|
||||
|
||||
if (v->timetable_start != 0) {
|
||||
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||
v->lateness_counter = (_date - v->timetable_start) * DAY_TICKS + _date_fract;
|
||||
#else
|
||||
v->lateness_counter = (_date * DAY_TICKS) + _date_fract - v->timetable_start;
|
||||
#endif
|
||||
v->timetable_start = 0;
|
||||
}
|
||||
|
||||
@@ -415,7 +425,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
||||
* the timetable entry like is done for road vehicles/ships.
|
||||
* Thus always make sure at least one tick is used between the
|
||||
* processing of different orders when filling the timetable. */
|
||||
uint time_to_set = CeilDiv(max(time_taken, 1U), DAY_TICKS) * DAY_TICKS;
|
||||
uint time_to_set = CeilDiv(max(time_taken, 1U), DATE_UNIT_SIZE) * DATE_UNIT_SIZE;
|
||||
|
||||
if (travelling && (autofilling || !v->current_order.IsTravelTimetabled())) {
|
||||
ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);
|
||||
|
Reference in New Issue
Block a user