Implements plugin: channel-safely v0.6.1.2

develop
Josh Cooper 2022-11-08 20:01:30 -08:00
parent 8847ed23b4
commit 3cb186a62f
2 changed files with 7 additions and 4 deletions

@ -199,13 +199,15 @@ namespace CSP {
INFO(jobs).print("JobStartedEvent()\n"); INFO(jobs).print("JobStartedEvent()\n");
auto job = (df::job*) j; auto job = (df::job*) j;
// validate job type // validate job type
if (is_channel_job(job)) { if (ChannelManager::Get().exists(job->pos)) {
DEBUG(jobs).print(" valid channel job:\n"); WARN(jobs).print(" valid channel job:\n");
df::unit* worker = Job::getWorker(job); df::unit* worker = Job::getWorker(job);
// there is a valid worker (living citizen) on the job? right.. // there is a valid worker (living citizen) on the job? right..
if (worker && Units::isAlive(worker) && Units::isCitizen(worker)) { if (worker && Units::isAlive(worker) && Units::isCitizen(worker)) {
DEBUG(jobs).print(" valid worker:\n"); DEBUG(jobs).print(" valid worker:\n");
// track workers on jobs // track workers on jobs
df::coord &pos = job->pos;
WARN(jobs).print(" -> Starting job at (" COORD ")\n", COORDARGS(pos));
if (config.monitor_active || config.resurrect) { if (config.monitor_active || config.resurrect) {
job_ids.emplace(job, job->id); job_ids.emplace(job, job->id);
active_jobs.emplace(job->id, job); active_jobs.emplace(job->id, job);
@ -225,7 +227,7 @@ namespace CSP {
INFO(jobs).print("JobCompletedEvent()\n"); INFO(jobs).print("JobCompletedEvent()\n");
auto job = (df::job*) j; auto job = (df::job*) j;
// we only care if the job is a channeling one // we only care if the job is a channeling one
if (ChannelManager::Get().groups.count(job->pos)) { if (ChannelManager::Get().exists(job->pos)) {
// check job outcome // check job outcome
auto block = Maps::getTileBlock(job->pos); auto block = Maps::getTileBlock(job->pos);
df::coord local(job->pos); df::coord local(job->pos);
@ -246,7 +248,7 @@ namespace CSP {
// the tile is unchanged // the tile is unchanged
df::unit* worker = active_workers[job->id]; df::unit* worker = active_workers[job->id];
endangered_workers.emplace(active_workers[job->id]); endangered_workers.emplace(active_workers[job->id]);
ERR(jobs).print(" -> (" COORD ") stopped working but (" COORD ") doesn't appear done.\n",COORDARGS(worker->pos), COORDARGS(job->pos)); ERR(jobs).print("() -> job at (" COORD ") is done, but (" COORD ") doesn't appear done.\n",COORDARGS(worker->pos), COORDARGS(job->pos));
if (config.insta_dig) { if (config.insta_dig) {
dignow_queue.emplace(job->pos); dignow_queue.emplace(job->pos);
} }

@ -30,6 +30,7 @@ public:
void manage_group(const Group &group, bool set_marker_mode = false, bool marker_mode = false); void manage_group(const Group &group, bool set_marker_mode = false, bool marker_mode = false);
bool manage_one(const Group &group, const df::coord &map_pos, bool set_marker_mode = false, bool marker_mode = false); bool manage_one(const Group &group, const df::coord &map_pos, bool set_marker_mode = false, bool marker_mode = false);
void mark_done(const df::coord &map_pos); void mark_done(const df::coord &map_pos);
bool exists(const df::coord &map_pos) const { return groups.count(map_pos); }
void debug() { void debug() {
DEBUG(groups).print(" DEBUGGING GROUPS:\n"); DEBUG(groups).print(" DEBUGGING GROUPS:\n");
if (config.debug) { if (config.debug) {