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

Function onDig

plugins/digFlood.cpp:59–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void onDig(color_ostream& out, void* ptr) {
60 df::job* job = (df::job*)ptr;
61 if ( job->completion_timer > 0 )
62 return;
63
64 if ( job->job_type != df::enums::job_type::Dig &&
65 job->job_type != df::enums::job_type::CarveUpwardStaircase &&
66 job->job_type != df::enums::job_type::CarveDownwardStaircase &&
67 job->job_type != df::enums::job_type::CarveUpDownStaircase &&
68 job->job_type != df::enums::job_type::CarveRamp &&
69 job->job_type != df::enums::job_type::DigChannel )
70 return;
71
72 set<df::coord> jobLocations;
73 for ( df::job_list_link* link = &world->jobs.list; link != NULL; link = link->next ) {
74 if ( link->item == NULL )
75 continue;
76
77 if ( link->item->job_type != df::enums::job_type::Dig &&
78 link->item->job_type != df::enums::job_type::CarveUpwardStaircase &&
79 link->item->job_type != df::enums::job_type::CarveDownwardStaircase &&
80 link->item->job_type != df::enums::job_type::CarveUpDownStaircase &&
81 link->item->job_type != df::enums::job_type::CarveRamp &&
82 link->item->job_type != df::enums::job_type::DigChannel )
83 continue;
84
85 jobLocations.insert(link->item->pos);
86 }
87
88 MapExtras::MapCache cache;
89 df::coord pos = job->pos;
90 for ( int16_t a = -1; a <= 1; a++ ) {
91 for ( int16_t b = -1; b <= 1; b++ ) {
92 maybeExplore(out, cache, df::coord(pos.x+a,pos.y+b,pos.z), jobLocations);
93 }
94 }
95 cache.trash();
96}
97
98void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt, set<df::coord>& jobLocations) {
99 if ( !Maps::isValidTilePos(pt) ) {

Callers

nothing calls this directly

Calls 2

maybeExploreFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected