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

Method possible_cavein

plugins/channel-safely/channel-groups.cpp:51–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51bool ChannelJobs::possible_cavein(const df::coord &job_pos) {
52 for (auto iter : active) {
53 if (iter == job_pos) continue;
54 if (calc_distance(job_pos, iter) <= 2) {
55 // find neighbours
56 df::coord n1[8];
57 df::coord n2[8];
58 get_neighbours(job_pos, n1);
59 get_neighbours(iter, n2);
60 // find shared neighbours
61 for (int i = 0; i < 7; ++i) {
62 for (int j = i + 1; j < 8; ++j) {
63 if (n1[i] == n2[j]) {
64 if (has_cavein_conditions(n1[i])) {
65 WARN(jobs).print("Channel-Safely::jobs: Cave-in conditions detected at (" COORD ")\n", COORDARGS(n1[i]));
66 return true;
67 }
68 }
69 }
70 }
71 }
72 }
73 return false;
74}
75
76// adds map_pos to a group if an adjacent one exists, or creates one if none exist... if multiple exist they're merged into the first found
77void ChannelGroups::add(const df::coord &map_pos) {

Callers 1

JobStartedEventFunction · 0.80

Calls 3

calc_distanceFunction · 0.85
get_neighboursFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected