# HG changeset patch # User rubidium # Date 1262024799 0 # Node ID 4b9804ff406b5a3e74451cbc923890180c84ba0a # Parent 14b88fb5751d3fe96181610ccd8a0c27a4ca44d5 (svn r18653) -Fix [FS#3442]: when trying to attach a wagon to an existing free wagon chain, don't attach it to itself diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -765,10 +765,11 @@ /* Try to connect the vehicle to one of free chains of wagons. */ Train *w; FOR_ALL_TRAINS(w) { - /* do not connect new wagon with crashed/flooded consists */ - if (w->tile == tile && w->IsFreeWagon() && - w->engine_type == engine && - !(w->vehstatus & VS_CRASHED)) { + if (w->tile == tile && ///< Same depot + w->IsFreeWagon() && ///< A free wagon chain + w->engine_type == engine && ///< Same type + w->First() != v && ///< Don't connect to ourself + !(w->vehstatus & VS_CRASHED)) { ///< Not crashed/flooded DoCommand(0, v->index | (w->Last()->index << 16), 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); break; }