Merge remote-tracking branch 'lethosor/nestboxes-fix-forbid' into develop

develop
lethosor 2023-02-10 23:30:55 -05:00
commit c89b61a3d5
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 4 additions and 2 deletions

@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins ## New Plugins
## Fixes ## Fixes
-@ `nestboxes`: fixed bug causing nestboxes themselves to be forbidden, which prevented citizens from using them to lay eggs. Now only eggs are forbidden.
## Misc Improvements ## Misc Improvements

@ -9,6 +9,7 @@
#include "df/world.h" #include "df/world.h"
#include "df/building_nest_boxst.h" #include "df/building_nest_boxst.h"
#include "df/item.h" #include "df/item.h"
#include "df/item_eggst.h"
#include "df/unit.h" #include "df/unit.h"
using std::string; using std::string;
@ -140,8 +141,8 @@ static void do_cycle(color_ostream &out) {
fertile = true; fertile = true;
} }
for (auto &contained_item : nb->contained_items) { for (auto &contained_item : nb->contained_items) {
df::item *item = contained_item->item; auto *item = virtual_cast<df::item_eggst>(contained_item->item);
if (item->flags.bits.forbid != fertile) { if (item && item->flags.bits.forbid != fertile) {
item->flags.bits.forbid = fertile; item->flags.bits.forbid = fertile;
if (fertile && item->flags.bits.in_job) { if (fertile && item->flags.bits.in_job) {
// cancel any job involving the egg // cancel any job involving the egg