| 182 | // |
| 183 | |
| 184 | static void do_cycle(color_ostream &out) { |
| 185 | DEBUG(cycle,out).print("running {} cycle\n", plugin_name); |
| 186 | |
| 187 | // mark that we have recently run |
| 188 | cycle_timestamp = world->frame_counter; |
| 189 | |
| 190 | // see if egg protection is limited to a burrow |
| 191 | auto burrow = getBurrow(out); |
| 192 | |
| 193 | for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) { |
| 194 | for (auto &contained_item : nb->contained_items) { |
| 195 | if (contained_item->use_mode == df::building_item_role_type::PERM) |
| 196 | continue; |
| 197 | if (auto *item = virtual_cast<df::item_eggst>(contained_item->item)) { |
| 198 | bool fertile = item->egg_flags.bits.fertile; |
| 199 | if (item->flags.bits.forbid == fertile) |
| 200 | continue; |
| 201 | if (burrow && !Burrows::isAssignedTile(burrow, Items::getPosition(item))) { |
| 202 | continue; |
| 203 | } |
| 204 | item->flags.bits.forbid = fertile; |
| 205 | if (fertile && item->flags.bits.in_job) { |
| 206 | // cancel any job involving the egg |
| 207 | df::specific_ref *sref = Items::getSpecificRef( |
| 208 | item, df::specific_ref_type::JOB); |
| 209 | if (sref && sref->data.job) |
| 210 | Job::removeJob(sref->data.job); |
| 211 | } |
| 212 | out.print("nestboxes: {} eggs {}\n", item->getStackSize(), fertile ? "forbidden" : "unforbidden"); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
no test coverage detected