diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3091,83 +3091,89 @@ static Foundation GetFoundation_Station( return FlatteningFoundation(tileh); } +static void FillTileDescRoadStop(TileIndex tile, TileDesc *td) +{ + RoadType road_rt = GetRoadTypeRoad(tile); + RoadType tram_rt = GetRoadTypeTram(tile); + Owner road_owner = INVALID_OWNER; + Owner tram_owner = INVALID_OWNER; + if (road_rt != INVALID_ROADTYPE) { + const RoadTypeInfo *rti = GetRoadTypeInfo(road_rt); + td->roadtype = rti->strings.name; + td->road_speed = rti->max_speed / 2; + road_owner = GetRoadOwner(tile, RTT_ROAD); + } + + if (tram_rt != INVALID_ROADTYPE) { + const RoadTypeInfo *rti = GetRoadTypeInfo(tram_rt); + td->tramtype = rti->strings.name; + td->tram_speed = rti->max_speed / 2; + tram_owner = GetRoadOwner(tile, RTT_TRAM); + } + + if (IsDriveThroughStopTile(tile)) { + /* Is there a mix of owners? */ + if ((tram_owner != INVALID_OWNER && tram_owner != td->owner[0]) || + (road_owner != INVALID_OWNER && road_owner != td->owner[0])) { + uint i = 1; + if (road_owner != INVALID_OWNER) { + td->owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER; + td->owner[i] = road_owner; + i++; + } + if (tram_owner != INVALID_OWNER) { + td->owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER; + td->owner[i] = tram_owner; + } + } + } +} + +void FillTileDescRailStation(TileIndex tile, TileDesc *td) +{ + const StationSpec *spec = GetStationSpec(tile); + + if (spec != nullptr) { + td->station_class = StationClass::Get(spec->cls_id)->name; + td->station_name = spec->name; + + if (spec->grf_prop.grffile != nullptr) { + const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid); + td->grf = gc->GetName(); + } + } + + const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile)); + td->rail_speed = rti->max_speed; + td->railtype = rti->strings.name; +} + +void FillTileDescAirport(TileIndex tile, TileDesc *td) +{ + const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec(); + td->airport_class = AirportClass::Get(as->cls_id)->name; + td->airport_name = as->name; + + const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile); + td->airport_tile_name = ats->name; + + if (as->grf_prop.grffile != nullptr) { + const GRFConfig *gc = GetGRFConfig(as->grf_prop.grffile->grfid); + td->grf = gc->GetName(); + } else if (ats->grf_prop.grffile != nullptr) { + const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid); + td->grf = gc->GetName(); + } +} + static void GetTileDesc_Station(TileIndex tile, TileDesc *td) { td->owner[0] = GetTileOwner(tile); - - if (IsRoadStopTile(tile)) { - RoadType road_rt = GetRoadTypeRoad(tile); - RoadType tram_rt = GetRoadTypeTram(tile); - Owner road_owner = INVALID_OWNER; - Owner tram_owner = INVALID_OWNER; - if (road_rt != INVALID_ROADTYPE) { - const RoadTypeInfo *rti = GetRoadTypeInfo(road_rt); - td->roadtype = rti->strings.name; - td->road_speed = rti->max_speed / 2; - road_owner = GetRoadOwner(tile, RTT_ROAD); - } - - if (tram_rt != INVALID_ROADTYPE) { - const RoadTypeInfo *rti = GetRoadTypeInfo(tram_rt); - td->tramtype = rti->strings.name; - td->tram_speed = rti->max_speed / 2; - tram_owner = GetRoadOwner(tile, RTT_TRAM); - } - - if (IsDriveThroughStopTile(tile)) { - /* Is there a mix of owners? */ - if ((tram_owner != INVALID_OWNER && tram_owner != td->owner[0]) || - (road_owner != INVALID_OWNER && road_owner != td->owner[0])) { - uint i = 1; - if (road_owner != INVALID_OWNER) { - td->owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER; - td->owner[i] = road_owner; - i++; - } - if (tram_owner != INVALID_OWNER) { - td->owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER; - td->owner[i] = tram_owner; - } - } - } - } - td->build_date = BaseStation::GetByTile(tile)->build_date; - if (HasStationTileRail(tile)) { - const StationSpec *spec = GetStationSpec(tile); - - if (spec != nullptr) { - td->station_class = StationClass::Get(spec->cls_id)->name; - td->station_name = spec->name; - - if (spec->grf_prop.grffile != nullptr) { - const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid); - td->grf = gc->GetName(); - } - } - - const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile)); - td->rail_speed = rti->max_speed; - td->railtype = rti->strings.name; - } - - if (IsAirport(tile)) { - const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec(); - td->airport_class = AirportClass::Get(as->cls_id)->name; - td->airport_name = as->name; - - const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile); - td->airport_tile_name = ats->name; - - if (as->grf_prop.grffile != nullptr) { - const GRFConfig *gc = GetGRFConfig(as->grf_prop.grffile->grfid); - td->grf = gc->GetName(); - } else if (ats->grf_prop.grffile != nullptr) { - const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid); - td->grf = gc->GetName(); - } - } + if (IsRoadStop(tile)) FillTileDescRoadStop(tile, td); + if (HasStationRail(tile)) FillTileDescRailStation(tile, td); + if (IsAirport(tile)) FillTileDescAirport(tile, td); StringID str; switch (GetStationType(tile)) {