mirror of https://github.com/OpenTTD/OpenTTD
(svn r18653) -Fix [FS#3442]: when trying to attach a wagon to an existing free wagon chain, don't attach it to itself
parent
454e124912
commit
4697a1f431
|
@ -765,10 +765,11 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
|
||||||
/* Try to connect the vehicle to one of free chains of wagons. */
|
/* Try to connect the vehicle to one of free chains of wagons. */
|
||||||
Train *w;
|
Train *w;
|
||||||
FOR_ALL_TRAINS(w) {
|
FOR_ALL_TRAINS(w) {
|
||||||
/* do not connect new wagon with crashed/flooded consists */
|
if (w->tile == tile && ///< Same depot
|
||||||
if (w->tile == tile && w->IsFreeWagon() &&
|
w->IsFreeWagon() && ///< A free wagon chain
|
||||||
w->engine_type == engine &&
|
w->engine_type == engine && ///< Same type
|
||||||
!(w->vehstatus & VS_CRASHED)) {
|
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);
|
DoCommand(0, v->index | (w->Last()->index << 16), 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue