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

Method manage_one

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

Source from the content-addressed store, hash-verified

162}
163
164bool ChannelManager::manage_one(const df::coord &map_pos, bool set_marker_mode, bool marker_mode) const {
165 if (Maps::isValidTilePos(map_pos)) {
166 TRACE(manager).print("manage_one(({}), {}, {})\n", map_pos, set_marker_mode, marker_mode);
167 df::map_block* block = Maps::getTileBlock(map_pos);
168 // we calculate the position inside the block*
169 df::coord local(map_pos);
170 local.x = local.x % 16;
171 local.y = local.y % 16;
172 df::tile_occupancy &tile_occupancy = block->occupancy[Coord(local)];
173 // ensure that we aren't on the top-most layers
174 if (map_pos.z < mapz - 3) {
175 // do we already know whether to set marker mode?
176 if (!marker_mode) {
177 // marker_mode is set to true if it is unsafe to dig
178 marker_mode = (!set_marker_mode &&
179 (has_group_above(groups, map_pos) || !is_safe_to_dig_down(map_pos))) ||
180 (set_marker_mode &&
181 is_channel_designation(block->designation[Coord(local)]) && !is_safe_to_dig_down(map_pos));
182 }
183 if (marker_mode) {
184 if (jobs.count(map_pos)) {
185 cancel_job(map_pos);
186 }
187 } else if (!block->flags.bits.designated) {
188 block->flags.bits.designated = true;
189 }
190 tile_occupancy.bits.dig_marked = marker_mode;
191 TRACE(manager).print("marker mode {}\n", marker_mode ? "ENABLED" : "DISABLED");
192 } else {
193 // if we are though, it should be totally safe to dig
194 tile_occupancy.bits.dig_marked = false;
195 }
196 TRACE(manager).print(" <- manage_one() exits normally\n");
197 return true;
198 }
199 return false;
200}
201
202void ChannelManager::mark_done(const df::coord &map_pos) {
203 groups.remove(map_pos);

Callers 1

JobStartedEventFunction · 0.80

Calls 8

isValidTilePosFunction · 0.85
getTileBlockFunction · 0.85
has_group_aboveFunction · 0.85
is_safe_to_dig_downFunction · 0.85
is_channel_designationFunction · 0.85
cancel_jobFunction · 0.85
printMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected