Implements plugin: channel-safely v0.5.1

develop
Josh Cooper 2022-11-06 16:18:39 -08:00
parent e5dbaac85d
commit 9db0d809fa
2 changed files with 55 additions and 53 deletions

@ -148,6 +148,7 @@ namespace CSP {
void JobStartedEvent(color_ostream &out, void* p) { void JobStartedEvent(color_ostream &out, void* p) {
if (enabled && World::isFortressMode() && Maps::IsValid()) { if (enabled && World::isFortressMode() && Maps::IsValid()) {
if (config.monitor_active) {
INFO(monitor).print("JobStartedEvent()\n"); INFO(monitor).print("JobStartedEvent()\n");
auto job = (df::job*) p; auto job = (df::job*) p;
// validate job type // validate job type
@ -206,10 +207,11 @@ namespace CSP {
INFO(monitor).print(" <- JobStartedEvent() exits normally\n"); INFO(monitor).print(" <- JobStartedEvent() exits normally\n");
} }
} }
}
void JobCompletedEvent(color_ostream &out, void* job_ptr) { void JobCompletedEvent(color_ostream &out, void* job_ptr) {
if (enabled && World::isFortressMode() && Maps::IsValid()) { if (enabled && World::isFortressMode() && Maps::IsValid()) {
INFO(monitor).print("JobCompletedEvent()\n"); INFO(jobs).print("JobCompletedEvent()\n");
auto job = (df::job*) job_ptr; auto job = (df::job*) job_ptr;
// 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().groups.count(job->pos)) {
@ -226,7 +228,7 @@ namespace CSP {
// the job can be considered done // the job can be considered done
df::coord below(job->pos); df::coord below(job->pos);
below.z--; below.z--;
WARN(monitor).print(" -> Marking tile done and managing the group below.\n"); WARN(jobs).print(" -> Marking tile done and managing the group below.\n");
// mark done and manage below // mark done and manage below
block->designation[Coord(local)].bits.traffic = df::tile_traffic::Normal; block->designation[Coord(local)].bits.traffic = df::tile_traffic::Normal;
ChannelManager::Get().mark_done(job->pos); ChannelManager::Get().mark_done(job->pos);

@ -97,7 +97,7 @@ inline bool can_reach_designation(const df::coord &start, const df::coord &end)
df::coord neighbours[8]; df::coord neighbours[8];
get_neighbours(end, neighbours); get_neighbours(end, neighbours);
for (auto &pos : neighbours) { for (auto &pos : neighbours) {
if (Maps::canWalkBetween(start, pos)) { if (Maps::isValidTilePos(pos) && Maps::canWalkBetween(start, pos)) {
return true; return true;
} }
} }