diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 7ed1c5bb8c..87b0baa413 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -557,8 +557,9 @@ static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, * @param old_head The old front vehicle (no wagons attached anymore) * @param new_head The new head of the completely replaced vehicle chain * @param flags the command flags to use + * @param start_stop_check whether to run the start-stop check */ -CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlag flags) +CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlag flags, bool start_stop_check) { CommandCost cost = CommandCost(); @@ -569,7 +570,7 @@ CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoComma if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(0, old_head->group_id, new_head->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP)); /* Perform start/stop check whether the new vehicle suits newgrf restrictions etc. */ - if (cost.Succeeded()) { + if (start_stop_check && cost.Succeeded()) { /* Start the vehicle, might be denied by certain things */ assert((new_head->vehstatus & VS_STOPPED) != 0); cost.AddCost(CmdStartStopVehicle(new_head, true)); @@ -797,7 +798,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon } /* The new vehicle chain is constructed, now take over orders and everything... */ - if (cost.Succeeded()) cost.AddCost(CopyHeadSpecificThings(old_head, new_head, flags)); + if (cost.Succeeded()) cost.AddCost(CopyHeadSpecificThings(old_head, new_head, flags, true)); if (cost.Succeeded()) { /* Success ! */ @@ -864,7 +865,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon *nothing_to_do = false; /* The new vehicle is constructed, now take over orders and everything... */ - cost.AddCost(CopyHeadSpecificThings(old_head, new_head, flags)); + cost.AddCost(CopyHeadSpecificThings(old_head, new_head, flags, true)); if (cost.Succeeded()) { /* The new vehicle is constructed, now take over cargo */ diff --git a/src/autoreplace_func.h b/src/autoreplace_func.h index d2e9288681..d56a97db03 100644 --- a/src/autoreplace_func.h +++ b/src/autoreplace_func.h @@ -97,7 +97,7 @@ inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company); -CommandCost CopyHeadSpecificThings(Vehicle*, Vehicle*, DoCommandFlag); +CommandCost CopyHeadSpecificThings(Vehicle*, Vehicle*, DoCommandFlag, bool start_stop_check); bool AutoreplaceMultiPartShipWouldSucceed(EngineID e, const Vehicle *old_veh, CargoTypes all_cargoes); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 151cd2e198..b0eb87be1e 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -7446,7 +7446,7 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 // If we bought a new engine or reused one from the depot, copy some parameters from the incoming primary engine if (incoming != new_chain) { - CopyHeadSpecificThings(incoming, new_chain, flags); + CopyHeadSpecificThings(incoming, new_chain, flags, false); NeutralizeStatus(incoming); // additionally, if we don't want to use the template refit, refit as incoming