diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 2261456a33..373a92cdbf 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -634,6 +634,7 @@ CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do if (vehicle_list_window) { if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR; } else { + if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR; /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vli.vtype, tile, &list, nullptr); } @@ -666,6 +667,7 @@ CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, Vehicle CommandCost cost(EXPENSES_NEW_VEHICLES); if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR; + if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR; /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &list, &list); diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 18dbef35f2..111762ee13 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -80,21 +80,21 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine case VEH_TRAIN: { const Train *t = Train::From(v); if (t->IsArticulatedPart() || t->IsRearDualheaded()) continue; - if (t->track != TRACK_BIT_DEPOT) continue; + if (!t->IsInDepot()) continue; if (wagons != nullptr && t->First()->IsFreeWagon()) { if (individual_wagons || t->IsFreeWagon()) wagons->push_back(t); continue; } + if (!t->IsPrimaryVehicle()) continue; break; } default: + if (!v->IsPrimaryVehicle()) continue; if (!v->IsInDepot()) continue; break; } - if (!v->IsPrimaryVehicle()) continue; - engines->push_back(v); }