(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

This commit is contained in:
rubidium
2010-12-26 09:03:19 +00:00
parent 8a278f7711
commit 64f04c3a74
10 changed files with 123 additions and 27 deletions

View File

@@ -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))) {