From fd0cb63963de8787a28cac0d041b29eefe5c1c17 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 23 Jul 2021 18:12:20 +0100 Subject: [PATCH] Fix send vehicle to specific depot allowing incompatible rail types --- src/vehicle.cpp | 3 ++- src/vehicle_gui.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bbcae1d468..7290874db1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3574,7 +3574,8 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command, Tile IsInfraTileUsageAllowed(this->type, this->owner, specific_depot))) { return_cmd_error(no_depot[this->type]); } - if (this->type == VEH_ROAD && (GetPresentRoadTypes(tile) & RoadVehicle::From(this)->compatible_roadtypes) == 0) { + if ((this->type == VEH_ROAD && (GetPresentRoadTypes(tile) & RoadVehicle::From(this)->compatible_roadtypes) == 0) || + (this->type == VEH_TRAIN && !HasBit(Train::From(this)->compatible_railtypes, GetRailType(tile)))) { return_cmd_error(no_depot[this->type]); } location = specific_depot; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index d7ee94fb98..2a727a394d 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -3864,6 +3864,7 @@ public: const Vehicle *v = Vehicle::Get(this->window_number); if (IsDepotTile(tile) && GetDepotVehicleType(tile) == v->type && IsInfraTileUsageAllowed(v->type, v->owner, tile)) { if (v->type == VEH_ROAD && (GetPresentRoadTypes(tile) & RoadVehicle::From(v)->compatible_roadtypes) == 0) return; + if (v->type == VEH_TRAIN && !HasBit(Train::From(v)->compatible_railtypes, GetRailType(tile))) return; DoCommandP(v->tile, v->index | (this->depot_select_ctrl_pressed ? DEPOT_SERVICE : 0U) | DEPOT_SPECIFIC, tile, GetCmdSendToDepot(v)); ResetObjectToPlace(); this->RaiseButtons();