diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 2a162426c8..67e233f9d7 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -689,6 +689,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const /** Move all free vehicles in the depot to the train */ void NormalizeTrainVehInDepot(const Train *u) { + assert(u->IsEngine()); for (const Train *v : Train::Iterate()) { if (v->IsFreeWagon() && v->tile == u->tile && v->track == TRACK_BIT_DEPOT) { diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 46f284e15c..549bd189c4 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -172,7 +172,7 @@ std::tuple CmdBuildVehicle(D } if (flags & DC_EXEC) { - if (type == VEH_TRAIN && use_free_vehicles && !(flags & DC_AUTOREPLACE)) { + if (type == VEH_TRAIN && use_free_vehicles && !(flags & DC_AUTOREPLACE) && Train::From(v)->IsEngine()) { /* Move any free wagons to the new vehicle. */ NormalizeTrainVehInDepot(Train::From(v)); }