Add checks to prevent coupling free wagon chains of different owners.
This commit is contained in:
@@ -660,7 +660,8 @@ static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const
|
|||||||
w->IsFreeWagon() && ///< A free wagon chain
|
w->IsFreeWagon() && ///< A free wagon chain
|
||||||
w->engine_type == e->index && ///< Same type
|
w->engine_type == e->index && ///< Same type
|
||||||
w->First() != v && ///< Don't connect to ourself
|
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);
|
DoCommand(0, v->index | 1 << 20, w->Last()->index, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -676,7 +677,8 @@ static void NormalizeTrainVehInDepot(const Train *u)
|
|||||||
const Train *v;
|
const Train *v;
|
||||||
FOR_ALL_TRAINS(v) {
|
FOR_ALL_TRAINS(v) {
|
||||||
if (v->IsFreeWagon() && v->tile == u->tile &&
|
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,
|
if (DoCommand(0, v->index | 1 << 20, u->index, DC_EXEC,
|
||||||
CMD_MOVE_RAIL_VEHICLE).Failed())
|
CMD_MOVE_RAIL_VEHICLE).Failed())
|
||||||
break;
|
break;
|
||||||
@@ -810,7 +812,7 @@ static Train *FindGoodVehiclePos(const Train *src)
|
|||||||
|
|
||||||
Train *dst;
|
Train *dst;
|
||||||
FOR_ALL_TRAINS(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. */
|
/* check so all vehicles in the line have the same engine. */
|
||||||
Train *t = dst;
|
Train *t = dst;
|
||||||
while (t->engine_type == eng) {
|
while (t->engine_type == eng) {
|
||||||
|
Reference in New Issue
Block a user