diff --git a/docs/changelog.txt b/docs/changelog.txt index e51d7c5794..d96475f0ee 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -59,6 +59,8 @@ Template for new versions: ## Fixes - Fix mouse clicks bleeding through DFHack windows when clicking in the space between the frame and the window content in resizable windows - `autobutcher`: don't run a scanning and marking cycle on the first tick of a fortress to allow for all custom configuration to be set first +- `nestboxes`: don't consider eggs to be infertile just because the mother has left the nest; eggs can still hatch in this situation +- `timestream`: adjust the incubation counter on fertile eggs so they hatch at the expected time - `logistics`: don't ignore rotten items when applying stockpile logistics operations (e.g. autodump, autoclaim, etc.) ## Misc Improvements diff --git a/plugins/nestboxes.cpp b/plugins/nestboxes.cpp index 6f21628170..64cfcc301b 100644 --- a/plugins/nestboxes.cpp +++ b/plugins/nestboxes.cpp @@ -118,15 +118,13 @@ static void do_cycle(color_ostream &out) { cycle_timestamp = world->frame_counter; for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) { - bool fertile = false; - if (nb->claimed_by != -1) { - df::unit *u = df::unit::find(nb->claimed_by); - if (u && u->pregnancy_timer > 0) - fertile = true; - } for (auto &contained_item : nb->contained_items) { - auto *item = virtual_cast(contained_item->item); - if (item && item->flags.bits.forbid != fertile) { + if (contained_item->use_mode == df::building_item_role_type::PERM) + continue; + if (auto *item = virtual_cast(contained_item->item)) { + bool fertile = item->egg_flags.bits.fertile; + if (item->flags.bits.forbid == fertile) + continue; item->flags.bits.forbid = fertile; if (fertile && item->flags.bits.in_job) { // cancel any job involving the egg @@ -135,7 +133,7 @@ static void do_cycle(color_ostream &out) { if (sref && sref->data.job) Job::removeJob(sref->data.job); } - out.print("%d eggs %s.\n", item->getStackSize(), fertile ? "forbidden" : "unforbidden"); + out.print("nestboxes: %d eggs %s\n", item->getStackSize(), fertile ? "forbidden" : "unforbidden"); } } } diff --git a/plugins/timestream.cpp b/plugins/timestream.cpp index 0747a30371..512e3c215c 100644 --- a/plugins/timestream.cpp +++ b/plugins/timestream.cpp @@ -29,7 +29,9 @@ #include "df/activity_event_teach_topicst.h" #include "df/activity_event_writest.h" #include "df/activity_event_worshipst.h" +#include "df/building_nest_boxst.h" #include "df/init.h" +#include "df/item_eggst.h" #include "df/unit.h" #include "df/world.h" @@ -571,6 +573,22 @@ static void adjust_activities(color_ostream &out, int32_t timeskip) { } } +static void adjust_items(color_ostream &out, int32_t timeskip) { + // increment incubation counters for fertile eggs in non-forbidden nestboxes + for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) { + for (auto & contained_item : nb->contained_items) { + if (contained_item->use_mode == df::building_item_role_type::PERM) { + if (contained_item->item->flags.bits.forbid) + break; + else + continue; + } + if (auto *egg = virtual_cast(contained_item->item); egg && egg->egg_flags.bits.fertile) + increment_counter(egg, &df::item_eggst::incubation_counter, timeskip); + } + } +} + static void do_cycle(color_ostream &out) { DEBUG(cycle,out).print("running %s cycle\n", plugin_name); @@ -612,6 +630,7 @@ static void do_cycle(color_ostream &out) { adjust_units(out, timeskip); adjust_activities(out, timeskip); + adjust_items(out, timeskip); } /////////////////////////////////////////////////////