Fix ClearSeparation() not being called when auto-separation disabled.

This can causes crashes if auto-separation is re-enabled as the
next/prev separation ptrs can end up dangling.
pull/6/merge
Jonathan G Rennison 9 years ago
parent d05f67cf5a
commit a7e9c9ce65

@ -1161,7 +1161,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS);
if (_settings_game.order.timetable_separation) v->ClearSeparation();
v->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
}
@ -1626,7 +1626,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
SetBit(dst->vehicle_flags, VF_AUTOMATE_TIMETABLE);
}
if (_settings_game.order.timetable_separation) dst->ClearSeparation();
dst->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(dst->vehicle_flags, VF_TIMETABLE_STARTED);
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);

@ -591,7 +591,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
/* Start automated timetables at first opportunity */
if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED) && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) {
if (_settings_game.order.timetable_separation) v->ClearSeparation();
v->ClearSeparation();
SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
v->lateness_counter = 0;
if (_settings_game.order.timetable_separation) UpdateSeparationOrder(v);
@ -680,7 +680,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
* Otherwise we risk trains blocking 1-lane stations for long times. */
ChangeTimetable(v, v->cur_real_order_index, 0, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true);
for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
if (_settings_game.order.timetable_separation) v2->ClearSeparation();
v2->ClearSeparation();
ClrBit(v2->vehicle_flags, VF_TIMETABLE_STARTED);
SetWindowDirty(WC_VEHICLE_TIMETABLE, v2->index);
}

@ -209,7 +209,7 @@ uint Vehicle::Crash(bool flooded)
v->MarkAllViewportsDirty();
}
if (_settings_game.order.timetable_separation) this->ClearSeparation();
this->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
/* Dirty some windows */
@ -2230,7 +2230,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
if (flags & DC_EXEC) {
this->current_order.SetDepotOrderType(ODTF_MANUAL);
this->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
if (_settings_game.order.timetable_separation) this->ClearSeparation();
this->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
}
@ -2248,7 +2248,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS);
}
if (_settings_game.order.timetable_separation) this->ClearSeparation();
this->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
this->current_order.MakeDummy();
@ -2701,7 +2701,7 @@ void Vehicle::RemoveFromShared()
this->next_shared = NULL;
this->previous_shared = NULL;
if (_settings_game.order.timetable_separation) this->ClearSeparation();
this->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
}

@ -578,7 +578,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) {
if (v->IsStoppedInDepot() && (flags & DC_AUTOREPLACE) == 0) DeleteVehicleNews(p1, STR_NEWS_TRAIN_IS_WAITING + v->type);
if (_settings_game.order.timetable_separation) v->ClearSeparation();
v->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
v->vehstatus ^= VS_STOPPED;

Loading…
Cancel
Save