| 3746 | |
| 3747 | template <typename Func> |
| 3748 | static void ForAllStationsNearTown(Town *t, Func func) |
| 3749 | { |
| 3750 | /* Ideally the search radius should be close to the actual town zone 0 radius. |
| 3751 | * The true radius is not stored or calculated anywhere, only the squared radius. */ |
| 3752 | /* The efficiency of this search might be improved for large towns and many stations on the map, |
| 3753 | * by using an integer square root approximation giving a value not less than the true square root. */ |
| 3754 | uint search_radius = t->cache.squared_town_zone_radius[to_underlying(HouseZone::TownEdge)] / 2; |
| 3755 | ForAllStationsRadius(t->xy, search_radius, [&](const Station * st) { |
| 3756 | if (DistanceSquare(st->xy, t->xy) <= t->cache.squared_town_zone_radius[to_underlying(HouseZone::TownEdge)]) { |
| 3757 | func(st); |
| 3758 | } |
| 3759 | }); |
| 3760 | } |
| 3761 | |
| 3762 | /** |
| 3763 | * Monthly callback to update town and station ratings. |
no test coverage detected