summaryrefslogtreecommitdiff
path: root/src/timetable_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-18 14:25:45 +0000
committerrubidium <rubidium@openttd.org>2011-01-18 14:25:45 +0000
commit39d7f3b2bd486d5332ad3a6ddfe518dd86b65fa4 (patch)
treecf7235784a78e55053822e943a973228fdfc5762 /src/timetable_cmd.cpp
parentff6aeb879128ef505454bb2229324af96e68ec4e (diff)
downloadopenttd-39d7f3b2bd486d5332ad3a6ddfe518dd86b65fa4.tar.xz
(svn r21831) -Fix [FS#4414]: service orders for trains/aircraft would (sometimes) not get a time when autofilling
Diffstat (limited to 'src/timetable_cmd.cpp')
-rw-r--r--src/timetable_cmd.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index dc6125777..c633ec61b 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -279,8 +279,14 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
if (!v->current_order.IsType(OT_CONDITIONAL) && (travelling || time_taken > v->current_order.wait_time)) {
/* 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 = CeilDiv(time_taken, DAY_TICKS) * DAY_TICKS;
+ * adjusted later by people who aren't.
+ * For trains/aircraft multiple movement cycles are done in one
+ * tick. This makes it possible to leave the station and process
+ * e.g. a depot order in the same tick, causing it to not fill
+ * 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. */
+ time_taken = CeilDiv(max(time_taken, 1U), DAY_TICKS) * DAY_TICKS;
ChangeTimetable(v, v->cur_order_index, time_taken, travelling);
}