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,23 +80,16 @@ bool ChannelManager::manage_one(const Group &group, const df::coord &map_pos, bo
} else { } else {
// next search for the designation priority // next search for the designation priority
for (df::block_square_event* event: block->block_events) { DEBUG(manager).print(" if(has_groups_above())\n");
if (auto evT = virtual_cast<df::block_square_event_designation_priorityst>(event)) { // check that the group has no incomplete groups directly above it
// we want to let the user keep some designations free of being managed if (has_group_above(groups, map_pos) || !is_safe_to_dig_down(map_pos)) {
if (evT->priority[Coord(local)] < 1000 * config.ignore_threshold) { DEBUG(manager).print(" has_groups_above: setting marker mode\n");
DEBUG(manager).print(" if(has_groups_above())\n"); tile_occupancy.bits.dig_marked = true;
// check that the group has no incomplete groups directly above it if (jobs.count(map_pos)) {
if (has_group_above(groups, map_pos) || !is_safe_to_dig_down(map_pos)) { jobs.erase(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;
}
}
} }
WARN(manager).print(" <- manage_one() exits normally\n");
return true;
} }
} }
} else { } else {

@ -202,7 +202,14 @@ namespace CSP {
void NewReportEvent(color_ostream &out, void* r) { void NewReportEvent(color_ostream &out, void* r) {
int32_t report_id = (int32_t)(intptr_t(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) { 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 jobStartHandler(CSP::JobStartedEvent, 0);
EM::EventHandler jobCompletionHandler(CSP::JobCompletedEvent, 0); EM::EventHandler jobCompletionHandler(CSP::JobCompletedEvent, 0);
EM::EventHandler reportHandler(CSP::NewReportEvent, 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_STARTED, jobStartHandler, plugin_self);
EM::registerListener(EventType::JOB_COMPLETED, jobCompletionHandler, 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]) // manage designations to start off (first time building groups [very important])
out.print("channel-safely: enabled!\n"); out.print("channel-safely: enabled!\n");
CSP::UnpauseEvent(); CSP::UnpauseEvent();