Skip to content

Commit

Permalink
Fix two gas assertion runtimes (tgstation#53718)
Browse files Browse the repository at this point in the history
/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.
  • Loading branch information
Timberpoes authored Sep 15, 2020
1 parent 8a6fc43 commit 96f4c2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions code/game/machinery/electrolyzer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions code/modules/events/crystal_event.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96f4c2f

Please sign in to comment.