* Get the closest object of a given type. * @param tile The tile to start searching from. * @param type The type of the object to search for. * @param current The current object (to ignore). * @return The distance to the closest object. */
| 212 | * @return The distance to the closest object. |
| 213 | */ |
| 214 | static uint32_t GetClosestObject(TileIndex tile, ObjectType type, const Object *current) |
| 215 | { |
| 216 | uint32_t best_dist = UINT32_MAX; |
| 217 | for (const Object *o : Object::Iterate()) { |
| 218 | if (o->type != type || o == current) continue; |
| 219 | |
| 220 | best_dist = std::min(best_dist, DistanceManhattan(tile, o->location.tile)); |
| 221 | } |
| 222 | |
| 223 | return best_dist; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Implementation of var 65 |
no test coverage detected