| 264 | } |
| 265 | |
| 266 | void JobCompletedEvent(color_ostream &out, void* j) { |
| 267 | if (enabled && World::isFortressMode() && Maps::IsValid()) { |
| 268 | TRACE(jobs).print("JobCompletedEvent()\n"); |
| 269 | auto job = (df::job*) j; |
| 270 | // we only care if the job is a channeling one |
| 271 | if (ChannelManager::Get().exists(job->pos)) { |
| 272 | ChannelManager::Get().manage_group(job->pos, true, false); |
| 273 | // check job outcome |
| 274 | auto block = Maps::getTileBlock(job->pos); |
| 275 | df::coord local(job->pos); |
| 276 | local.x = local.x % 16; |
| 277 | local.y = local.y % 16; |
| 278 | // verify completion |
| 279 | if (TileCache::Get().hasChanged(job->pos, block->tiletype[Coord(local)])) { |
| 280 | // the job can be considered done |
| 281 | df::coord below(job->pos); |
| 282 | below.z--; |
| 283 | DEBUG(jobs).print(" -> (" COORD ") is marked done, managing group below.\n", COORDARGS(job->pos)); |
| 284 | // mark done and manage below (and the rest of the group, if there were cavein candidates) |
| 285 | block->designation[Coord(local)].bits.traffic = df::tile_traffic::Normal; |
| 286 | ChannelManager::Get().mark_done(job->pos); |
| 287 | ChannelManager::Get().manage_group(below); |
| 288 | if (config.resurrect) { |
| 289 | // this is the only place we can be 100% sure of "safety" |
| 290 | // (excluding deadly enemies that may have arrived, and future digging) |
| 291 | if (active_workers.count(job->id)) { |
| 292 | df::unit* worker = active_workers[job->id]; |
| 293 | last_safe[worker->id] = worker->pos; |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | // clean up |
| 298 | auto jp = active_jobs[job->id]; |
| 299 | job_id_map.erase(jp); |
| 300 | active_workers.erase(job->id); |
| 301 | active_jobs.erase(job->id); |
| 302 | } |
| 303 | TRACE(jobs).print("JobCompletedEvent() exits\n"); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | void NewReportEvent(color_ostream &out, void* r) { |
| 308 | int32_t tick = world->frame_counter; |
nothing calls this directly
no test coverage detected