diff --git a/code/datums/diseases/wizarditis.dm b/code/datums/diseases/wizarditis.dm index 9e098c80077..41ab2927ac9 100644 --- a/code/datums/diseases/wizarditis.dm +++ b/code/datums/diseases/wizarditis.dm @@ -90,8 +90,9 @@ STI KALY - blind var/area/thearea = pick(theareas) var/list/L = list() + var/turf/mob_turf = get_turf(affected_mob) for(var/turf/T in get_area_turfs(thearea.type)) - if(T.z != affected_mob.z) + if(!is_valid_z_level(T, mob_turf)) continue if(T.name == "space") continue diff --git a/code/game/machinery/computer/law.dm b/code/game/machinery/computer/law.dm index 1749c491485..3193048f8b8 100644 --- a/code/game/machinery/computer/law.dm +++ b/code/game/machinery/computer/law.dm @@ -21,8 +21,7 @@ to_chat(user, span_alert("Upload failed! Check to make sure [current.name] is functioning properly.")) current = null return - var/turf/currentloc = get_turf(current) - if(currentloc && user.z != currentloc.z) + if(!is_valid_z_level(get_turf(current), get_turf(user))) to_chat(user, span_alert("Upload failed! Unable to establish a connection to [current.name]. You're too far away!")) current = null return diff --git a/code/game/machinery/computer/prisoner/management.dm b/code/game/machinery/computer/prisoner/management.dm index e1a444d5906..c4281ffb474 100644 --- a/code/game/machinery/computer/prisoner/management.dm +++ b/code/game/machinery/computer/prisoner/management.dm @@ -32,10 +32,10 @@ dat += text("Insert Prisoner ID.
") dat += "

Prisoner Implant Management

" dat += "
Chemical Implants
" - var/turf/Tr = null + var/turf/current_turf = get_turf(src) for(var/obj/item/implant/chem/C in GLOB.tracked_chem_implants) - Tr = get_turf(C) - if((Tr) && (Tr.z != src.z)) + var/turf/implant_turf = get_turf(C) + if(!is_valid_z_level(current_turf, implant_turf)) continue//Out of range if(!C.imp_in) continue @@ -49,13 +49,13 @@ for(var/obj/item/implant/tracking/T in GLOB.tracked_implants) if(!isliving(T.imp_in)) continue - Tr = get_turf(T) - if((Tr) && (Tr.z != src.z)) + var/turf/implant_turf = get_turf(T) + if(!is_valid_z_level(current_turf, implant_turf)) continue//Out of range var/loc_display = "Unknown" var/mob/living/M = T.imp_in - if(is_station_level(Tr.z) && !isspaceturf(M.loc)) + if(is_station_level(implant_turf.z) && !isspaceturf(M.loc)) var/turf/mob_loc = get_turf(M) loc_display = mob_loc.loc diff --git a/code/game/machinery/computer/robot.dm b/code/game/machinery/computer/robot.dm index 9b4fc6de73b..562f3d4d649 100644 --- a/code/game/machinery/computer/robot.dm +++ b/code/game/machinery/computer/robot.dm @@ -44,11 +44,12 @@ var/mob/living/silicon/ai/ai = user data["can_detonate"] = !isnull(ai.malf_picker) + var/turf/current_turf = get_turf(src) data["cyborgs"] = list() for(var/mob/living/silicon/robot/R in GLOB.silicon_mobs) if(!can_control(user, R)) continue - if(z != (get_turf(R)).z) + if(!is_valid_z_level(current_turf, get_turf(R))) continue var/list/cyborg_data = list( name = R.name, @@ -66,7 +67,7 @@ for(var/mob/living/simple_animal/drone/D in GLOB.drones_list) if(D.hacked) continue - if(z != (get_turf(D)).z) + if(!is_valid_z_level(current_turf, get_turf(D))) continue var/list/drone_data = list( name = D.name, diff --git a/code/game/objects/items/devices/camera_bug.dm b/code/game/objects/items/devices/camera_bug.dm index f5a22a25a4b..eb45bc93f90 100644 --- a/code/game/objects/items/devices/camera_bug.dm +++ b/code/game/objects/items/devices/camera_bug.dm @@ -65,9 +65,7 @@ if ( loc != user || user.incapacitated() || user.is_blind() || !current ) user.unset_machine() return FALSE - var/turf/T_user = get_turf(user.loc) - var/turf/T_current = get_turf(current) - if(T_user.z != T_current.z || !current.can_use()) + if(!is_valid_z_level(get_turf(current), get_turf(user.loc)) || !current.can_use()) to_chat(user, span_danger("[src] has lost the signal.")) current = null user.unset_machine() @@ -312,9 +310,8 @@ src.updateSelfDialog() /obj/item/camera_bug/proc/same_z_level(obj/machinery/camera/C) - var/turf/T_cam = get_turf(C) var/turf/T_bug = get_turf(loc) - if(!T_bug || T_cam.z != T_bug.z) + if(!T_bug || !is_valid_z_level(T_bug, get_turf(C))) to_chat(usr, span_warning("You can't get a signal!")) return FALSE return TRUE diff --git a/code/modules/antagonists/blob/blob_mobs.dm b/code/modules/antagonists/blob/blob_mobs.dm index 5f19f24279e..439515f10c1 100644 --- a/code/modules/antagonists/blob/blob_mobs.dm +++ b/code/modules/antagonists/blob/blob_mobs.dm @@ -140,12 +140,12 @@ add_cell_sample() /mob/living/simple_animal/hostile/blob/blobspore/Life(delta_time = SSMOBS_DT, times_fired) - if(!is_zombie && isturf(src.loc)) + if(!is_zombie && isturf(loc)) for(var/mob/living/carbon/human/H in view(src,1)) //Only for corpse right next to/on same tile if(!is_weak && H.stat == DEAD) Zombify(H) break - if(factory && z != factory.z) + if(!is_valid_z_level(get_turf(src), get_turf(factory))) death() return ..() diff --git a/code/modules/antagonists/cult/runes.dm b/code/modules/antagonists/cult/runes.dm index a8f9b6c9403..686d4292161 100644 --- a/code/modules/antagonists/cult/runes.dm +++ b/code/modules/antagonists/cult/runes.dm @@ -968,10 +968,9 @@ structure_check() searches for nearby cultist structures required for the invoca empulse(T, 0.42*(intensity), 1) var/list/images = list() - var/zmatch = T.z var/datum/atom_hud/sec_hud = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] for(var/mob/living/M in GLOB.alive_mob_list) - if(M.z != zmatch) + if(!is_valid_z_level(T, get_turf(M))) continue if(ishuman(M)) if(!IS_CULTIST(M)) diff --git a/code/modules/experisci/experiment/handlers/experiment_handler.dm b/code/modules/experisci/experiment/handlers/experiment_handler.dm index b02c69b8df3..bd6c0e47685 100644 --- a/code/modules/experisci/experiment/handlers/experiment_handler.dm +++ b/code/modules/experisci/experiment/handlers/experiment_handler.dm @@ -298,7 +298,7 @@ var/turf/turf_server = get_turf(server) if (!turf_source || !turf_server) break - if (turf_source.z == turf_server.z || (SSmapping.level_trait(turf_source.z, ZTRAIT_STATION) && SSmapping.level_trait(turf_server.z, ZTRAIT_STATION))) + if(is_valid_z_level(turf_source, turf_server)) local_servers += server return local_servers diff --git a/code/modules/mapfluff/ruins/objects_and_mobs/necropolis_gate.dm b/code/modules/mapfluff/ruins/objects_and_mobs/necropolis_gate.dm index f49f98648f9..fac60eaf149 100644 --- a/code/modules/mapfluff/ruins/objects_and_mobs/necropolis_gate.dm +++ b/code/modules/mapfluff/ruins/objects_and_mobs/necropolis_gate.dm @@ -185,7 +185,7 @@ GLOBAL_DATUM(necropolis_gate, /obj/structure/necropolis_gate/legion_gate) var/sound/legion_sound = sound('sound/creatures/legion_spawn.ogg') for(var/mob/M in GLOB.player_list) - if(M.z == z) + if(is_valid_z_level(get_turf(M), T)) to_chat(M, span_userdanger("Discordant whispers flood your mind in a thousand voices. Each one speaks your name, over and over. Something horrible has been released.")) M.playsound_local(T, null, 100, FALSE, 0, FALSE, pressure_affected = FALSE, sound_to_use = legion_sound) flash_color(M, flash_color = "#FF0000", flash_time = 50) diff --git a/code/modules/mod/modules/modules_science.dm b/code/modules/mod/modules/modules_science.dm index ac1b9e2e543..36b78df768f 100644 --- a/code/modules/mod/modules/modules_science.dm +++ b/code/modules/mod/modules/modules_science.dm @@ -49,7 +49,7 @@ devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range) SIGNAL_HANDLER var/turf/wearer_turf = get_turf(mod.wearer) - if(wearer_turf.z != epicenter.z) + if(!is_valid_z_level(wearer_turf, epicenter)) return if(get_dist(epicenter, wearer_turf) > explosion_detection_dist) return diff --git a/code/modules/modular_computers/file_system/programs/borg_monitor.dm b/code/modules/modular_computers/file_system/programs/borg_monitor.dm index d6810724efe..4a5611dddbf 100644 --- a/code/modules/modular_computers/file_system/programs/borg_monitor.dm +++ b/code/modules/modular_computers/file_system/programs/borg_monitor.dm @@ -144,7 +144,7 @@ ///This proc is used to determin if a borg should be shown in the list (based on the borg's scrambledcodes var). Syndicate version overrides this to show only syndicate borgs. /datum/computer_file/program/borg_monitor/proc/evaluate_borg(mob/living/silicon/robot/R) - if((get_turf(computer)).z != (get_turf(R)).z) + if(!is_valid_z_level(get_turf(computer), get_turf(R))) return FALSE if(R.scrambledcodes) return FALSE @@ -176,7 +176,7 @@ return FALSE /datum/computer_file/program/borg_monitor/syndicate/evaluate_borg(mob/living/silicon/robot/R) - if((get_turf(computer)).z != (get_turf(R)).z) + if(!is_valid_z_level(get_turf(computer), get_turf(R))) return FALSE if(!R.scrambledcodes) return FALSE diff --git a/code/modules/modular_computers/file_system/programs/robocontrol.dm b/code/modules/modular_computers/file_system/programs/robocontrol.dm index 5ed2eb18b01..5e194d2c1ca 100644 --- a/code/modules/modular_computers/file_system/programs/robocontrol.dm +++ b/code/modules/modular_computers/file_system/programs/robocontrol.dm @@ -24,7 +24,6 @@ /datum/computer_file/program/robocontrol/ui_data(mob/user) var/list/data = get_header_data() var/turf/current_turf = get_turf(ui_host()) - var/zlevel = current_turf.z var/list/botlist = list() var/list/mulelist = list() @@ -37,7 +36,7 @@ botcount = 0 for(var/mob/living/simple_animal/bot/simple_bot as anything in GLOB.bots_list) - if(simple_bot.z != zlevel || !(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) //Only non-emagged bots on the same Z-level are detected! + if(!is_valid_z_level(current_turf, get_turf(simple_bot)) || !(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) //Only non-emagged bots on the same Z-level are detected! continue if(computer && !simple_bot.check_access(user)) // Only check Bots we can access) continue @@ -69,7 +68,7 @@ for(var/mob/living/simple_animal/drone/all_drones as anything in GLOB.drones_list) if(all_drones.hacked) continue - if(all_drones.z != zlevel) + if(!is_valid_z_level(current_turf, get_turf(all_drones))) continue var/list/drone_data = list( "name" = all_drones.name, diff --git a/code/modules/pai/software.dm b/code/modules/pai/software.dm index 4849d754043..ce6b83b45bd 100644 --- a/code/modules/pai/software.dm +++ b/code/modules/pai/software.dm @@ -210,7 +210,7 @@ if(!resolved_master) balloon_alert(src, "cannot locate master") return FALSE - if(src.z != resolved_master.z) + if(!is_valid_z_level(get_turf(src), get_turf(resolved_master))) balloon_alert(src, "master out of range") return FALSE host_scan.attack(resolved_master, src) diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 19a1a36e1c7..8f34edab6e8 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -379,7 +379,10 @@ GLOBAL_LIST_EMPTY(gravity_generators) var/turf/T = get_turf(src) var/sound/alert_sound = sound('sound/effects/alert.ogg') for(var/mob/mobs as anything in GLOB.mob_list) - if(mobs.z != z && !(SSmapping.level_trait(z, ZTRAITS_STATION) && SSmapping.level_trait(mobs.z, ZTRAITS_STATION))) + var/turf/mob_turf = get_turf(mobs) + if(!istype(mob_turf)) + continue + if(!is_valid_z_level(T, mob_turf)) continue mobs.update_gravity(mobs.has_gravity()) if(mobs.client) diff --git a/code/modules/power/supermatter/supermatter_delamination/delamination_effects.dm b/code/modules/power/supermatter/supermatter_delamination/delamination_effects.dm index 396afc48218..a6f3e7325ae 100644 --- a/code/modules/power/supermatter/supermatter_delamination/delamination_effects.dm +++ b/code/modules/power/supermatter/supermatter_delamination/delamination_effects.dm @@ -8,7 +8,7 @@ /datum/sm_delam/proc/effect_irradiate(obj/machinery/power/supermatter_crystal/sm) var/turf/sm_turf = get_turf(sm) for (var/mob/living/victim in range(20, sm)) - if(victim.z != sm_turf.z) + if(!is_valid_z_level(get_turf(victim), sm_turf)) continue SSradiation.irradiate(victim) return TRUE @@ -17,7 +17,7 @@ /datum/sm_delam/proc/effect_demoralize(obj/machinery/power/supermatter_crystal/sm) var/turf/sm_turf = get_turf(sm) for(var/mob/living/victim as anything in GLOB.alive_mob_list) - if(!istype(victim) || victim.z != sm_turf.z) + if(!istype(victim) || !is_valid_z_level(get_turf(victim), sm_turf)) continue if(ishuman(victim)) //Hilariously enough, running into a closet should make you get hit the hardest. @@ -25,11 +25,10 @@ human.hallucination += max(50, min(300, DETONATION_HALLUCINATION * sqrt(1 / (get_dist(victim, sm) + 1)) ) ) for(var/mob/victim as anything in GLOB.player_list) - var/turf/mob_turf = get_turf(victim) - if(sm_turf.z != mob_turf.z) + if(!is_valid_z_level(get_turf(victim), sm_turf)) continue SEND_SOUND(victim, 'sound/magic/charge.ogg') - if (victim.z != sm_turf.z) + if(!is_valid_z_level(get_turf(victim), sm_turf)) to_chat(victim, span_boldannounce("You hold onto \the [victim.loc] as hard as you can, as reality distorts around you. You feel safe.")) continue to_chat(victim, span_boldannounce("You feel reality distort for a moment...")) diff --git a/code/modules/power/supermatter/supermatter_hit_procs.dm b/code/modules/power/supermatter/supermatter_hit_procs.dm index a413a1ab03f..9a269fc9965 100644 --- a/code/modules/power/supermatter/supermatter_hit_procs.dm +++ b/code/modules/power/supermatter/supermatter_hit_procs.dm @@ -48,8 +48,9 @@ investigate_log("consumed by singularity.", INVESTIGATE_ENGINE) message_admins("Singularity has consumed a supermatter shard and can now become stage six.") visible_message(span_userdanger("[src] is consumed by the singularity!")) + var/turf/sm_turf = get_turf(src) for(var/mob/hearing_mob as anything in GLOB.player_list) - if(hearing_mob.z != z) + if(!is_valid_z_level(get_turf(hearing_mob), sm_turf)) continue SEND_SOUND(hearing_mob, 'sound/effects/supermatter.ogg') //everyone goan know bout this to_chat(hearing_mob, span_boldannounce("A horrible screeching fills your ears, and a wave of dread washes over you...")) diff --git a/code/modules/research/ordnance/doppler_array.dm b/code/modules/research/ordnance/doppler_array.dm index f2f37c9bf02..6f164f517c3 100644 --- a/code/modules/research/ordnance/doppler_array.dm +++ b/code/modules/research/ordnance/doppler_array.dm @@ -163,7 +163,7 @@ if(machine_stat & NOPOWER) return FALSE var/turf/zone = get_turf(src) - if(zone.z != epicenter.z) + if(!is_valid_z_level(zone, epicenter)) return FALSE if(next_announce > world.time) diff --git a/code/modules/station_goals/shield.dm b/code/modules/station_goals/shield.dm index 16dc79bf05a..dd0490e8882 100644 --- a/code/modules/station_goals/shield.dm +++ b/code/modules/station_goals/shield.dm @@ -62,8 +62,9 @@ . = TRUE /obj/machinery/computer/sat_control/proc/toggle(id) + var/turf/current_turf = get_turf(src) for(var/obj/machinery/satellite/S in GLOB.machines) - if(S.id == id && S.z == z) + if(S.id == id && is_valid_z_level(get_turf(S), current_turf)) S.toggle() /obj/machinery/computer/sat_control/ui_data()