MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CanRemoveRoadWithStop

Function CanRemoveRoadWithStop

src/station_cmd.cpp:4869–4896  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

4867 * @return A succeeded command if the road can be removed, a failed command with the relevant error message otherwise.
4868 */
4869static 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.

Callers 1

ClearTile_StationFunction · 0.85

Calls 8

CommandCostClass · 0.85
GetRoadTypeTramFunction · 0.85
GetRoadOwnerFunction · 0.85
CheckOwnershipFunction · 0.85
GetRoadTypeRoadFunction · 0.85
CheckAllowRemoveRoadFunction · 0.85
GetAnyRoadBitsFunction · 0.85
FailedMethod · 0.80

Tested by

no test coverage detected