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

Function FindJoiningWaypoint

src/station_cmd.cpp:1316–1323  ·  view source on GitHub ↗

* Find a nearby waypoint that joins this waypoint. * @param existing_waypoint an existing waypoint we build over * @param waypoint_to_join the waypoint to join to * @param adjacent whether adjacent waypoints are allowed * @param ta the area of the newly build waypoint * @param wp 'return' pointer for the found waypoint * @param is_road whether to find a road waypoint * @return command cost

Source from the content-addressed store, hash-verified

1314 * @return command cost with the error or 'okay'
1315 */
1316CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp, bool is_road)
1317{
1318 if (is_road) {
1319 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_ROADWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp, [](const Waypoint *wp) -> bool { return HasBit(wp->waypoint_flags, WPF_ROAD); });
1320 } else {
1321 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp, [](const Waypoint *wp) -> bool { return !HasBit(wp->waypoint_flags, WPF_ROAD); });
1322 }
1323}
1324
1325/**
1326 * Clear platform reservation during station building/removing.

Callers 2

CmdBuildRailWaypointFunction · 0.85
CmdBuildRoadWaypointFunction · 0.85

Calls 1

HasBitFunction · 0.85

Tested by

no test coverage detected