From d6046086da920e9635bcc053dbb32ce2e0113d1f Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 31 Dec 2022 17:55:32 +0000 Subject: [PATCH] Infra sharing: Disallow control over other company trains wholly in depots See: #469 --- src/infrastructure_func.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infrastructure_func.h b/src/infrastructure_func.h index ac2ca81cf3..f991518d09 100644 --- a/src/infrastructure_func.h +++ b/src/infrastructure_func.h @@ -72,7 +72,7 @@ static inline CommandCost CheckInfraUsageAllowed(VehicleType type, Owner infra_o */ static inline bool IsVehicleControlAllowed(const Vehicle *v, Owner o) { - return v->owner == o || (v->type == VEH_TRAIN && IsTileOwner(v->tile, o)); + return v->owner == o || (v->type == VEH_TRAIN && IsTileOwner(v->tile, o) && !v->IsChainInDepot()); } /** @@ -84,7 +84,7 @@ static inline bool IsVehicleControlAllowed(const Vehicle *v, Owner o) */ static inline CommandCost CheckVehicleControlAllowed(const Vehicle *v) { - if (v->type == VEH_TRAIN && IsTileOwner(v->tile, _current_company)) return CommandCost(); + if (v->type == VEH_TRAIN && IsTileOwner(v->tile, _current_company) && !v->IsChainInDepot()) return CommandCost(); return CheckOwnership(v->owner); }