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

Method HasRoadType

src/script/api/script_station.cpp:208–221  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

206}
207
208/* static */ bool ScriptStation::HasRoadType(StationID station_id, ScriptRoad::RoadType road_type)
209{
210 if (!IsValidStation(station_id)) return false;
211 if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
212
213 for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(RoadStopType::Bus); rs != nullptr; rs = rs->next) {
214 if (::GetPresentRoadTypes(rs->xy).Test(::RoadType(road_type))) return true;
215 }
216 for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(RoadStopType::Truck); rs != nullptr; rs = rs->next) {
217 if (::GetPresentRoadTypes(rs->xy).Test(::RoadType(road_type))) return true;
218 }
219
220 return false;
221}
222
223/* static */ TownID ScriptStation::GetNearestTown(StationID station_id)
224{

Callers

nothing calls this directly

Calls 4

GetPresentRoadTypesFunction · 0.85
TestMethod · 0.80
RoadTypeEnum · 0.70
GetPrimaryRoadStopMethod · 0.45

Tested by

no test coverage detected