@@ -413,23 +413,35 @@ local function handle_eggs(eggs)
413413 print_details ((" Total count for %s eggs is %s" ):format (race , total_count ))
414414
415415 if total_count - current_eggs < max_eggs then
416+ local egg_count_to_leave_in_source_stack = current_eggs
416417 if state .split_stacks and total_count > max_eggs then
417- local egg_count_to_leave_in_source_stack = max_eggs - total_count + current_eggs
418+ egg_count_to_leave_in_source_stack = max_eggs - total_count + current_eggs
418419 split_egg_stack (eggs , egg_count_to_leave_in_source_stack )
419420 end
420421
421422 eggs .flags .forbid = true
423+
424+ if eggs .flags .in_job then
425+ local job_ref = dfhack .items .getSpecificRef (eggs , df .specific_ref_type .JOB )
426+ if job_ref then
427+ print_details ((" About to remove job related to egg(s)" ))
428+ dfhack .job .removeJob (job_ref .data .job )
429+ eggs .flags .in_job = false
430+ end
431+ end
432+
422433 print_local (
423- (" Previously existing %s eggs is %s lower than maximum %s , forbidden %s new eggs. " ):format (
434+ (" Previously existing %s egg(s) is %s lower than maximum %s , forbidden %s egg(s) out of %s new " ):format (
424435 race ,
425436 total_count - current_eggs ,
426437 max_eggs ,
438+ egg_count_to_leave_in_source_stack ,
427439 current_eggs
428440 )
429441 )
430442 else
431443 print_local (
432- (" Total count for %s eggs is %s over maximum %s, newly laid eggs %s , no action taken." ):format (
444+ (" Total count for %s egg(s) is %s over maximum %s, newly laid egg(s) %s , no action taken." ):format (
433445 race ,
434446 total_count ,
435447 max_eggs ,
0 commit comments