MCPcopy Create free account
hub / github.com/DFHack/dfhack / find_dwarf

Function find_dwarf

plugins/channel-safely/channel-manager.cpp:17–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17df::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
39void ChannelManager::manage_groups() {

Callers 1

manage_groupMethod · 0.85

Calls 1

calc_distanceFunction · 0.85

Tested by

no test coverage detected