From 09311187e1f02896a3d9eb961b002259cf1bd01d Mon Sep 17 00:00:00 2001 From: AbsFree Date: Sat, 8 Mar 2025 08:50:41 +0100 Subject: [PATCH 1/3] fixed division by zero issue --- .../code/mechanics/fattening_gasses.dm | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/GainStation13/code/mechanics/fattening_gasses.dm b/GainStation13/code/mechanics/fattening_gasses.dm index f376645b05..421f6cef84 100644 --- a/GainStation13/code/mechanics/fattening_gasses.dm +++ b/GainStation13/code/mechanics/fattening_gasses.dm @@ -1,26 +1,28 @@ /obj/item/organ/lungs/proc/lipoifium_breathing(datum/gas_mixture/breath, mob/living/carbon/human/H) - if(breath) - var/pressure = breath.return_pressure() - var/total_moles = breath.total_moles() - var/lipoifium_moles = breath.get_moles(GAS_FAT) - #define PP_MOLES(X) ((X / total_moles) * pressure) - var/gas_breathed = PP_MOLES(lipoifium_moles) // this does the same thing as the bit below but I think this is more readable - // #define PP(air, gas) PP_MOLES(air.get_moles(gas)) - // var/gas_breathed = PP(breath, GAS_FAT) - if(gas_breathed > 0) - // listen I know I can debug this but sometimes having this show up in chat without a pause is more convenient - // message_admins("Lipoifium pp is [gas_breathed]") - // message_admins("Lipoifium moles are [lipoifium_moles]") - H.adjust_fatness(2 * gas_breathed, FATTENING_TYPE_ATMOS) - breath.adjust_moles(GAS_FAT, -gas_breathed) - // TODO: the entire code below is a workaround for default odor not working - // The problem seems to be auxmos'es get_gasses function not acknowledging that lipoifium exists - // which is strange, considering that everything else regarding this gas and auxmos works - // I do not know what kind of spaghetti coding must be going on there, but I pray god has in his - // care the poor sods who have to work on that - var/smell_chance = min(lipoifium_moles * 100 / total_moles, 20) - if(prob(smell_chance)) - to_chat(owner, "You can smell lard.") + if(!breath) + return + + if(breath.total_moles() == 0) + return + + var/pressure = breath.return_pressure() + var/total_moles = breath.total_moles() + var/lipoifium_moles = breath.get_moles(GAS_FAT) + #define PP_MOLES(X) ((X / total_moles) * pressure) + var/gas_breathed = PP_MOLES(lipoifium_moles) // this does the same thing as the bit below but I think this is more readable + // #define PP(air, gas) PP_MOLES(air.get_moles(gas)) + // var/gas_breathed = PP(breath, GAS_FAT) + if(gas_breathed <= 0) + return + + H.adjust_fatness(gas_breathed, FATTENING_TYPE_ATMOS) + breath.adjust_moles(GAS_FAT, -gas_breathed) + // TODO: the entire code below is a workaround for default odor not working + // The problem seems to be auxmos'es get_gasses function not acknowledging that lipoifium exists + // which is strange, considering that everything else regarding this gas and auxmos works + var/smell_chance = min(lipoifium_moles * 100 / total_moles, 20) + if(prob(smell_chance)) + to_chat(owner, "You can smell lard.") /obj/item/organ/lungs/check_breath(datum/gas_mixture/breath, mob/living/carbon/human/H) From e8c16e3d3fc142ffec926b732127a3beed617d17 Mon Sep 17 00:00:00 2001 From: AbsFree Date: Sat, 8 Mar 2025 10:01:46 +0100 Subject: [PATCH 2/3] tweaks to the way lipoifium calculates fat gained --- GainStation13/code/mechanics/fattening_gasses.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GainStation13/code/mechanics/fattening_gasses.dm b/GainStation13/code/mechanics/fattening_gasses.dm index 421f6cef84..6043845fd6 100644 --- a/GainStation13/code/mechanics/fattening_gasses.dm +++ b/GainStation13/code/mechanics/fattening_gasses.dm @@ -15,8 +15,8 @@ if(gas_breathed <= 0) return - H.adjust_fatness(gas_breathed, FATTENING_TYPE_ATMOS) - breath.adjust_moles(GAS_FAT, -gas_breathed) + H.adjust_fatness(lipoifium_moles * 1500, FATTENING_TYPE_ATMOS) + breath.set_moles(GAS_FAT, 0) // TODO: the entire code below is a workaround for default odor not working // The problem seems to be auxmos'es get_gasses function not acknowledging that lipoifium exists // which is strange, considering that everything else regarding this gas and auxmos works From b86163559b35fffed3f90828064ea8e132931fc4 Mon Sep 17 00:00:00 2001 From: AbsFree Date: Sat, 8 Mar 2025 10:08:09 +0100 Subject: [PATCH 3/3] simplified the code --- GainStation13/code/mechanics/fattening_gasses.dm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/GainStation13/code/mechanics/fattening_gasses.dm b/GainStation13/code/mechanics/fattening_gasses.dm index 6043845fd6..216f105fb1 100644 --- a/GainStation13/code/mechanics/fattening_gasses.dm +++ b/GainStation13/code/mechanics/fattening_gasses.dm @@ -5,14 +5,10 @@ if(breath.total_moles() == 0) return - var/pressure = breath.return_pressure() var/total_moles = breath.total_moles() var/lipoifium_moles = breath.get_moles(GAS_FAT) - #define PP_MOLES(X) ((X / total_moles) * pressure) - var/gas_breathed = PP_MOLES(lipoifium_moles) // this does the same thing as the bit below but I think this is more readable - // #define PP(air, gas) PP_MOLES(air.get_moles(gas)) - // var/gas_breathed = PP(breath, GAS_FAT) - if(gas_breathed <= 0) + #define PP_MOLES(X) ((X / total_moles) * pressure) // this needs to be here because spaghetti, I'm sorry + if(lipoifium_moles <= 0) return H.adjust_fatness(lipoifium_moles * 1500, FATTENING_TYPE_ATMOS)