From fcd6696768ba391b5316aad2134452a3c8ad0ed0 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Sun, 6 Nov 2022 18:07:22 -0800 Subject: [PATCH] Implements plugin: channel-safely v0.5.3 --- plugins/channel-safely/channel-manager.cpp | 25 +++++++------------ .../channel-safely/channel-safely-plugin.cpp | 11 ++++++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/channel-safely/channel-manager.cpp b/plugins/channel-safely/channel-manager.cpp index 7d923e9b2..9f5c5d4b4 100644 --- a/plugins/channel-safely/channel-manager.cpp +++ b/plugins/channel-safely/channel-manager.cpp @@ -80,23 +80,16 @@ bool ChannelManager::manage_one(const Group &group, const df::coord &map_pos, bo } else { // next search for the designation priority - for (df::block_square_event* event: block->block_events) { - if (auto evT = virtual_cast(event)) { - // we want to let the user keep some designations free of being managed - if (evT->priority[Coord(local)] < 1000 * config.ignore_threshold) { - DEBUG(manager).print(" if(has_groups_above())\n"); - // check that the group has no incomplete groups directly above it - if (has_group_above(groups, map_pos) || !is_safe_to_dig_down(map_pos)) { - DEBUG(manager).print(" has_groups_above: setting marker mode\n"); - tile_occupancy.bits.dig_marked = true; - if (jobs.count(map_pos)) { - jobs.erase(map_pos); - } - WARN(manager).print(" <- manage_one() exits normally\n"); - return true; - } - } + DEBUG(manager).print(" if(has_groups_above())\n"); + // check that the group has no incomplete groups directly above it + if (has_group_above(groups, map_pos) || !is_safe_to_dig_down(map_pos)) { + DEBUG(manager).print(" has_groups_above: setting marker mode\n"); + tile_occupancy.bits.dig_marked = true; + if (jobs.count(map_pos)) { + jobs.erase(map_pos); } + WARN(manager).print(" <- manage_one() exits normally\n"); + return true; } } } else { diff --git a/plugins/channel-safely/channel-safely-plugin.cpp b/plugins/channel-safely/channel-safely-plugin.cpp index 37bee4282..fa6864b8c 100644 --- a/plugins/channel-safely/channel-safely-plugin.cpp +++ b/plugins/channel-safely/channel-safely-plugin.cpp @@ -202,7 +202,14 @@ namespace CSP { void NewReportEvent(color_ostream &out, void* r) { int32_t report_id = (int32_t)(intptr_t(r)); - out.print("%d\n", report_id); + if (df::global::world) { + auto &reports = df::global::world->status.reports; + size_t idx = df::report::binsearch_index(reports, report_id); + if (idx >= 0 && idx < reports.size()){ + auto report = reports[report_id]; + out.print("%d\n%s\n", report_id, report->text.c_str()); + } + } } void OnUpdate(color_ostream &out) { @@ -326,9 +333,9 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { EM::EventHandler jobStartHandler(CSP::JobStartedEvent, 0); EM::EventHandler jobCompletionHandler(CSP::JobCompletedEvent, 0); EM::EventHandler reportHandler(CSP::NewReportEvent, 0); + EM::registerListener(EventType::REPORT, reportHandler, plugin_self); EM::registerListener(EventType::JOB_STARTED, jobStartHandler, plugin_self); EM::registerListener(EventType::JOB_COMPLETED, jobCompletionHandler, plugin_self); - EM::registerListener(EventType::REPORT, reportHandler, plugin_self); // manage designations to start off (first time building groups [very important]) out.print("channel-safely: enabled!\n"); CSP::UnpauseEvent();