* 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 */
| 78 | * @return the deleted nearby waypoint |
| 79 | */ |
| 80 | static 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 |
no test coverage detected