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

Function GetTileDesc_TunnelBridge

src/tunnelbridge_cmd.cpp:1765–1828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1763}
1764
1765static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc &td)
1766{
1767 TransportType tt = GetTunnelBridgeTransportType(tile);
1768
1769 if (IsTunnel(tile)) {
1770 td.str = (tt == TRANSPORT_RAIL) ? STR_LAI_TUNNEL_DESCRIPTION_RAILROAD : STR_LAI_TUNNEL_DESCRIPTION_ROAD;
1771 } else { // IsBridge(tile)
1772 td.str = (tt == TRANSPORT_WATER) ? STR_LAI_BRIDGE_DESCRIPTION_AQUEDUCT : GetBridgeSpec(GetBridgeType(tile))->transport_name[tt];
1773 }
1774 td.owner[0] = GetTileOwner(tile);
1775
1776 Owner road_owner = INVALID_OWNER;
1777 Owner tram_owner = INVALID_OWNER;
1778 RoadType road_rt = (tt == TRANSPORT_ROAD) ? GetRoadTypeRoad(tile) : INVALID_ROADTYPE;
1779 RoadType tram_rt = (tt == TRANSPORT_ROAD) ? GetRoadTypeTram(tile) : INVALID_ROADTYPE;
1780 if (road_rt != INVALID_ROADTYPE) {
1781 const RoadTypeInfo *rti = GetRoadTypeInfo(road_rt);
1782 td.roadtype = rti->strings.name;
1783 td.road_speed = rti->max_speed / 2;
1784 road_owner = GetRoadOwner(tile, RTT_ROAD);
1785 }
1786 if (tram_rt != INVALID_ROADTYPE) {
1787 const RoadTypeInfo *rti = GetRoadTypeInfo(tram_rt);
1788 td.tramtype = rti->strings.name;
1789 td.tram_speed = rti->max_speed / 2;
1790 tram_owner = GetRoadOwner(tile, RTT_TRAM);
1791 }
1792
1793 /* Is there a mix of owners? */
1794 if ((tram_owner != INVALID_OWNER && tram_owner != td.owner[0]) ||
1795 (road_owner != INVALID_OWNER && road_owner != td.owner[0])) {
1796 uint i = 1;
1797 if (road_owner != INVALID_OWNER) {
1798 td.owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
1799 td.owner[i] = road_owner;
1800 i++;
1801 }
1802 if (tram_owner != INVALID_OWNER) {
1803 td.owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
1804 td.owner[i] = tram_owner;
1805 }
1806 }
1807
1808 if (tt == TRANSPORT_RAIL) {
1809 const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
1810 td.rail_speed = rti->max_speed;
1811 td.railtype = rti->strings.name;
1812
1813 if (!IsTunnel(tile)) {
1814 uint16_t spd = GetBridgeSpec(GetBridgeType(tile))->speed;
1815 /* rail speed special-cases 0 as unlimited, hides display of limit etc. */
1816 if (spd == UINT16_MAX) spd = 0;
1817 if (td.rail_speed == 0 || spd < td.rail_speed) {
1818 td.rail_speed = spd;
1819 }
1820 }
1821 } else if (tt == TRANSPORT_ROAD && !IsTunnel(tile)) {
1822 uint16_t spd = GetBridgeSpec(GetBridgeType(tile))->speed;

Callers

nothing calls this directly

Calls 11

IsTunnelFunction · 0.85
GetBridgeSpecFunction · 0.85
GetBridgeTypeFunction · 0.85
GetTileOwnerFunction · 0.85
GetRoadTypeRoadFunction · 0.85
GetRoadTypeTramFunction · 0.85
GetRoadTypeInfoFunction · 0.85
GetRoadOwnerFunction · 0.85
GetRailTypeInfoFunction · 0.85
GetRailTypeFunction · 0.85

Tested by

no test coverage detected