Implements plugin: channel-safely v1.2.2

minor changes only
The largest change is moving a df::map_block* declaration to an outer loop
develop
Josh Cooper 2022-12-12 10:45:57 -08:00
parent ae8291b952
commit 89eefd006f
3 changed files with 8 additions and 17 deletions

@ -207,6 +207,7 @@ void ChannelGroups::scan(bool full_scan) {
if (!full_scan && !block->flags.bits.designated) { if (!full_scan && !block->flags.bits.designated) {
continue; continue;
} }
df::map_block* block_above = Maps::getBlock(bx, by, z+1);
// foreach tile // foreach tile
bool empty_group = true; bool empty_group = true;
for (int16_t lx = 0; lx < 16; ++lx) { for (int16_t lx = 0; lx < 16; ++lx) {
@ -220,15 +221,14 @@ void ChannelGroups::scan(bool full_scan) {
jobs.erase(map_pos); jobs.erase(map_pos);
} }
block->designation[lx][ly].bits.dig = df::tile_dig_designation::No; block->designation[lx][ly].bits.dig = df::tile_dig_designation::No;
} else if (is_dig_designation(block->designation[lx][ly]) || block->occupancy[lx][ly].bits.dig_marked) { } else if (is_dig_designation(block->designation[lx][ly]) || block->occupancy[lx][ly].bits.dig_marked ) {
if (!is_channel_designation(block->designation[lx][ly])) { // We have a dig designated, or marked. Some of these will not need intervention.
if (df::map_block* block_above = Maps::getBlock(bx, by, z+1)) { if (block_above &&
if (!is_channel_designation(block_above->designation[lx][ly])) { !is_channel_designation(block->designation[lx][ly]) &&
// dig designation without a channel above it, we can skip this. !is_channel_designation(block_above->designation[lx][ly])) {
// if this tile isn't a channel designation, and doesn't have a channel designation above it.. we can skip it
continue; continue;
} }
}
}
for (df::block_square_event* event: block->block_events) { for (df::block_square_event* event: block->block_events) {
if (auto evT = virtual_cast<df::block_square_event_designation_priorityst>(event)) { if (auto evT = virtual_cast<df::block_square_event_designation_priorityst>(event)) {
// we want to let the user keep some designations free of being managed // we want to let the user keep some designations free of being managed

@ -5,9 +5,6 @@
#include <modules/EventManager.h> //hash function for df::coord #include <modules/EventManager.h> //hash function for df::coord
#include <df/block_square_event_designation_priorityst.h> #include <df/block_square_event_designation_priorityst.h>
#include <algorithm>
#include <random>
df::unit* find_dwarf(const df::coord &map_pos) { df::unit* find_dwarf(const df::coord &map_pos) {
df::unit* nearest = nullptr; df::unit* nearest = nullptr;
uint32_t distance; uint32_t distance;

@ -416,12 +416,6 @@ namespace CSP {
if (!config.monitoring) continue; if (!config.monitoring) continue;
TRACE(monitor).print(" -> compare positions of worker and job\n"); TRACE(monitor).print(" -> compare positions of worker and job\n");
// save position
if (unit->pos != job->pos && isFloorTerrain(*Maps::getTileType(unit->pos))) {
// worker is probably safe right now
continue;
}
// check for fall safety // check for fall safety
if (unit->pos == job->pos && !is_safe_fall(job->pos)) { if (unit->pos == job->pos && !is_safe_fall(job->pos)) {
// unsafe // unsafe