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

Function GetTileDesc_Road

src/road_cmd.cpp:2212–2276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2210};
2211
2212static void GetTileDesc_Road(TileIndex tile, TileDesc &td)
2213{
2214 Owner rail_owner = INVALID_OWNER;
2215 Owner road_owner = INVALID_OWNER;
2216 Owner tram_owner = INVALID_OWNER;
2217
2218 RoadType road_rt = GetRoadTypeRoad(tile);
2219 RoadType tram_rt = GetRoadTypeTram(tile);
2220 if (road_rt != INVALID_ROADTYPE) {
2221 const RoadTypeInfo *rti = GetRoadTypeInfo(road_rt);
2222 td.roadtype = rti->strings.name;
2223 td.road_speed = rti->max_speed / 2;
2224 road_owner = GetRoadOwner(tile, RTT_ROAD);
2225 }
2226 if (tram_rt != INVALID_ROADTYPE) {
2227 const RoadTypeInfo *rti = GetRoadTypeInfo(tram_rt);
2228 td.tramtype = rti->strings.name;
2229 td.tram_speed = rti->max_speed / 2;
2230 tram_owner = GetRoadOwner(tile, RTT_TRAM);
2231 }
2232
2233 switch (GetRoadTileType(tile)) {
2234 case RoadTileType::Crossing: {
2235 td.str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
2236 rail_owner = GetTileOwner(tile);
2237
2238 const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
2239 td.railtype = rti->strings.name;
2240 td.rail_speed = rti->max_speed;
2241
2242 break;
2243 }
2244
2245 case RoadTileType::Depot:
2246 td.str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
2247 td.build_date = Depot::GetByTile(tile)->build_date;
2248 break;
2249
2250 default: {
2251 td.str = (road_rt != INVALID_ROADTYPE ? _road_tile_strings[to_underlying(GetRoadside(tile))] : STR_LAI_ROAD_DESCRIPTION_TRAMWAY);
2252 break;
2253 }
2254 }
2255
2256 /* Now we have to discover, if the tile has only one owner or many:
2257 * - Find a first_owner of the tile. (Currently road or tram must be present, but this will break when the third type becomes available)
2258 * - Compare the found owner with the other owners, and test if they differ.
2259 * Note: If road exists it will be the first_owner.
2260 */
2261 Owner first_owner = (road_owner == INVALID_OWNER ? tram_owner : road_owner);
2262 bool mixed_owners = (tram_owner != INVALID_OWNER && tram_owner != first_owner) || (rail_owner != INVALID_OWNER && rail_owner != first_owner);
2263
2264 if (mixed_owners) {
2265 /* Multiple owners */
2266 td.owner_type[0] = (rail_owner == INVALID_OWNER ? STR_NULL : STR_LAND_AREA_INFORMATION_RAIL_OWNER);
2267 td.owner[0] = rail_owner;
2268 td.owner_type[1] = (road_owner == INVALID_OWNER ? STR_NULL : STR_LAND_AREA_INFORMATION_ROAD_OWNER);
2269 td.owner[1] = road_owner;

Callers

nothing calls this directly

Calls 10

GetRoadTypeRoadFunction · 0.85
GetRoadTypeTramFunction · 0.85
GetRoadTypeInfoFunction · 0.85
GetRoadOwnerFunction · 0.85
GetRoadTileTypeFunction · 0.85
GetTileOwnerFunction · 0.85
GetRailTypeInfoFunction · 0.85
GetRailTypeFunction · 0.85
to_underlyingFunction · 0.85
GetRoadsideFunction · 0.85

Tested by

no test coverage detected