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

Function toggle_cur_level

plugins/dig.cpp:1984–2031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1982}
1983
1984static void toggle_cur_level(color_ostream &out, PersistentDataItem &config) {
1985 std::unordered_map<df::coord, df::job *> dig_jobs;
1986 fill_dig_jobs(dig_jobs);
1987
1988 std::unordered_set<df::job *> z_jobs;
1989
1990 bool did_set_assignment = false;
1991 bool target_state = true;
1992 const int z = *window_z;
1993 for (auto & block : world->map.map_blocks) {
1994 if (block->map_pos.z != z)
1995 continue;
1996
1997 const auto & block_pos = block->map_pos;
1998 df::tile_bitmask *mask = NULL;
1999 for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++) {
2000 df::coord pos = block_pos + df::coord(x, y, 0);
2001 if (!block->designation[x % 16][y % 16].bits.hidden)
2002 continue;
2003
2004 if (dig_jobs.contains(pos)) {
2005 z_jobs.emplace(dig_jobs[pos]);
2006 continue;
2007 }
2008
2009 if (!block->designation[x][y].bits.dig)
2010 continue;
2011
2012 if (!mask)
2013 mask = World::getPersistentTilemask(config, block, target_state);
2014 if (!mask)
2015 break;
2016
2017 if (!did_set_assignment)
2018 target_state = !mask->getassignment(x, y);
2019
2020 mask->setassignment(x, y, target_state);
2021 did_set_assignment = true;
2022 }
2023 }
2024
2025 if (target_state)
2026 for (auto job : z_jobs)
2027 unhide_surrounding_tagged_tiles(out, job);
2028
2029 if (target_state && did_set_assignment)
2030 do_enable(true);
2031}
2032
2033static int getCurLevelDesignatedCount(color_ostream &out) {
2034 std::unordered_map<df::coord, df::job *> dig_jobs;

Callers 2

toggleCurLevelWarmDigFunction · 0.85
toggleCurLevelDampDigFunction · 0.85

Calls 4

fill_dig_jobsFunction · 0.85
containsMethod · 0.80
do_enableFunction · 0.70

Tested by

no test coverage detected