From 5bc5d43ffbac999a5b8eef23230ec49c4a42f42d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 13 Feb 2016 16:51:35 +0000 Subject: [PATCH] Add checks to prevent coupling free wagon chains of different owners. --- src/train_cmd.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 9426889aa7..d1448e60e6 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -660,7 +660,8 @@ static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const w->IsFreeWagon() && ///< A free wagon chain w->engine_type == e->index && ///< Same type w->First() != v && ///< Don't connect to ourself - !(w->vehstatus & VS_CRASHED)) { ///< Not crashed/flooded + !(w->vehstatus & VS_CRASHED) && ///< Not crashed/flooded + w->owner == v->owner) { ///< Same owner DoCommand(0, v->index | 1 << 20, w->Last()->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); break; } @@ -676,7 +677,8 @@ static void NormalizeTrainVehInDepot(const Train *u) const Train *v; FOR_ALL_TRAINS(v) { if (v->IsFreeWagon() && v->tile == u->tile && - v->track == TRACK_BIT_DEPOT) { + v->track == TRACK_BIT_DEPOT && + v->owner == u->owner) { if (DoCommand(0, v->index | 1 << 20, u->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE).Failed()) break; @@ -810,7 +812,7 @@ static Train *FindGoodVehiclePos(const Train *src) Train *dst; FOR_ALL_TRAINS(dst) { - if (dst->IsFreeWagon() && dst->tile == tile && !(dst->vehstatus & VS_CRASHED)) { + if (dst->IsFreeWagon() && dst->tile == tile && !(dst->vehstatus & VS_CRASHED) && dst->owner == src->owner) { /* check so all vehicles in the line have the same engine. */ Train *t = dst; while (t->engine_type == eng) {