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

Method GetPrimaryRoadStop

src/station.cpp:209–224  ·  view source on GitHub ↗

* Get the primary road stop (the first road stop) that the given vehicle can load/unload. * @param v the vehicle to get the first road stop for * @return the first roadstop that this vehicle can load at */

Source from the content-addressed store, hash-verified

207 * @return the first roadstop that this vehicle can load at
208 */
209RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
210{
211 RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? RoadStopType::Bus : RoadStopType::Truck);
212
213 for (; rs != nullptr; rs = rs->next) {
214 /* The vehicle cannot go to this roadstop (different roadtype) */
215 if (!HasTileAnyRoadType(rs->xy, v->compatible_roadtypes)) continue;
216 /* The vehicle is articulated and can therefore not go to a standard road stop. */
217 if (IsBayRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
218
219 /* The vehicle can actually go to this road stop. So, return it! */
220 break;
221 }
222
223 return rs;
224}
225
226/**
227 * Called when new facility is built on the station. If it is the first facility

Callers 5

GetByTileMethod · 0.45
CanVehicleUseStationFunction · 0.45
HasRoadTypeMethod · 0.45
ChooseRoadTrackMethod · 0.45

Calls 4

HasTileAnyRoadTypeFunction · 0.85
IsBayRoadStopTileFunction · 0.85
IsBusMethod · 0.80
HasArticulatedPartMethod · 0.80

Tested by

no test coverage detected