| 730 | } |
| 731 | |
| 732 | static void manageNewUnitActiveEvent(color_ostream& out) { |
| 733 | if (!df::global::world) |
| 734 | return; |
| 735 | |
| 736 | multimap<Plugin*,EventHandler> copy(handlers[EventType::UNIT_NEW_ACTIVE].begin(), handlers[EventType::UNIT_NEW_ACTIVE].end()); |
| 737 | unordered_set<int32_t> next_activeUnits; |
| 738 | vector<int32_t> newly_active_unit_ids; |
| 739 | for (df::unit* unit : df::global::world->units.active) { |
| 740 | if (!Units::isActive(unit)) |
| 741 | continue; |
| 742 | next_activeUnits.emplace(unit->id); |
| 743 | if (!activeUnits.count(unit->id)) |
| 744 | newly_active_unit_ids.emplace_back(unit->id); |
| 745 | } |
| 746 | for (int32_t unit_id : newly_active_unit_ids) { |
| 747 | for (auto &[_,handle] : copy) { |
| 748 | DEBUG(log,out).print("calling handler for new unit event\n"); |
| 749 | run_handler(out, EventType::UNIT_NEW_ACTIVE, handle, (void*) intptr_t(unit_id)); // intptr_t() avoids cast from smaller type warning |
| 750 | } |
| 751 | } |
| 752 | activeUnits = std::move(next_activeUnits); |
| 753 | } |
| 754 | |
| 755 | |
| 756 | static void manageUnitDeathEvent(color_ostream& out) { |
nothing calls this directly
no test coverage detected