If road vehicle next order is for same station when leaving, do not leave
Just start loading again without moving instead
This commit is contained in:
@@ -1565,6 +1565,28 @@ inline byte IncreaseOvertakingCounter(RoadVehicle *v)
|
|||||||
return v->overtaking_ctr;
|
return v->overtaking_ctr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CheckRestartLoadingAtRoadStop(RoadVehicle *v)
|
||||||
|
{
|
||||||
|
StationID station_id = v->current_order.GetDestination();
|
||||||
|
VehicleOrderID next_order_idx = AdvanceOrderIndexDeferred(v, v->cur_implicit_order_index);
|
||||||
|
const Order *next_order = v->GetOrder(next_order_idx);
|
||||||
|
if (next_order != nullptr && next_order->IsType(OT_GOTO_STATION) && next_order->GetDestination() == station_id &&
|
||||||
|
!(next_order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) &&
|
||||||
|
IsInfraTileUsageAllowed(VEH_ROAD, v->owner, v->tile) &&
|
||||||
|
GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK)) {
|
||||||
|
FlushAdvanceOrderIndexDeferred(v, true);
|
||||||
|
v->current_order.Free();
|
||||||
|
v->cur_implicit_order_index = next_order_idx;
|
||||||
|
ProcessOrders(v);
|
||||||
|
v->last_station_visited = station_id;
|
||||||
|
v->BeginLoading();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlushAdvanceOrderIndexDeferred(v, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
|
bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
|
||||||
{
|
{
|
||||||
SCOPE_INFO_FMT([&], "IndividualRoadVehicleController: %s, %s", scope_dumper().VehicleInfo(v), scope_dumper().VehicleInfo(prev));
|
SCOPE_INFO_FMT([&], "IndividualRoadVehicleController: %s, %s", scope_dumper().VehicleInfo(v), scope_dumper().VehicleInfo(prev));
|
||||||
@@ -2015,13 +2037,20 @@ again:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (v->current_order.IsType(OT_LEAVESTATION)) {
|
||||||
|
if (CheckRestartLoadingAtRoadStop(v)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Vehicle is ready to leave a bay in a road stop */
|
/* Vehicle is ready to leave a bay in a road stop */
|
||||||
if (rs->IsEntranceBusy()) {
|
if (rs->IsEntranceBusy()) {
|
||||||
/* Road stop entrance is busy, so wait as there is nowhere else to go */
|
/* Road stop entrance is busy, so wait as there is nowhere else to go */
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (v->current_order.IsType(OT_LEAVESTATION)) v->current_order.Free();
|
if (v->current_order.IsType(OT_LEAVESTATION)) {
|
||||||
|
v->PlayLeaveStationSound();
|
||||||
|
v->current_order.Free();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsStandardRoadStopTile(v->tile)) rs->SetEntranceBusy(true);
|
if (IsStandardRoadStopTile(v->tile)) rs->SetEntranceBusy(true);
|
||||||
@@ -2039,6 +2068,8 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (v->current_order.IsType(OT_LEAVESTATION) && IsDriveThroughStopTile(v->tile)) {
|
if (v->current_order.IsType(OT_LEAVESTATION) && IsDriveThroughStopTile(v->tile)) {
|
||||||
|
if (CheckRestartLoadingAtRoadStop(v)) return false;
|
||||||
|
v->PlayLeaveStationSound();
|
||||||
v->current_order.Free();
|
v->current_order.Free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3538,8 +3538,6 @@ void Vehicle::HandleLoading(bool mode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->type != VEH_TRAIN && this->type != VEH_SHIP && this->type != VEH_AIRCRAFT) this->PlayLeaveStationSound();
|
|
||||||
|
|
||||||
this->LeaveStation();
|
this->LeaveStation();
|
||||||
|
|
||||||
/* Only advance to next order if we just loaded at the current one */
|
/* Only advance to next order if we just loaded at the current one */
|
||||||
|
Reference in New Issue
Block a user