From 148d048bc8e930776bdc1557693a7cd6ee199507 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:05:27 +0200 Subject: [PATCH] Fixes null.b_type error in handle_rejection (#22556) * Please describe the intent of your changes in a clear fashion. The `handle_rejection()` proc in `code/modules/organs/organ.dm` was attempting to access `owner.dna.b_type` without first verifying that `owner` or `owner.dna` were non-null. This could happen if an organ's `process()` chain continued to tick after the organ had been detached from its mob, leading to a runtime error. This change adds an early return guard `if(!owner || !owner.dna) return` at the beginning of the `handle_rejection()` proc. This prevents the null dereference and aligns the proc's behavior with similar checks found in `handle_germ_effects()`. * Please make sure that, in the case of mapping changes, you include images of these changes in the PR's description. * Please make sure to mark your PR as wip or review required by making a comment with !wip or !review required * If you include sprites/sounds/... (assets) that you have not created yourself specify the license and original author below. * Ensure that you also credit them in the appropriate location / changelog as specified in the contributor guidelines ### Asset Licenses The following assets that **have not** been created by myself are included in this PR: | Path | Original Author | License | | --- | --- | --- | | icons/example.dmi | ExamplePerson (Example Station) | CC0 | Fixes SERVER-PROD-CN --------- Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> Co-authored-by: VMSolidus --- code/modules/organs/organ.dm | 36 ++++++++++--------- .../hellfirejag-organ-transplant-runtime.yml | 4 +++ 2 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 html/changelogs/hellfirejag-organ-transplant-runtime.yml diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index d175fb42c53..19c1e52e860 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -251,23 +251,25 @@ INITIALIZE_IMMEDIATE(/obj/item/organ) /obj/item/organ/proc/handle_rejection() // Process unsuitable transplants. - if(dna) - if(!rejecting) - if(blood_incompatible(dna.b_type, owner.dna.b_type, species, owner.species)) - rejecting = 1 - else - rejecting++ //Rejection severity increases over time. - if(rejecting % 10 == 0) //Only fire every ten rejection ticks. - switch(rejecting) - if(1 to 50) - germ_level++ - if(51 to 200) - germ_level += rand(1,2) - if(201 to 500) - germ_level += rand(2,3) - if(501 to INFINITY) - germ_level += rand(3,5) - owner.reagents.add_reagent(/singleton/reagent/toxin, rand(1,2)) + if(!owner || !owner.dna || !dna) + return + + if(!rejecting && blood_incompatible(dna.b_type, owner.dna.b_type, species, owner.species)) + rejecting = 1 + return + + rejecting++ //Rejection severity increases over time. + if(rejecting % 10 == 0) //Only fire every ten rejection ticks. + switch(rejecting) + if(1 to 50) + germ_level++ + if(51 to 200) + germ_level += rand(1,2) + if(201 to 500) + germ_level += rand(2,3) + if(501 to INFINITY) + germ_level += rand(3,5) + owner.reagents.add_reagent(/singleton/reagent/toxin, rand(1,2)) /obj/item/organ/proc/receive_chem(chemical as obj) return 0 diff --git a/html/changelogs/hellfirejag-organ-transplant-runtime.yml b/html/changelogs/hellfirejag-organ-transplant-runtime.yml new file mode 100644 index 00000000000..4d42a97ba84 --- /dev/null +++ b/html/changelogs/hellfirejag-organ-transplant-runtime.yml @@ -0,0 +1,4 @@ +author: Hellfirejag +delete-after: True +changes: + - bugfix: "Fixed a runtime error in organ rejection."