From 89eefd006f8e255b4d6127fc0de7870dca05cb3f Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 12 Dec 2022 10:45:57 -0800 Subject: [PATCH] Implements plugin: channel-safely v1.2.2 minor changes only The largest change is moving a df::map_block* declaration to an outer loop --- plugins/channel-safely/channel-groups.cpp | 16 ++++++++-------- plugins/channel-safely/channel-manager.cpp | 3 --- plugins/channel-safely/channel-safely-plugin.cpp | 6 ------ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/plugins/channel-safely/channel-groups.cpp b/plugins/channel-safely/channel-groups.cpp index 7ee6c5b44..5338eb6ed 100644 --- a/plugins/channel-safely/channel-groups.cpp +++ b/plugins/channel-safely/channel-groups.cpp @@ -207,6 +207,7 @@ void ChannelGroups::scan(bool full_scan) { if (!full_scan && !block->flags.bits.designated) { continue; } + df::map_block* block_above = Maps::getBlock(bx, by, z+1); // foreach tile bool empty_group = true; for (int16_t lx = 0; lx < 16; ++lx) { @@ -220,14 +221,13 @@ void ChannelGroups::scan(bool full_scan) { jobs.erase(map_pos); } 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) { - if (!is_channel_designation(block->designation[lx][ly])) { - if (df::map_block* block_above = Maps::getBlock(bx, by, z+1)) { - if (!is_channel_designation(block_above->designation[lx][ly])) { - // dig designation without a channel above it, we can skip this. - continue; - } - } + } else if (is_dig_designation(block->designation[lx][ly]) || block->occupancy[lx][ly].bits.dig_marked ) { + // We have a dig designated, or marked. Some of these will not need intervention. + if (block_above && + !is_channel_designation(block->designation[lx][ly]) && + !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; } for (df::block_square_event* event: block->block_events) { if (auto evT = virtual_cast(event)) { diff --git a/plugins/channel-safely/channel-manager.cpp b/plugins/channel-safely/channel-manager.cpp index b6b19a0ef..c22bd8a8e 100644 --- a/plugins/channel-safely/channel-manager.cpp +++ b/plugins/channel-safely/channel-manager.cpp @@ -5,9 +5,6 @@ #include //hash function for df::coord #include -#include -#include - df::unit* find_dwarf(const df::coord &map_pos) { df::unit* nearest = nullptr; uint32_t distance; diff --git a/plugins/channel-safely/channel-safely-plugin.cpp b/plugins/channel-safely/channel-safely-plugin.cpp index 73a1fea19..adb668468 100644 --- a/plugins/channel-safely/channel-safely-plugin.cpp +++ b/plugins/channel-safely/channel-safely-plugin.cpp @@ -416,12 +416,6 @@ namespace CSP { if (!config.monitoring) continue; 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 if (unit->pos == job->pos && !is_safe_fall(job->pos)) { // unsafe