Caused by incorrect order of operations when buying a train engine with refit and attaching free wagons.
(cherry picked from commit ee2d0745e9
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
5c2f9dffe6
commit
98788e865f
@@ -1520,7 +1520,7 @@ static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const
|
||||
}
|
||||
|
||||
/** Move all free vehicles in the depot to the train */
|
||||
static void NormalizeTrainVehInDepot(const Train *u)
|
||||
void NormalizeTrainVehInDepot(const Train *u)
|
||||
{
|
||||
for (const Train *v : Train::Iterate()) {
|
||||
if (v->IsFreeWagon() && v->tile == u->tile &&
|
||||
@@ -1576,11 +1576,10 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
|
||||
* @param tile tile of the depot where rail-vehicle is built.
|
||||
* @param flags type of operation.
|
||||
* @param e the engine to build.
|
||||
* @param data bit 0 prevents any free cars from being added to the train.
|
||||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret)
|
||||
CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
|
||||
@@ -1652,10 +1651,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
||||
v->ConsistChanged(CCF_ARRANGE);
|
||||
UpdateTrainGroupID(v);
|
||||
|
||||
if (!HasBit(data, 0) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle
|
||||
NormalizeTrainVehInDepot(v);
|
||||
}
|
||||
|
||||
CheckConsistencyOfArticulatedVehicle(v);
|
||||
|
||||
InvalidateVehicleTickCaches();
|
||||
|
Reference in New Issue
Block a user