| 781 | } |
| 782 | |
| 783 | static void manageItemCreationEvent(color_ostream& out) { |
| 784 | if (!df::global::world) |
| 785 | return; |
| 786 | if (!df::global::item_next_id) |
| 787 | return; |
| 788 | if ( nextItem >= *df::global::item_next_id ) { |
| 789 | return; |
| 790 | } |
| 791 | |
| 792 | multimap<Plugin*,EventHandler> copy(handlers[EventType::ITEM_CREATED].begin(), handlers[EventType::ITEM_CREATED].end()); |
| 793 | size_t index = df::item::binsearch_index(df::global::world->items.all, nextItem, false); |
| 794 | if ( index != 0 ) index--; |
| 795 | |
| 796 | std::vector<int32_t> created_items; |
| 797 | for ( size_t a = index; a < df::global::world->items.all.size(); a++ ) { |
| 798 | df::item* item = df::global::world->items.all[a]; |
| 799 | //already processed |
| 800 | if ( item->id < nextItem ) |
| 801 | continue; |
| 802 | //invaders |
| 803 | if ( item->flags.bits.foreign ) |
| 804 | continue; |
| 805 | //traders who bring back your items? |
| 806 | if ( item->flags.bits.trader ) |
| 807 | continue; |
| 808 | //migrants |
| 809 | if ( item->flags.bits.owned ) |
| 810 | continue; |
| 811 | //spider webs don't count |
| 812 | if ( item->flags.bits.spider_web ) |
| 813 | continue; |
| 814 | created_items.push_back(item->id); |
| 815 | } |
| 816 | |
| 817 | // handle all created items |
| 818 | for (int32_t item_id : created_items) { |
| 819 | for (auto &[_,handle] : copy) { |
| 820 | DEBUG(log,out).print("calling handler for item created event\n"); |
| 821 | run_handler(out, EventType::ITEM_CREATED, handle, (void*)intptr_t(item_id)); |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | nextItem = *df::global::item_next_id; |
| 826 | } |
| 827 | |
| 828 | static void manageBuildingEvent(color_ostream& out) { |
| 829 | if (!df::global::world) |
nothing calls this directly
no test coverage detected