(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:
@@ -1231,7 +1231,7 @@ void VehicleEnterDepot(Vehicle *v)
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
||||
|
||||
const Order *real_order = v->GetOrder(v->cur_order_index);
|
||||
const Order *real_order = v->GetNextManualOrder(v->cur_order_index);
|
||||
Order t = v->current_order;
|
||||
v->current_order.MakeDummy();
|
||||
|
||||
@@ -1747,6 +1747,12 @@ void Vehicle::BeginLoading()
|
||||
current_order.MakeLoading(true);
|
||||
UpdateVehicleTimetable(this, true);
|
||||
|
||||
for (Order *order = this->GetOrder(this->cur_order_index);
|
||||
order != NULL && order->IsType(OT_AUTOMATIC);
|
||||
order = order->next) {
|
||||
DeleteOrder(this, this->cur_order_index);
|
||||
}
|
||||
|
||||
/* Furthermore add the Non Stop flag to mark that this station
|
||||
* is the actual destination of the vehicle, which is (for example)
|
||||
* necessary to be known for HandleTrainLoading to determine
|
||||
@@ -1755,6 +1761,18 @@ void Vehicle::BeginLoading()
|
||||
this->current_order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
|
||||
|
||||
} else {
|
||||
/* We weren't scheduled to stop here. Insert an automatic order
|
||||
* to show that we are stopping here. */
|
||||
Order *in_list = this->GetOrder(this->cur_order_index);
|
||||
if (this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID &&
|
||||
((in_list == NULL && this->cur_order_index == 0) ||
|
||||
(in_list != NULL && (!in_list->IsType(OT_AUTOMATIC) ||
|
||||
in_list->GetDestination() != this->last_station_visited)))) {
|
||||
Order *auto_order = new Order();
|
||||
auto_order->MakeAutomatic(this->last_station_visited);
|
||||
InsertOrder(this, auto_order, this->cur_order_index);
|
||||
if (this->cur_order_index > 0) --this->cur_order_index;
|
||||
}
|
||||
current_order.MakeLoading(false);
|
||||
}
|
||||
|
||||
@@ -1808,11 +1826,8 @@ void Vehicle::HandleLoading(bool mode)
|
||||
|
||||
this->PlayLeaveStationSound();
|
||||
|
||||
bool at_destination_station = this->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE;
|
||||
this->LeaveStation();
|
||||
|
||||
/* If this was not the final order, don't remove it from the list. */
|
||||
if (!at_destination_station) return;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2143,6 +2158,20 @@ void Vehicle::RemoveFromShared()
|
||||
this->previous_shared = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next manual (not OT_AUTOMATIC) order after the one at the given index.
|
||||
* @param index The index to start searching at.
|
||||
* @return The next manual order at or after index or NULL if there is none.
|
||||
*/
|
||||
Order *Vehicle::GetNextManualOrder(int index) const
|
||||
{
|
||||
Order *order = this->GetOrder(index);
|
||||
while(order != NULL && order->IsType(OT_AUTOMATIC)) {
|
||||
order = order->next;
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
void StopAllVehicles()
|
||||
{
|
||||
Vehicle *v;
|
||||
|
Reference in New Issue
Block a user