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

Function FindDeletedWaypointCloseTo

src/waypoint_cmd.cpp:80–97  ·  view source on GitHub ↗

* Find a deleted waypoint close to a tile. * @param tile to search from * @param str the string to get the 'type' of * @param cid previous owner of the waypoint * @param is_road whether to find a road waypoint * @return the deleted nearby waypoint */

Source from the content-addressed store, hash-verified

78 * @return the deleted nearby waypoint
79 */
80static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile, StringID str, CompanyID cid, bool is_road)
81{
82 Waypoint *best = nullptr;
83 uint thres = 8;
84
85 for (Waypoint *wp : Waypoint::Iterate()) {
86 if (!wp->IsInUse() && wp->string_id == str && wp->owner == cid && HasBit(wp->waypoint_flags, WPF_ROAD) == is_road) {
87 uint cur_dist = DistanceManhattan(tile, wp->xy);
88
89 if (cur_dist < thres) {
90 thres = cur_dist;
91 best = wp;
92 }
93 }
94 }
95
96 return best;
97}
98
99/**
100 * Get the axis for a new rail waypoint. This means that if it is a valid

Callers 3

CmdBuildRailWaypointFunction · 0.85
CmdBuildRoadWaypointFunction · 0.85
CmdBuildBuoyFunction · 0.85

Calls 3

HasBitFunction · 0.85
DistanceManhattanFunction · 0.85
IsInUseMethod · 0.80

Tested by

no test coverage detected