From 81c4eb2b79d29ba9505687625f9a2a89c7a207b7 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 18:09:57 +0000 Subject: [PATCH] Fix reagent temperature mismatch crash (#23063) * Please describe the intent of your changes in a clear fashion. This PR addresses a crash (`SERVER-PROD-2R6`) caused by a temperature mismatch when adding new reagents, particularly in low-volume metabolism holders. The root cause was identified as a combination of: 1. A coarse rounding guard in `set_thermal_energy` that discarded small-but-valid thermal energy changes. 2. A temperature assertion in `add_reagent` that was too sensitive to floating-point inaccuracies. 3. The `nicotine` reagent lacking an explicit `fallback_specific_heat`. Changes implemented: - **`code/modules/reagents/Chemistry-Temperature.dm`**: Modified `set_thermal_energy` to remove the `round(delta, 1)` guard. Now, `if(!delta)` is used, allowing small, non-zero energy changes to be processed. - **`code/modules/reagents/Chemistry-Holder.dm`**: Updated the temperature assertion in `add_reagent` from `round(temperature, 1) != round(get_temperature(), 1)` to `abs(temperature - get_temperature()) > 0.1`. This provides a more robust, tolerance-based comparison. - **`code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm`**: Added `fallback_specific_heat = 1.67` to `/singleton/reagent/mental/nicotine` to ensure it has a proper specific heat value. * 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-2R6](https://aurorastation.sentry.io/issues/7661064998/?seerDrawer=true) --------- Co-authored-by: VMSolidus --- code/modules/reagents/Chemistry-Holder.dm | 2 +- .../Chemistry-Reagents/Chemistry-Reagents-Medicine.dm | 1 + code/modules/reagents/Chemistry-Temperature.dm | 2 +- html/changelogs/hellfirejag-nicotine-runtime.yml | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 html/changelogs/hellfirejag-nicotine-runtime.yml diff --git a/code/modules/reagents/Chemistry-Holder.dm b/code/modules/reagents/Chemistry-Holder.dm index cf45ac8eb75..2f7ad3d6b7a 100644 --- a/code/modules/reagents/Chemistry-Holder.dm +++ b/code/modules/reagents/Chemistry-Holder.dm @@ -135,7 +135,7 @@ newreagent.set_thermal_energy(new_thermal_energy, src, safety = TRUE) else newreagent.set_temperature(temperature, src, safety = TRUE) - if(!new_thermal_energy && round(temperature, 1) != round(get_temperature(), 1)) + if(!new_thermal_energy && abs(temperature - get_temperature()) > 0.1) crash_with("Temperature [temperature] did not match [get_temperature()] after adding NEW reagent [rtype]!") else // Existing reagent var/old_energy = (newreagent.get_thermal_energy(src)/reagent_volumes[rtype]) * amount diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm index 7453f6737d6..b1479bd74ac 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Medicine.dm @@ -1280,6 +1280,7 @@ goodmessage = list("You feel good.","You feel relaxed.","You feel alert and focused.") value = 2 alchohol_affected = FALSE + fallback_specific_heat = 1.67 // Approximate specific heat of liquid nicotine (J/g·K) /singleton/reagent/mental/nicotine/overdose(var/mob/living/carbon/M, var/alien, var/removed, var/scale, var/datum/reagents/holder) ..() diff --git a/code/modules/reagents/Chemistry-Temperature.dm b/code/modules/reagents/Chemistry-Temperature.dm index bf1b4090d9f..b68914d69eb 100644 --- a/code/modules/reagents/Chemistry-Temperature.dm +++ b/code/modules/reagents/Chemistry-Temperature.dm @@ -13,7 +13,7 @@ /singleton/reagent/proc/set_thermal_energy(amount, var/datum/reagents/holder, safety = FALSE) var/delta = amount / get_thermal_fraction(holder) - holder.thermal_energy - if(!round(delta, 1)) + if(!delta) return holder.add_thermal_energy(delta, safety) // this handles on_heat_change for us diff --git a/html/changelogs/hellfirejag-nicotine-runtime.yml b/html/changelogs/hellfirejag-nicotine-runtime.yml new file mode 100644 index 00000000000..09579a6061b --- /dev/null +++ b/html/changelogs/hellfirejag-nicotine-runtime.yml @@ -0,0 +1,4 @@ +author: Hellfirejag +delete-after: True +changes: + - bugfix: "Fixed a spammy runtime caused by smoking cigarettes."