Merge pull request #2853 from myk002/myk_nestboxes_job

[nestboxes] remove in-progress jobs when protecting fert eggs
develop
Myk 2023-02-09 00:04:30 -08:00 committed by GitHub
commit 30ad6c9e4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `channel-safely`: fixed bug resulting in marker mode never being set for any designation
-@ `automelt`: fixed bug related to lua stack smashing behavior in returned stockpile configs
-@ `autochop`: fixed bug related to lua stack smashing behavior in returned stockpile configs
- `nestboxes`: now cancels any in-progress hauling jobs when it protects a fertile egg
## Misc Improvements
- `automelt`: is now more resistent to savegame corruption

@ -1,6 +1,8 @@
#include "Debug.h"
#include "PluginManager.h"
#include "modules/Items.h"
#include "modules/Job.h"
#include "modules/Persistence.h"
#include "modules/World.h"
@ -141,6 +143,13 @@ static void do_cycle(color_ostream &out) {
df::item *item = contained_item->item;
if (item->flags.bits.forbid != fertile) {
item->flags.bits.forbid = fertile;
if (fertile && item->flags.bits.in_job) {
// cancel any job involving the egg
df::specific_ref *sref = Items::getSpecificRef(
item, df::specific_ref_type::JOB);
if (sref && sref->data.job)
Job::removeJob(sref->data.job);
}
out.print("%d eggs %s.\n", item->getStackSize(), fertile ? "forbidden" : "unforbidden");
}
}