summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-28 18:26:39 +0000
committerrubidium <rubidium@openttd.org>2009-12-28 18:26:39 +0000
commit4697a1f431ddfc82dcfd3790411eef064907eef5 (patch)
tree9a9e2af625ec22e4aaf05374db3ac532244a99b7 /src
parent454e124912cb6885ca7904489aac7e2704baca26 (diff)
downloadopenttd-4697a1f431ddfc82dcfd3790411eef064907eef5.tar.xz
(svn r18653) -Fix [FS#3442]: when trying to attach a wagon to an existing free wagon chain, don't attach it to itself
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index d2c64bc0a..b30547991 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -765,10 +765,11 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
/* 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;
}