|
29 | 29 | #include "df/activity_event_teach_topicst.h" |
30 | 30 | #include "df/activity_event_writest.h" |
31 | 31 | #include "df/activity_event_worshipst.h" |
| 32 | +#include "df/building_nest_boxst.h" |
32 | 33 | #include "df/init.h" |
| 34 | +#include "df/item_eggst.h" |
33 | 35 | #include "df/unit.h" |
34 | 36 | #include "df/world.h" |
35 | 37 |
|
@@ -571,6 +573,22 @@ static void adjust_activities(color_ostream &out, int32_t timeskip) { |
571 | 573 | } |
572 | 574 | } |
573 | 575 |
|
| 576 | +static void adjust_items(color_ostream &out, int32_t timeskip) { |
| 577 | + // increment incubation counters for fertile eggs in non-forbidden nestboxes |
| 578 | + for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) { |
| 579 | + for (auto & contained_item : nb->contained_items) { |
| 580 | + if (contained_item->use_mode == df::building_item_role_type::PERM) { |
| 581 | + if (contained_item->item->flags.bits.forbid) |
| 582 | + break; |
| 583 | + else |
| 584 | + continue; |
| 585 | + } |
| 586 | + if (auto *egg = virtual_cast<df::item_eggst>(contained_item->item); egg && egg->egg_flags.bits.fertile) |
| 587 | + increment_counter(egg, &df::item_eggst::incubation_counter, timeskip); |
| 588 | + } |
| 589 | + } |
| 590 | +} |
| 591 | + |
574 | 592 | static void do_cycle(color_ostream &out) { |
575 | 593 | DEBUG(cycle,out).print("running %s cycle\n", plugin_name); |
576 | 594 |
|
@@ -612,6 +630,7 @@ static void do_cycle(color_ostream &out) { |
612 | 630 |
|
613 | 631 | adjust_units(out, timeskip); |
614 | 632 | adjust_activities(out, timeskip); |
| 633 | + adjust_items(out, timeskip); |
615 | 634 | } |
616 | 635 |
|
617 | 636 | ///////////////////////////////////////////////////// |
|
0 commit comments