| 15 | |
| 16 | |
| 17 | df::unit* find_dwarf(const df::coord &map_pos) { |
| 18 | |
| 19 | df::unit* nearest = nullptr; |
| 20 | uint32_t distance; |
| 21 | for (auto unit : df::global::world->units.active) { |
| 22 | if (!nearest) { |
| 23 | nearest = unit; |
| 24 | distance = calc_distance(unit->pos, map_pos); |
| 25 | } else if (unit->status.labors[df::unit_labor::MINE]) { |
| 26 | uint32_t d = calc_distance(unit->pos, map_pos); |
| 27 | if (d < distance) { |
| 28 | nearest = unit; |
| 29 | distance = d; |
| 30 | } else if (Maps::canWalkBetween(unit->pos, map_pos)) { |
| 31 | return unit; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | return nearest; |
| 36 | } |
| 37 | |
| 38 | // sets mark flags as necessary, for all designations |
| 39 | void ChannelManager::manage_groups() { |
no test coverage detected