diff --git a/code/ZAS/ConnectionGroup.dm b/code/ZAS/ConnectionGroup.dm
index 78a1d43b8f4..322c24be1c2 100644
--- a/code/ZAS/ConnectionGroup.dm
+++ b/code/ZAS/ConnectionGroup.dm
@@ -208,7 +208,8 @@ Class Procs:
src.A = A
src.B = B
LAZYADD(A.edges, src)
- air = B.return_air()
+ if(B)
+ air = B.return_air()
//id = 52*A.id
// log_debug("New edge from [A] to [B].")
diff --git a/code/_helpers/turfs.dm b/code/_helpers/turfs.dm
index 5921702ab81..c64a7926333 100644
--- a/code/_helpers/turfs.dm
+++ b/code/_helpers/turfs.dm
@@ -179,8 +179,9 @@
/proc/air_sound(atom/source, var/required_pressure = SOUND_MINIMUM_PRESSURE)
var/turf/T = get_turf(source)
+ if(!istype(T)) return FALSE
var/datum/gas_mixture/environment = T.return_air()
var/pressure = (environment)? environment.return_pressure() : 0
if(pressure < required_pressure)
return FALSE
- return TRUE
\ No newline at end of file
+ return TRUE
diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index 550171c2607..f9721dfcbf0 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -47,8 +47,6 @@
/atom/proc/return_air()
if(loc)
return loc.return_air()
- else
- return null
// Returns src and all recursive contents in a list.
/atom/proc/GetAllContents()
diff --git a/code/game/gamemodes/technomancer/spells/radiance.dm b/code/game/gamemodes/technomancer/spells/radiance.dm
index f6595f984fe..b3f9dcbdf4b 100644
--- a/code/game/gamemodes/technomancer/spells/radiance.dm
+++ b/code/game/gamemodes/technomancer/spells/radiance.dm
@@ -30,6 +30,7 @@
/obj/item/spell/radiance/process()
var/turf/T = get_turf(src)
+ if(!istype(T)) return
var/datum/gas_mixture/removed = null
var/datum/gas_mixture/env = null
var/adjusted_power = calculate_spell_power(power)
diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm
index 10d40aa35fc..8a71e878f92 100644
--- a/code/game/machinery/alarm.dm
+++ b/code/game/machinery/alarm.dm
@@ -500,6 +500,7 @@
/obj/machinery/alarm/proc/populate_status(var/data)
var/turf/location = get_turf(src)
+ if(!istype(location)) return
var/datum/gas_mixture/environment = location.return_air()
var/total = environment.total_moles
diff --git a/code/game/machinery/atmoalter/canister.dm b/code/game/machinery/atmoalter/canister.dm
index 35dd8c0dc88..ea826c78b37 100644
--- a/code/game/machinery/atmoalter/canister.dm
+++ b/code/game/machinery/atmoalter/canister.dm
@@ -241,8 +241,9 @@ update_flag
var/datum/gas_mixture/environment
if(holding)
environment = holding.air_contents
- else
+ else if(loc)
environment = loc.return_air()
+ else return
var/env_pressure = environment.return_pressure()
var/pressure_delta = release_pressure - env_pressure
diff --git a/code/game/machinery/atmoalter/pump.dm b/code/game/machinery/atmoalter/pump.dm
index ce8c0b0fc35..4e825e597ae 100644
--- a/code/game/machinery/atmoalter/pump.dm
+++ b/code/game/machinery/atmoalter/pump.dm
@@ -73,8 +73,9 @@
var/datum/gas_mixture/environment
if(holding)
environment = holding.air_contents
- else
+ else if(loc)
environment = loc.return_air()
+ else return
var/pressure_delta
var/output_volume
diff --git a/code/game/machinery/atmoalter/scrubber.dm b/code/game/machinery/atmoalter/scrubber.dm
index 6b6a211f939..56c80edd8a8 100644
--- a/code/game/machinery/atmoalter/scrubber.dm
+++ b/code/game/machinery/atmoalter/scrubber.dm
@@ -63,8 +63,9 @@
var/datum/gas_mixture/environment
if(holding)
environment = holding.air_contents
- else
+ else if(loc)
environment = loc.return_air()
+ else return
var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles
@@ -196,6 +197,8 @@
var/power_draw = -1
+ if(!loc)
+ return
var/datum/gas_mixture/environment = loc.return_air()
var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles
diff --git a/code/game/machinery/cryo.dm b/code/game/machinery/cryo.dm
index 67a4e2bffcb..e6270b89e7c 100644
--- a/code/game/machinery/cryo.dm
+++ b/code/game/machinery/cryo.dm
@@ -403,8 +403,6 @@
//draws from the cryo tube's environment, instead of the cold internal air.
if(loc)
return loc.return_air()
- else
- return null
/datum/data/function/proc/reset()
return
diff --git a/code/game/machinery/overview.dm b/code/game/machinery/overview.dm
index 6665d9ff901..8cce48c1479 100644
--- a/code/game/machinery/overview.dm
+++ b/code/game/machinery/overview.dm
@@ -41,7 +41,7 @@
- if(!T)
+ if(!isturf(T))
colour = rgb(0,0,0)
else
@@ -119,7 +119,7 @@
colour = rgb(red, green, blue)
- if(!colour2 && !T.density)
+ if(!colour2 && isturf(T) && !T.density)
var/datum/gas_mixture/environment = T.return_air()
var/turf_total = environment.total_moles()
//var/turf_total = T.co2 + T.oxygen + T.poison + T.sl_gas + T.n2
@@ -342,4 +342,3 @@ proc/getb(col)
mapobjs = null
src.unset_machine()
-
diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm
index b802a735f37..c5114ba407d 100644
--- a/code/game/machinery/spaceheater.dm
+++ b/code/game/machinery/spaceheater.dm
@@ -167,7 +167,7 @@
/obj/machinery/space_heater/process()
- if(on)
+ if(on && loc)
if(cell && cell.charge)
var/datum/gas_mixture/env = loc.return_air()
if(env && abs(env.temperature - set_temperature) <= 0.1)
diff --git a/code/game/machinery/telecomms/telecommunications.dm b/code/game/machinery/telecomms/telecommunications.dm
index 4a15063df1f..ced5b9269a5 100644
--- a/code/game/machinery/telecomms/telecommunications.dm
+++ b/code/game/machinery/telecomms/telecommunications.dm
@@ -138,6 +138,7 @@
/obj/machinery/telecomms/proc/check_heat()
// Checks heat from the environment and applies any integrity damage
+ if(!loc) return
var/datum/gas_mixture/environment = loc.return_air()
var/damage_chance = 0 // Percent based chance of applying 1 integrity damage this tick
switch(environment.temperature)
diff --git a/code/game/objects/items/airbubble.dm b/code/game/objects/items/airbubble.dm
index 4094ca59610..b36814b3248 100644
--- a/code/game/objects/items/airbubble.dm
+++ b/code/game/objects/items/airbubble.dm
@@ -580,8 +580,7 @@
/obj/structure/closet/airbubble/proc/get_turf_air()
var/turf/T = get_turf(src)
if(T)
- . = T.return_air()
- return
+ return T.return_air()
/obj/structure/closet/airbubble/proc/return_pressure()
. = 0
diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm
index 997c4020fb6..be16c295b88 100644
--- a/code/game/objects/items/devices/scanners.dm
+++ b/code/game/objects/items/devices/scanners.dm
@@ -377,9 +377,9 @@ BREATH ANALYZER
origin_tech = list(TECH_MAGNET = 1, TECH_ENGINEERING = 1)
/obj/item/device/analyzer/atmosanalyze(var/mob/user)
+ if(!user) return
var/air = user.return_air()
- if (!air)
- return
+ if (!air) return
return atmosanalyzer_scan(src, air, user)
diff --git a/code/game/objects/items/devices/suit_cooling.dm b/code/game/objects/items/devices/suit_cooling.dm
index 31bd9ae6ff4..abdd94afb49 100644
--- a/code/game/objects/items/devices/suit_cooling.dm
+++ b/code/game/objects/items/devices/suit_cooling.dm
@@ -84,7 +84,7 @@
return C.air_contents.temperature
var/turf/T = get_turf(src)
- if(istype(T, /turf/space))
+ if(istype(T, /turf/space) || !isturf(T))
return FALSE //space has no temperature, this just makes sure the cooling unit works in space
var/datum/gas_mixture/environment = T.return_air()
diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm
index 6f1490336d4..d3ac84da23a 100644
--- a/code/game/objects/objs.dm
+++ b/code/game/objects/objs.dm
@@ -101,8 +101,6 @@
/obj/return_air()
if(loc)
return loc.return_air()
- else
- return null
/obj/proc/updateUsrDialog()
if(in_use)
diff --git a/code/game/objects/structures/pit.dm b/code/game/objects/structures/pit.dm
index 52d2190c2c9..01104a051ed 100644
--- a/code/game/objects/structures/pit.dm
+++ b/code/game/objects/structures/pit.dm
@@ -62,8 +62,6 @@
/obj/structure/pit/return_air()
if(open && loc)
return loc.return_air()
- else
- return null
/obj/structure/pit/proc/digout(mob/escapee)
var/breakout_time = 1 //2 minutes by default
diff --git a/code/game/objects/structures/transit_tubes.dm b/code/game/objects/structures/transit_tubes.dm
index 8ef4bb7c928..ea63f61e6ef 100644
--- a/code/game/objects/structures/transit_tubes.dm
+++ b/code/game/objects/structures/transit_tubes.dm
@@ -366,6 +366,7 @@ obj/structure/ex_act(severity)
// giving it a chance to mix its internal air supply with the turf it is
// currently on.
/obj/structure/transit_tube_pod/proc/mix_air()
+ if(!loc) return
var/datum/gas_mixture/environment = loc.return_air()
//note that share_ratio assumes both gas mixes have the same volume,
diff --git a/code/game/sound.dm b/code/game/sound.dm
index 480cc046b68..0d9e66fb17d 100644
--- a/code/game/sound.dm
+++ b/code/game/sound.dm
@@ -193,7 +193,7 @@
S.volume -= max(distance - world.view, 0) * 2
- if (use_pressure)
+ if (use_pressure && istype(T))
var/datum/gas_mixture/hearer_env = T.return_air()
var/datum/gas_mixture/source_env = source_turf.return_air()
diff --git a/code/modules/admin/verbs/clear_toxins.dm b/code/modules/admin/verbs/clear_toxins.dm
index 68a4a3f9d4d..ff140fc5b93 100644
--- a/code/modules/admin/verbs/clear_toxins.dm
+++ b/code/modules/admin/verbs/clear_toxins.dm
@@ -5,6 +5,8 @@
if (!check_rights(R_ADMIN))
return
+ if(!usr.loc) return
+
var/datum/gas_mixture/environment = usr.loc.return_air()
environment.gas[GAS_PHORON] = 0
environment.gas[GAS_NITROGEN] = 82.1472
diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm
index cd24bbad78b..84022d26ae6 100644
--- a/code/modules/admin/verbs/debug.dm
+++ b/code/modules/admin/verbs/debug.dm
@@ -22,9 +22,9 @@
set name = "Cell"
if(!mob)
return
- var/turf/T = mob.loc
+ var/turf/T = get_turf(mob)
- if (!( istype(T, /turf) ))
+ if (!istype(T))
return
var/datum/gas_mixture/env = T.return_air()
diff --git a/code/modules/atmospherics/components/binary_devices/dp_vent_pump.dm b/code/modules/atmospherics/components/binary_devices/dp_vent_pump.dm
index 8debe635fb5..14f1504184c 100644
--- a/code/modules/atmospherics/components/binary_devices/dp_vent_pump.dm
+++ b/code/modules/atmospherics/components/binary_devices/dp_vent_pump.dm
@@ -112,6 +112,8 @@
broadcast_status()
broadcast_status_next_process = FALSE
+ if(!loc) return FALSE
+
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
diff --git a/code/modules/atmospherics/components/binary_devices/passive_gate.dm b/code/modules/atmospherics/components/binary_devices/passive_gate.dm
index 768f7824ddb..1ff14faeb5f 100644
--- a/code/modules/atmospherics/components/binary_devices/passive_gate.dm
+++ b/code/modules/atmospherics/components/binary_devices/passive_gate.dm
@@ -279,6 +279,7 @@
to_chat(user, "You cannot unwrench \the [src], turn it off first.")
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if (!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/binary_devices/pump.dm b/code/modules/atmospherics/components/binary_devices/pump.dm
index 5933bbf7b0c..772372998aa 100644
--- a/code/modules/atmospherics/components/binary_devices/pump.dm
+++ b/code/modules/atmospherics/components/binary_devices/pump.dm
@@ -225,6 +225,7 @@ Thus, the two variables affect pump operation are set in New():
to_chat(user, "You cannot unwrench this [src], turn it off first.")
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if (!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED && !istype(W, /obj/item/pipewrench))
to_chat(user, "You cannot unwrench this [src], it's too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/omni_devices/omni_base.dm b/code/modules/atmospherics/components/omni_devices/omni_base.dm
index e84f02b6f19..3739547b7be 100644
--- a/code/modules/atmospherics/components/omni_devices/omni_base.dm
+++ b/code/modules/atmospherics/components/omni_devices/omni_base.dm
@@ -88,6 +88,7 @@
var/int_pressure = 0
for(var/datum/omni_port/P in ports)
int_pressure += P.air.return_pressure()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_pressure - env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/portables_connector.dm b/code/modules/atmospherics/components/portables_connector.dm
index 0b1eb5193e8..0d00350b7ea 100644
--- a/code/modules/atmospherics/components/portables_connector.dm
+++ b/code/modules/atmospherics/components/portables_connector.dm
@@ -139,6 +139,7 @@
if (locate(/obj/machinery/portable_atmospherics, src.loc))
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/trinary_devices/filter.dm b/code/modules/atmospherics/components/trinary_devices/filter.dm
index 121e4db7074..82d14a694f0 100644
--- a/code/modules/atmospherics/components/trinary_devices/filter.dm
+++ b/code/modules/atmospherics/components/trinary_devices/filter.dm
@@ -135,6 +135,7 @@
if (!W.iswrench())
return ..()
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/trinary_devices/mixer.dm b/code/modules/atmospherics/components/trinary_devices/mixer.dm
index f035b9a0726..2e2022dbd9e 100644
--- a/code/modules/atmospherics/components/trinary_devices/mixer.dm
+++ b/code/modules/atmospherics/components/trinary_devices/mixer.dm
@@ -107,6 +107,7 @@
if (!W.iswrench())
return ..()
var/datum/gas_mixture/int_air = return_air()
+ if (!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/tvalve.dm b/code/modules/atmospherics/components/tvalve.dm
index e45b19c7877..a8112e2b0c0 100644
--- a/code/modules/atmospherics/components/tvalve.dm
+++ b/code/modules/atmospherics/components/tvalve.dm
@@ -350,6 +350,7 @@
to_chat(user, "You cannot unwrench \the [src], it's too complicated.")
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/unary/heat_exchanger.dm b/code/modules/atmospherics/components/unary/heat_exchanger.dm
index cf686d5d1f2..70eca5e4382 100644
--- a/code/modules/atmospherics/components/unary/heat_exchanger.dm
+++ b/code/modules/atmospherics/components/unary/heat_exchanger.dm
@@ -73,6 +73,7 @@
to_chat(user, "You must remove the plating first.")
return 1
var/datum/gas_mixture/int_air = return_air()
+ if (!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/components/unary/outlet_injector.dm b/code/modules/atmospherics/components/unary/outlet_injector.dm
index af67e85c2d4..7d0daeb1fd5 100644
--- a/code/modules/atmospherics/components/unary/outlet_injector.dm
+++ b/code/modules/atmospherics/components/unary/outlet_injector.dm
@@ -65,6 +65,7 @@
return
var/power_draw = -1
+ if(!loc) return FALSE
var/datum/gas_mixture/environment = loc.return_air()
if(environment && air_contents.temperature > 0)
@@ -81,7 +82,7 @@
return 1
/obj/machinery/atmospherics/unary/outlet_injector/proc/inject()
- if(injecting || (stat & NOPOWER))
+ if(injecting || (stat & NOPOWER) || !loc)
return 0
var/datum/gas_mixture/environment = loc.return_air()
diff --git a/code/modules/atmospherics/components/unary/thermal_plate.dm b/code/modules/atmospherics/components/unary/thermal_plate.dm
index 0f07cac56ef..e4f27e9ff13 100644
--- a/code/modules/atmospherics/components/unary/thermal_plate.dm
+++ b/code/modules/atmospherics/components/unary/thermal_plate.dm
@@ -21,6 +21,8 @@
process()
..()
+ if (!loc) return FALSE
+
var/datum/gas_mixture/environment = loc.return_air()
//Get processable air sample and thermal info from environment
diff --git a/code/modules/atmospherics/components/unary/vent_pump.dm b/code/modules/atmospherics/components/unary/vent_pump.dm
index cd05b038c8b..fa79d9f7e24 100644
--- a/code/modules/atmospherics/components/unary/vent_pump.dm
+++ b/code/modules/atmospherics/components/unary/vent_pump.dm
@@ -199,6 +199,8 @@
if(!can_pump())
return 0
+ if(!loc) return FALSE
+
var/datum/gas_mixture/environment = loc.return_air()
var/power_draw = -1
@@ -435,6 +437,7 @@
to_chat(user, SPAN_WARNING("You must remove the plating first."))
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, SPAN_WARNING("You cannot unwrench \the [src], it is too exerted due to internal pressure."))
@@ -463,4 +466,4 @@
#undef PRESSURE_CHECKS
#undef PRESSURE_CHECK_EXTERNAL
-#undef PRESSURE_CHECK_INTERNAL
\ No newline at end of file
+#undef PRESSURE_CHECK_INTERNAL
diff --git a/code/modules/atmospherics/components/unary/vent_scrubber.dm b/code/modules/atmospherics/components/unary/vent_scrubber.dm
index 22c265037e4..97cdd02a194 100644
--- a/code/modules/atmospherics/components/unary/vent_scrubber.dm
+++ b/code/modules/atmospherics/components/unary/vent_scrubber.dm
@@ -172,7 +172,7 @@
broadcast_status()
broadcast_status_next_process = FALSE
- if(!use_power || (stat & (NOPOWER|BROKEN)))
+ if(!use_power || (stat & (NOPOWER|BROKEN)) || !loc)
return 0
if(welded)
return 0
@@ -305,6 +305,7 @@
to_chat(user, SPAN_WARNING("You must remove the plating first."))
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, SPAN_WARNING("You cannot unwrench \the [src], it is too exerted due to internal pressure."))
diff --git a/code/modules/atmospherics/components/valve.dm b/code/modules/atmospherics/components/valve.dm
index dca6eecb555..11434e28678 100644
--- a/code/modules/atmospherics/components/valve.dm
+++ b/code/modules/atmospherics/components/valve.dm
@@ -308,6 +308,7 @@
to_chat(user, "You cannot unwrench \the [src], it's too complicated.")
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if (!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
to_chat(user, "You cannot unwrench \the [src], it is too exerted due to internal pressure.")
diff --git a/code/modules/atmospherics/datum_pipeline.dm b/code/modules/atmospherics/datum_pipeline.dm
index 63fe30225d9..7aa0be866ec 100644
--- a/code/modules/atmospherics/datum_pipeline.dm
+++ b/code/modules/atmospherics/datum_pipeline.dm
@@ -131,7 +131,7 @@
target.zone.air.merge(turf_copy)
- else
+ else if(target)
var/datum/gas_mixture/turf_air = target.return_air()
equalize_gases(list(air_sample, turf_air))
diff --git a/code/modules/atmospherics/pipes.dm b/code/modules/atmospherics/pipes.dm
index 6d1b2f94e93..f9c7d097607 100644
--- a/code/modules/atmospherics/pipes.dm
+++ b/code/modules/atmospherics/pipes.dm
@@ -94,6 +94,7 @@
to_chat(user, "You must remove the plating first.")
return TRUE
var/datum/gas_mixture/int_air = return_air()
+ if(!loc) return FALSE
var/datum/gas_mixture/env_air = loc.return_air()
if ((int_air.return_pressure()-env_air.return_pressure()) > PRESSURE_EXERTED)
if(!istype(W, /obj/item/pipewrench))
@@ -216,6 +217,7 @@
. = PROCESS_KILL
/obj/machinery/atmospherics/pipe/simple/check_pressure(pressure)
+ if(!loc) return
var/datum/gas_mixture/environment = loc.return_air()
var/pressure_difference = pressure - environment.return_pressure()
diff --git a/code/modules/cooking/machinery/cooking_machines/_cooker.dm b/code/modules/cooking/machinery/cooking_machines/_cooker.dm
index eee2f31f1b8..701739a129e 100644
--- a/code/modules/cooking/machinery/cooking_machines/_cooker.dm
+++ b/code/modules/cooking/machinery/cooking_machines/_cooker.dm
@@ -131,6 +131,7 @@
overlays += light
/obj/machinery/appliance/cooker/process()
+ if (!loc) return FALSE
var/datum/gas_mixture/loc_air = loc.return_air()
if (stat || (use_power != 2)) // if we're not actively heating
temperature -= min(loss, temperature - loc_air.temperature)
diff --git a/code/modules/custom_ka/projectiles.dm b/code/modules/custom_ka/projectiles.dm
index 67053331e5d..059c3b264ac 100644
--- a/code/modules/custom_ka/projectiles.dm
+++ b/code/modules/custom_ka/projectiles.dm
@@ -26,6 +26,7 @@
strike_thing(target_turf)
/obj/item/projectile/kinetic/proc/do_damage(var/turf/T, var/living_damage = 1, var/mineral_damage = 1)
+ if(!istype(T)) return
var/datum/gas_mixture/environment = T.return_air()
living_damage *= max(1 - (environment.return_pressure() / 100) * 0.75, 0)
new /obj/effect/overlay/temp/kinetic_blast(T)
@@ -41,4 +42,4 @@
var/turf/aoe_turf = new_target
do_damage(aoe_turf, max(base_damage - base_damage * get_dist(aoe_turf, target_turf) * 0.25, 0), base_damage)
if(!QDELETED(src))
- qdel(src)
\ No newline at end of file
+ qdel(src)
diff --git a/code/modules/heavy_vehicle/mecha.dm b/code/modules/heavy_vehicle/mecha.dm
index 5f447bb551a..261dce114ca 100644
--- a/code/modules/heavy_vehicle/mecha.dm
+++ b/code/modules/heavy_vehicle/mecha.dm
@@ -230,7 +230,7 @@
MR.start_charging(src)
/mob/living/heavy_vehicle/return_air()
- return (body && body.pilot_coverage >= 100 && hatch_closed) ? body.cockpit : loc.return_air()
+ return (body && body.pilot_coverage >= 100 && hatch_closed) ? body.cockpit : loc?.return_air()
/mob/living/heavy_vehicle/GetIdCard()
return access_card
diff --git a/code/modules/mob/abstract/observer/observer.dm b/code/modules/mob/abstract/observer/observer.dm
index 1358e1a26a0..f421ef5e6e1 100644
--- a/code/modules/mob/abstract/observer/observer.dm
+++ b/code/modules/mob/abstract/observer/observer.dm
@@ -540,6 +540,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
continue
var/turf/T = get_turf(testvent)
+ if(!istype(T)) continue
//Skip areas that contain turrets
var/area/A = T.loc
diff --git a/code/modules/mob/living/carbon/human/human_powers.dm b/code/modules/mob/living/carbon/human/human_powers.dm
index 1336bd720c4..e87060258da 100644
--- a/code/modules/mob/living/carbon/human/human_powers.dm
+++ b/code/modules/mob/living/carbon/human/human_powers.dm
@@ -1200,6 +1200,8 @@ mob/living/carbon/human/proc/change_monitor()
else
custom_emote(VISIBLE_MESSAGE, "flicks their tongue out.")
+ if(!src.loc) return
+
var/datum/gas_mixture/mixture = src.loc.return_air()
var/total_moles = mixture.total_moles
@@ -1317,4 +1319,4 @@ mob/living/carbon/human/proc/change_monitor()
/mob/living/carbon/human/proc/stop_listening()
if (is_listening())
visible_message("[src] stops listening intently.")
- intent_listener -= src
\ No newline at end of file
+ intent_listener -= src
diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm
index 3344902c9c9..955ed12053b 100644
--- a/code/modules/mob/living/living_defense.dm
+++ b/code/modules/mob/living/living_defense.dm
@@ -280,6 +280,10 @@
return fire_stacks
/mob/living/proc/handle_fire()
+ if(!loc)
+ ExtinguishMobCompletely()
+ return TRUE
+
if(fire_stacks < 0)
fire_stacks = min(0, ++fire_stacks) //If we've doused ourselves in water to avoid fire, dry off slowly
diff --git a/code/modules/multiz/pipes.dm b/code/modules/multiz/pipes.dm
index baeda168324..7b2b8b7d8a1 100644
--- a/code/modules/multiz/pipes.dm
+++ b/code/modules/multiz/pipes.dm
@@ -69,6 +69,7 @@
. = PROCESS_KILL
/obj/machinery/atmospherics/pipe/zpipe/check_pressure(pressure)
+ if(!loc) return FALSE
var/datum/gas_mixture/environment = loc.return_air()
var/pressure_difference = pressure - environment.return_pressure()
diff --git a/code/modules/power/portgen.dm b/code/modules/power/portgen.dm
index e21bb83bb3e..10cfd8ba08b 100644
--- a/code/modules/power/portgen.dm
+++ b/code/modules/power/portgen.dm
@@ -206,6 +206,7 @@
Gives traitors more opportunities to sabotage the generator or allows enterprising engineers to build additional
cooling in order to get more power out.
*/
+ if(!loc) return
var/datum/gas_mixture/environment = loc.return_air()
if (environment)
var/ratio = min(environment.return_pressure()/ONE_ATMOSPHERE, 1)
@@ -336,8 +337,11 @@
data["temperature_max"] = max_temperature
data["temperature_overheat"] = overheating
- var/datum/gas_mixture/environment = loc.return_air()
- data["temperature_min"] = Floor(environment.temperature - T0C)
+ if(loc)
+ var/datum/gas_mixture/environment = loc.return_air()
+ if(environment)
+ data["temperature_min"] = Floor(environment.temperature - T0C)
+
data["output_min"] = initial(power_output)
data["is_broken"] = IsBroken()
data["is_ai"] = (isAI(user) || (isrobot(user) && !Adjacent(user)))
diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm
index 88c5bb5fea0..4da0b703e71 100644
--- a/code/modules/power/turbine.dm
+++ b/code/modules/power/turbine.dm
@@ -70,7 +70,9 @@
stat |= BROKEN
return
rpm = 0.9* rpm + 0.1 * rpmtarget
+ if(!inturf) return
var/datum/gas_mixture/environment = inturf.return_air()
+ if(!environment) return
var/transfer_moles = environment.total_moles / 10
//var/transfer_moles = rpm/10000*capacity
var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles)
diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
index fdc4b1299d0..98f21c66f58 100644
--- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
+++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
@@ -198,8 +198,10 @@
if(istype(H, /obj/machinery/portable_atmospherics/hydroponics/soil/invisible))
qdel(H)
- var/datum/gas_mixture/environment = T.return_air()
- environment.adjust_gas(GAS_PHORON,-amount*10)
+ if(istype(T))
+ var/datum/gas_mixture/environment = T.return_air()
+ if(environment)
+ environment.adjust_gas(GAS_PHORON,-amount*10)
/decl/reagent/toxin/cyanide //Fast and Lethal
name = "Cyanide"
diff --git a/code/modules/reagents/reagent_dispenser.dm b/code/modules/reagents/reagent_dispenser.dm
index dbe15778ed1..c41ada08487 100644
--- a/code/modules/reagents/reagent_dispenser.dm
+++ b/code/modules/reagents/reagent_dispenser.dm
@@ -401,10 +401,12 @@
playsound(src.loc, 'sound/effects/smoke.ogg', 50, 1, -3)
INVOKE_ASYNC(S, /datum/effect/effect/system/smoke_spread/.proc/start)
- var/datum/gas_mixture/env = src.loc.return_air()
- if(env)
- if (reagents.total_volume > 750)
- env.temperature = 0
- else if (reagents.total_volume > 500)
- env.temperature -= 100
- QDEL_IN(src, 10)
+ if(src.loc)
+ var/datum/gas_mixture/env = src.loc.return_air()
+ if(env)
+ if (reagents.total_volume > 750)
+ env.temperature = 0
+ else if (reagents.total_volume > 500)
+ env.temperature -= 100
+
+ QDEL_IN(src, 10)
diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm
index 8d2aec7e24e..b4dbfb8d6af 100644
--- a/code/modules/recycling/disposal.dm
+++ b/code/modules/recycling/disposal.dm
@@ -500,6 +500,7 @@
return
var/atom/L = loc // recharging from loc turf
+ if(!loc) return
var/datum/gas_mixture/env = L.return_air()
var/power_draw = -1
diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm
index 8f8626193fc..e1625750677 100644
--- a/code/modules/research/server.dm
+++ b/code/modules/research/server.dm
@@ -59,6 +59,7 @@
if(stat & (NOPOWER|BROKEN))
return
+ if(!loc) return
var/datum/gas_mixture/environment = loc.return_air()
switch(environment.temperature)
if(0 to T0C)
diff --git a/code/modules/research/xenoarchaeology/artifact/artifact_unknown.dm b/code/modules/research/xenoarchaeology/artifact/artifact_unknown.dm
index d7b74d8c027..001ea46f5dd 100644
--- a/code/modules/research/xenoarchaeology/artifact/artifact_unknown.dm
+++ b/code/modules/research/xenoarchaeology/artifact/artifact_unknown.dm
@@ -95,6 +95,7 @@
var/trigger_nitro = 0
if( (my_effect.trigger >= TRIGGER_HEAT && my_effect.trigger <= TRIGGER_NITRO) || (my_effect.trigger >= TRIGGER_HEAT && my_effect.trigger <= TRIGGER_NITRO) )
var/turf/T = get_turf(src)
+ if(!istype(T)) return
var/datum/gas_mixture/env = T.return_air()
if(env)
if(env.temperature < 225)
diff --git a/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_atmospheric.dm b/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_atmospheric.dm
index 1328849c5a2..0d83ed5972a 100644
--- a/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_atmospheric.dm
+++ b/code/modules/research/xenoarchaeology/artifact/effects/unknown_effect_atmospheric.dm
@@ -162,12 +162,13 @@
to_chat(user, SPAN_NOTICE("You detect a decrease in temperature throughout your systems!"))
else
to_chat(user, SPAN_NOTICE("A chill passes up your spine!"))
+ if(!holder.loc) return
var/datum/gas_mixture/env = holder.loc.return_air()
if(env)
env.temperature = max(env.temperature - rand(5,50), 0)
/datum/artifact_effect/cold/DoEffectAura()
- if(holder)
+ if(holder && holder.loc)
var/datum/gas_mixture/env = holder.loc.return_air()
if(env && env.temperature > target_temp)
env.temperature -= pick(0, 0, 1)
@@ -186,7 +187,7 @@
effect = pick(EFFECT_TOUCH, EFFECT_AURA)
/datum/artifact_effect/heat/DoEffectTouch(var/mob/living/user)
- if(holder)
+ if(holder && holder.loc)
if(user.isSynthetic())
to_chat(user, SPAN_WARNING("You detect a wave of heat surging through your systems."))
else
@@ -196,7 +197,7 @@
env.temperature += rand(5,50)
/datum/artifact_effect/heat/DoEffectAura()
- if(holder)
+ if(holder && holder.loc)
var/datum/gas_mixture/env = holder.loc.return_air()
if(env && env.temperature < target_temp)
env.temperature += pick(0, 0, 1)
diff --git a/code/modules/supermatter/supermatter.dm b/code/modules/supermatter/supermatter.dm
index de9ecf5e5eb..0b094899b8d 100644
--- a/code/modules/supermatter/supermatter.dm
+++ b/code/modules/supermatter/supermatter.dm
@@ -371,7 +371,7 @@
data = ..() || list()
data["integrity_percentage"] = round(get_integrity())
var/datum/gas_mixture/env = null
- if(!istype(src.loc, /turf/space))
+ if(loc && !istype(src.loc, /turf/space))
env = src.loc.return_air()
data["ambient_temp"] = round(env?.temperature)
data["ambient_pressure"] = round(env?.return_pressure())