From e001f4e8c1a8d6059bede79a046747756ecedd9a Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 19 May 2019 18:41:20 +0100 Subject: [PATCH] TBTR: Transfer trace restrict slot occupancy to replacement train head --- src/autoreplace_cmd.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 0bfa0b6306..6e71c5af32 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -380,6 +380,15 @@ CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoComma ChangeVehicleViewports(old_head->index, new_head->index); ChangeVehicleViewWindow(old_head->index, new_head->index); ChangeVehicleNews(old_head->index, new_head->index); + + if (old_head->type == VEH_TRAIN) { + /* Transfer any acquired trace restrict slots to the new vehicle */ + if (HasBit(Train::From(old_head)->flags, VRF_HAVE_SLOT)) { + TraceRestrictTransferVehicleOccupantInAllSlots(old_head->index, new_head->index); + ClrBit(Train::From(old_head)->flags, VRF_HAVE_SLOT); + SetBit(Train::From(new_head)->flags, VRF_HAVE_SLOT); + } + } } return cost; @@ -573,11 +582,6 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon /* Success ! */ if ((flags & DC_EXEC) != 0 && new_head != old_head) { *chain = new_head; - if (HasBit(Train::From(old_head)->flags, VRF_HAVE_SLOT)) { - TraceRestrictTransferVehicleOccupantInAllSlots(old_head->index, new_head->index); - ClrBit(Train::From(old_head)->flags, VRF_HAVE_SLOT); - SetBit(Train::From(new_head)->flags, VRF_HAVE_SLOT); - } } /* Transfer cargo of old vehicles and sell them */