* Check if a drive-through road stop tile can be cleared. * Road stops built on town-owned roads check the conditions * that would allow clearing of the original road. * @param tile The road stop tile to check. * @param flags Command flags. * @return A succeeded command if the road can be removed, a failed command with the relevant error message otherwise. */
| 4867 | * @return A succeeded command if the road can be removed, a failed command with the relevant error message otherwise. |
| 4868 | */ |
| 4869 | static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlags flags) |
| 4870 | { |
| 4871 | /* Water flooding can always clear road stops. */ |
| 4872 | if (_current_company == OWNER_WATER) return CommandCost(); |
| 4873 | |
| 4874 | CommandCost ret; |
| 4875 | |
| 4876 | if (GetRoadTypeTram(tile) != INVALID_ROADTYPE) { |
| 4877 | Owner tram_owner = GetRoadOwner(tile, RTT_TRAM); |
| 4878 | if (tram_owner != OWNER_NONE) { |
| 4879 | ret = CheckOwnership(tram_owner); |
| 4880 | if (ret.Failed()) return ret; |
| 4881 | } |
| 4882 | } |
| 4883 | |
| 4884 | if (GetRoadTypeRoad(tile) != INVALID_ROADTYPE) { |
| 4885 | Owner road_owner = GetRoadOwner(tile, RTT_ROAD); |
| 4886 | if (road_owner == OWNER_TOWN) { |
| 4887 | ret = CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, RTT_ROAD), OWNER_TOWN, RTT_ROAD, flags); |
| 4888 | if (ret.Failed()) return ret; |
| 4889 | } else if (road_owner != OWNER_NONE) { |
| 4890 | ret = CheckOwnership(road_owner); |
| 4891 | if (ret.Failed()) return ret; |
| 4892 | } |
| 4893 | } |
| 4894 | |
| 4895 | return CommandCost(); |
| 4896 | } |
| 4897 | |
| 4898 | /** |
| 4899 | * Clear a single tile of a station. |
no test coverage detected