| 443 | } |
| 444 | |
| 445 | static void manageTickEvent(color_ostream& out) { |
| 446 | if (!df::global::world) |
| 447 | return; |
| 448 | unordered_set<EventHandler> toRemove; |
| 449 | int32_t tick = df::global::world->frame_counter; |
| 450 | while ( !tickQueue.empty() ) { |
| 451 | if ( tick < (*tickQueue.begin()).first ) |
| 452 | break; |
| 453 | EventHandler &handle = (*tickQueue.begin()).second; |
| 454 | tickQueue.erase(tickQueue.begin()); |
| 455 | DEBUG(log,out).print("calling handler for tick event\n"); |
| 456 | run_handler(out, EventType::TICK, handle, (void*)intptr_t(tick)); |
| 457 | toRemove.insert(handle); |
| 458 | } |
| 459 | if ( toRemove.empty() ) |
| 460 | return; |
| 461 | for ( auto a = handlers[EventType::TICK].begin(); a != handlers[EventType::TICK].end(); ) { |
| 462 | EventHandler &handle = (*a).second; |
| 463 | if ( toRemove.find(handle) == toRemove.end() ) { |
| 464 | a++; |
| 465 | continue; |
| 466 | } |
| 467 | a = handlers[EventType::TICK].erase(a); |
| 468 | toRemove.erase(handle); |
| 469 | if ( toRemove.empty() ) |
| 470 | break; |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | static void manageJobInitiatedEvent(color_ostream& out) { |
| 475 | if (!df::global::world) |