summaryrefslogtreecommitdiff
path: root/src/timetable_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-26 09:03:19 +0000
committerrubidium <rubidium@openttd.org>2010-12-26 09:03:19 +0000
commit64f04c3a74be3769a3e0bbf2e1c68bd27d6579eb (patch)
tree8608582c367f18f6c6669751ca8f0374e9f6a54d /src/timetable_cmd.cpp
parent8a278f771163b11074d23a573840af7b945abb8c (diff)
downloadopenttd-64f04c3a74be3769a3e0bbf2e1c68bd27d6579eb.tar.xz
(svn r21642) -Feature: concept of automatic station orders; add stub orders for intermediate stations and remove them when not visiting them anymore. This allows you to see what trains visit a station without actually having to order a vehicle to stop at all stations. Based on patch by fonsinchen
Diffstat (limited to 'src/timetable_cmd.cpp')
-rw-r--r--src/timetable_cmd.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 0f8fc39e9..40064f4a9 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -72,7 +72,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
VehicleOrderID order_number = GB(p1, 20, 8);
Order *order = v->GetOrder(order_number);
- if (order == NULL) return CMD_ERROR;
+ if (order == NULL || order->IsType(OT_AUTOMATIC)) return CMD_ERROR;
bool is_journey = HasBit(p1, 28);
@@ -238,11 +238,17 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
v->current_order_time = 0;
if (!_settings_game.order.timetabling) return;
+ if (v->current_order.IsType(OT_AUTOMATIC)) return; // no timetabling of auto orders
+
+ VehicleOrderID first_manual_order = 0;
+ for (Order *o = v->GetFirstOrder(); o != NULL && o->IsType(OT_AUTOMATIC); o = o->next) {
+ ++first_manual_order;
+ }
bool just_started = false;
/* This vehicle is arriving at the first destination in the timetable. */
- if (v->cur_order_index == 0 && travelling) {
+ if (v->cur_order_index == first_manual_order && travelling) {
/* If the start date hasn't been set, or it was set automatically when
* the vehicle last arrived at the first destination, update it to the
* current time. Otherwise set the late counter appropriately to when
@@ -279,7 +285,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
ChangeTimetable(v, v->cur_order_index, time_taken, travelling);
}
- if (v->cur_order_index == 0 && travelling) {
+ if (v->cur_order_index == first_manual_order && travelling) {
/* If we just started we would have returned earlier and have not reached
* this code. So obviously, we have completed our round: So turn autofill
* off again. */