summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-11-03 19:51:28 +0000
committerbjarni <bjarni@openttd.org>2005-11-03 19:51:28 +0000
commit80af1ebca8ea5c28f5f85697fe8ff4524f7cde0c (patch)
tree006f2f160edcff350c67fcbdea7a016567df4e09 /vehicle.c
parent01b6109751131daf2a1bfc60bd9404e358df08f5 (diff)
downloadopenttd-80af1ebca8ea5c28f5f85697fe8ff4524f7cde0c.tar.xz
(svn r3127) -Fix: [autoreplace] fixed a condition where a vehicle could fail to stop when autoreplacing
this would result in the construction of a new vehicle while the old one just continued added an assert to make sure it's always stopped before trying to sell the old vehicle
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/vehicle.c b/vehicle.c
index 4ca6a79e9..47a686f8a 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -527,15 +527,15 @@ Vehicle *_first_veh_in_depot_list;
void VehicleEnteredDepotThisTick(Vehicle *v)
{
// we need to set v->leave_depot_instantly as we have no control of it's contents at this time
- if (!HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
+ if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {
+ // we keep the vehicle in the depot since the user ordered it to stay
+ v->leave_depot_instantly = false;
+ } else {
// the vehicle do not plan on stopping in the depot, so we stop it to ensure that it will not reserve the path
// out of the depot before we might autoreplace it to a different engine. The new engine would not own the reserved path
// we store that we stopped the vehicle, so autoreplace can start it again
v->vehstatus |= VS_STOPPED;
v->leave_depot_instantly = true;
- } else {
- // we keep the vehicle in the depot
- v->leave_depot_instantly = false;
}
if (_first_veh_in_depot_list == NULL) {
@@ -1623,6 +1623,8 @@ static void MaybeReplaceVehicle(Vehicle *v)
assert(v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship || v->type == VEH_Aircraft);
+ assert(v->vehstatus & VS_STOPPED); // the vehicle should have been stopped in VehicleEnteredDepotThisTick() if needed
+
if (v->leave_depot_instantly) {
// we stopped the vehicle to do this, so we have to remember to start it again when we are done
// we need to store this info as the engine might be replaced and lose this info