Implements plugin: channel-safely v0.5.3

develop
Josh Cooper 2022-11-06 18:07:22 -08:00
parent 84ffeef092
commit fcd6696768
2 changed files with 18 additions and 18 deletions

@ -80,10 +80,6 @@ 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<df::block_square_event_designation_priorityst>(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)) {
@ -96,9 +92,6 @@ bool ChannelManager::manage_one(const Group &group, const df::coord &map_pos, bo
return true;
}
}
}
}
}
} else {
// if we are though, it should be totally safe to dig
tile_occupancy.bits.dig_marked = false;

@ -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();