summaryrefslogtreecommitdiff
path: root/src/order_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/order_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/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 684ff62c9..57df98a8b 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -99,6 +99,12 @@ void Order::MakeConditional(VehicleOrderID order)
this->dest = 0;
}
+void Order::MakeAutomatic(StationID destination)
+{
+ this->type = OT_AUTOMATIC;
+ this->dest = destination;
+}
+
void Order::SetRefit(CargoID cargo, byte subtype)
{
this->refit_cargo = cargo;
@@ -346,6 +352,8 @@ int OrderList::GetPositionInSharedOrderList(const Vehicle *v) const
bool OrderList::IsCompleteTimetable() const
{
for (Order *o = this->first; o != NULL; o = o->next) {
+ /* Automatic orders are, by definition, not timetabled. */
+ if (o->IsType(OT_AUTOMATIC)) continue;
if (!o->IsCompletelyTimetabled()) return false;
}
return true;
@@ -1446,9 +1454,20 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
int id = -1;
FOR_VEHICLE_ORDERS(v, order) {
id++;
- if (order->IsType(OT_GOTO_DEPOT) && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
- if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
- order->GetDestination() == destination) {
+
+ OrderType ot = order->GetType();
+ if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
+ if (ot == OT_AUTOMATIC || (v->type == VEH_AIRCRAFT && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
+ if (ot == type && order->GetDestination() == destination) {
+ /* We want to clear automatic orders, but we don't want to make them
+ * dummy orders. They should just vanish. Also check the actual order
+ * type as ot is currently OT_GOTO_STATION. */
+ if (order->IsType(OT_AUTOMATIC)) {
+ DeleteOrder(v, id);
+ id--;
+ continue;
+ }
+
order->MakeDummy();
for (const Vehicle *w = v->FirstShared(); w != NULL; w = w->NextShared()) {
/* In GUI, simulate by removing the order and adding it back */
@@ -1653,7 +1672,15 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
assert(v->cur_order_index < v->GetNumOrders());
/* Get the current order */
- order = v->GetOrder(v->cur_order_index);
+ order = v->GetNextManualOrder(v->cur_order_index);
+ if (order == NULL) {
+ order = v->GetNextManualOrder(0);
+ if (order == NULL) {
+ v->current_order.Free();
+ v->dest_tile = 0;
+ return false;
+ }
+ }
v->current_order = *order;
return UpdateOrderDest(v, order, conditional_depth + 1);
}
@@ -1708,7 +1735,7 @@ bool ProcessOrders(Vehicle *v)
/* Get the current order */
if (v->cur_order_index >= v->GetNumOrders()) v->cur_order_index = 0;
- const Order *order = v->GetOrder(v->cur_order_index);
+ const Order *order = v->GetNextManualOrder(v->cur_order_index);
/* If no order, do nothing. */
if (order == NULL || (v->type == VEH_AIRCRAFT && !CheckForValidOrders(v))) {