mirror of https://github.com/OpenTTD/OpenTTD
NormalizeTrainVehInDepot() should only be called if an engine was built, not for wagons.pull/11510/head
parent
3df7d1aff9
commit
e6d132d24b
|
@ -689,6 +689,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const
|
||||||
/** Move all free vehicles in the depot to the train */
|
/** Move all free vehicles in the depot to the train */
|
||||||
void NormalizeTrainVehInDepot(const Train *u)
|
void NormalizeTrainVehInDepot(const Train *u)
|
||||||
{
|
{
|
||||||
|
assert(u->IsEngine());
|
||||||
for (const Train *v : Train::Iterate()) {
|
for (const Train *v : Train::Iterate()) {
|
||||||
if (v->IsFreeWagon() && v->tile == u->tile &&
|
if (v->IsFreeWagon() && v->tile == u->tile &&
|
||||||
v->track == TRACK_BIT_DEPOT) {
|
v->track == TRACK_BIT_DEPOT) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
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. */
|
/* Move any free wagons to the new vehicle. */
|
||||||
NormalizeTrainVehInDepot(Train::From(v));
|
NormalizeTrainVehInDepot(Train::From(v));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue