From e3bbcbb1d391b1f494c5bc7ee3058f84d57e68cb Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 16 Sep 2020 02:29:24 +0200 Subject: [PATCH] [MIRROR] Fix two gas assertion runtimes (#816) * Fix two gas assertion runtimes (#53718) /datum/gas_mixture/proc/remove(amount) has a code path that can return null. All the code following the runtimes assume some bit of gas_mixture was actually removed at all. No need to trigger this code if there's no gas_mixture removed, can early return instead. * Fix two gas assertion runtimes Co-authored-by: Timberpoes --- code/game/machinery/electrolyzer.dm | 4 ++++ code/modules/events/crystal_event.dm | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/code/game/machinery/electrolyzer.dm b/code/game/machinery/electrolyzer.dm index e2954b91005..59079a8324a 100644 --- a/code/game/machinery/electrolyzer.dm +++ b/code/game/machinery/electrolyzer.dm @@ -92,6 +92,10 @@ var/datum/gas_mixture/env = L.return_air() //get air from the turf var/datum/gas_mixture/removed = env.remove(0.1 * env.total_moles()) + + if(!removed) + return + removed.assert_gases(/datum/gas/water_vapor, /datum/gas/oxygen, /datum/gas/hydrogen) var/proportion = min(removed.gases[/datum/gas/water_vapor][MOLES], (1.5 * delta_time * workingPower))//Works to max 12 moles at a time. removed.gases[/datum/gas/water_vapor][MOLES] -= proportion * 2 * workingPower diff --git a/code/modules/events/crystal_event.dm b/code/modules/events/crystal_event.dm index 5965893fe15..65d35f75673 100644 --- a/code/modules/events/crystal_event.dm +++ b/code/modules/events/crystal_event.dm @@ -363,6 +363,10 @@ This section is for the destabilized SM var/datum/gas_mixture/removed var/gasefficency = 0.5 removed = env.remove(gasefficency * env.total_moles()) + + if(!removed) + return + removed.assert_gases(/datum/gas/bz, /datum/gas/miasma) if(!removed || !removed.total_moles() || isspaceturf(loc_turf)) removed.gases[/datum/gas/bz][MOLES] += 0.5