From e85f8a448614350062893308d111128e9b3576f3 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Thu, 11 Mar 2021 13:44:28 +0100
Subject: [PATCH] [MIRROR] Replace some turf in range() with RANGETURFS and
fix(?) bspace trauma (#4070)
* Replace some turf in range() with RANGETURFS and fix(?) bspace trauma (#57566)
* Replace some turf in range() with RANGETURFS and fix(?) bspace trauma
Co-authored-by: TiviPlus <57223640+TiviPlus@users.noreply.github.com>
---
code/__HELPERS/game.dm | 2 +-
code/datums/brain_damage/special.dm | 2 +-
code/datums/helper_datums/teleport.dm | 2 +-
code/datums/martial/plasma_fist.dm | 5 +----
code/game/machinery/shieldgen.dm | 2 +-
code/game/objects/items/blueprints.dm | 2 +-
.../structures/lavaland/necropolis_tendril.dm | 2 +-
.../antagonists/eldritch_cult/eldritch_book.dm | 2 +-
.../antagonists/eldritch_cult/eldritch_magic.dm | 2 +-
.../simple_animal/hostile/megafauna/drake.dm | 3 ++-
code/modules/projectiles/guns/misc/beam_rifle.dm | 2 +-
.../projectiles/projectile/special/gravity.dm | 6 +++---
.../chemistry/reagents/pyrotechnic_reagents.dm | 2 +-
code/modules/reagents/chemistry/recipes.dm | 2 +-
.../reagents/chemistry/recipes/pyrotechnics.dm | 14 +++++++-------
.../research/xenobiology/crossbreeding/charged.dm | 3 ++-
.../xenobiology/crossbreeding/regenerative.dm | 6 +++---
code/modules/spells/spell_types/turf_teleport.dm | 8 ++++----
code/modules/swarmers/swarmer_act.dm | 4 ++--
19 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index 67e25e58c57..b4e2f5b1925 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -142,7 +142,7 @@
var/list/turfs = new/list()
var/rsq = radius * (radius+0.5)
- for(var/turf/T in range(radius, centerturf))
+ for(var/turf/T as anything in RANGE_TURFS(radius, centerturf))
var/dx = T.x - centerturf.x
var/dy = T.y - centerturf.y
if(dx*dx + dy*dy <= rsq)
diff --git a/code/datums/brain_damage/special.dm b/code/datums/brain_damage/special.dm
index c7171e9c447..87ac7bfbd8b 100644
--- a/code/datums/brain_damage/special.dm
+++ b/code/datums/brain_damage/special.dm
@@ -62,7 +62,7 @@
COOLDOWN_START(src, portal_cooldown, 10 SECONDS)
var/list/turf/possible_turfs = list()
- for(var/turf/T in range(owner, 8))
+ for(var/turf/T as anything in RANGE_TURFS(8, owner))
if(T.density)
continue
diff --git a/code/datums/helper_datums/teleport.dm b/code/datums/helper_datums/teleport.dm
index 406b1095362..7ce4a74dfdc 100644
--- a/code/datums/helper_datums/teleport.dm
+++ b/code/datums/helper_datums/teleport.dm
@@ -167,7 +167,7 @@
if(!precision)
return list(center)
var/list/posturfs = list()
- for(var/turf/T in range(precision,center))
+ for(var/turf/T as anything in RANGE_TURFS(precision,center))
if(T.is_transition_turf())
continue // Avoid picking these.
var/area/A = T.loc
diff --git a/code/datums/martial/plasma_fist.dm b/code/datums/martial/plasma_fist.dm
index 3f4e314ad3c..5f06345acd2 100644
--- a/code/datums/martial/plasma_fist.dm
+++ b/code/datums/martial/plasma_fist.dm
@@ -38,10 +38,7 @@
A.say("TORNADO SWEEP!", forced="plasma fist")
dance_rotate(A, CALLBACK(GLOBAL_PROC, .proc/playsound, A.loc, 'sound/weapons/punch1.ogg', 15, TRUE, -1))
var/obj/effect/proc_holder/spell/aoe_turf/repulse/R = new(null)
- var/list/turfs = list()
- for(var/turf/T in range(1,A))
- turfs.Add(T)
- R.cast(turfs)
+ R.cast(RANGE_TURFS(1,A))
log_combat(A, D, "tornado sweeped(Plasma Fist)")
return
diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm
index dbf64ded838..38be0b99232 100644
--- a/code/game/machinery/shieldgen.dm
+++ b/code/game/machinery/shieldgen.dm
@@ -137,7 +137,7 @@
update_appearance()
move_resist = INFINITY
- for(var/turf/target_tile in range(shield_range, src))
+ for(var/turf/target_tile as anything in RANGE_TURFS(shield_range, src))
if(isspaceturf(target_tile) && !(locate(/obj/structure/emergency_shield) in target_tile))
if(!(machine_stat & BROKEN) || prob(33))
deployed_shields += new /obj/structure/emergency_shield(target_tile)
diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm
index b0282187caf..d7f718f2005 100644
--- a/code/game/objects/items/blueprints.dm
+++ b/code/game/objects/items/blueprints.dm
@@ -117,7 +117,7 @@
/obj/item/areaeditor/blueprints/proc/get_images(turf/T, viewsize)
. = list()
- for(var/turf/TT in range(viewsize, T))
+ for(var/turf/TT in RANGE_TURFS(viewsize, T))
if(TT.blueprint_data)
. += TT.blueprint_data
diff --git a/code/game/objects/structures/lavaland/necropolis_tendril.dm b/code/game/objects/structures/lavaland/necropolis_tendril.dm
index 67a4625f38d..e202ef46d3b 100644
--- a/code/game/objects/structures/lavaland/necropolis_tendril.dm
+++ b/code/game/objects/structures/lavaland/necropolis_tendril.dm
@@ -94,7 +94,7 @@ GLOBAL_LIST_INIT(tendrils, list())
shake_camera(M, 15, 1)
playsound(get_turf(src),'sound/effects/explosionfar.ogg', 200, TRUE)
visible_message("The tendril falls inward, the ground around it widening into a yawning chasm!")
- for(var/turf/T in range(2,src))
+ for(var/turf/T in RANGE_TURFS(2,src))
if(!T.density)
T.TerraformTurf(/turf/open/chasm/lavaland, /turf/open/chasm/lavaland, flags = CHANGETURF_INHERIT_AIR)
qdel(src)
diff --git a/code/modules/antagonists/eldritch_cult/eldritch_book.dm b/code/modules/antagonists/eldritch_cult/eldritch_book.dm
index ca9262ff853..622174e6e2b 100644
--- a/code/modules/antagonists/eldritch_cult/eldritch_book.dm
+++ b/code/modules/antagonists/eldritch_cult/eldritch_book.dm
@@ -48,7 +48,7 @@
///Draws a rune on a selected turf
/obj/item/forbidden_book/proc/draw_rune(atom/target,mob/user)
- for(var/turf/T in range(1,target))
+ for(var/turf/T as anything in RANGE_TURFS(1,target))
if(is_type_in_typecache(T, blacklisted_turfs))
to_chat(user, "The terrain doesn't support runes!")
return
diff --git a/code/modules/antagonists/eldritch_cult/eldritch_magic.dm b/code/modules/antagonists/eldritch_cult/eldritch_magic.dm
index e24d95f67ef..1570b2fb83e 100644
--- a/code/modules/antagonists/eldritch_cult/eldritch_magic.dm
+++ b/code/modules/antagonists/eldritch_cult/eldritch_magic.dm
@@ -457,7 +457,7 @@
. = ..()
if(!has_fire_ring)
return
- for(var/turf/T in range(1,current_user))
+ for(var/turf/T in RANGE_TURFS(1,current_user))
new /obj/effect/hotspot(T)
T.hotspot_expose(700, 250 * delta_time, 1)
for(var/mob/living/livies in T.contents - current_user)
diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm
index 4b3794c9461..9e74381fdfc 100644
--- a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm
+++ b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm
@@ -143,7 +143,8 @@
if(!target)
return
target.visible_message("Fire rains from the sky!")
- for(var/turf/turf in range(9,get_turf(target)))
+ var/turf/targetturf = get_turf(target)
+ for(var/turf/turf as anything in RANGE_TURFS(9,targetturf))
if(prob(11))
new /obj/effect/temp_visual/target(turf)
diff --git a/code/modules/projectiles/guns/misc/beam_rifle.dm b/code/modules/projectiles/guns/misc/beam_rifle.dm
index eb70e5376bf..03f06e4c12f 100644
--- a/code/modules/projectiles/guns/misc/beam_rifle.dm
+++ b/code/modules/projectiles/guns/misc/beam_rifle.dm
@@ -441,7 +441,7 @@
for(var/mob/living/L in range(aoe_mob_range, epicenter)) //handle aoe mob damage
L.adjustFireLoss(aoe_mob_damage)
to_chat(L, "\The [src] sears you!")
- for(var/turf/T in range(aoe_fire_range, epicenter)) //handle aoe fire
+ for(var/turf/T in RANGE_TURFS(aoe_fire_range, epicenter)) //handle aoe fire
if(prob(aoe_fire_chance))
new /obj/effect/hotspot(T)
for(var/obj/O in range(aoe_structure_range, epicenter))
diff --git a/code/modules/projectiles/projectile/special/gravity.dm b/code/modules/projectiles/projectile/special/gravity.dm
index d3abf739d34..e19a067ce79 100644
--- a/code/modules/projectiles/projectile/special/gravity.dm
+++ b/code/modules/projectiles/projectile/special/gravity.dm
@@ -30,7 +30,7 @@
var/throwtarget = get_edge_target_turf(src, get_dir(src, get_step_away(A, src)))
A.safe_throw_at(throwtarget,power+1,1, force = MOVE_FORCE_EXTREMELY_STRONG)
thrown_items[A] = A
- for(var/turf/F in range(T,power))
+ for(var/turf/F in RANGE_TURFS(power, T))
new /obj/effect/temp_visual/gravpush(F)
/obj/projectile/gravityattract
@@ -64,7 +64,7 @@
continue
A.safe_throw_at(T, power+1, 1, force = MOVE_FORCE_EXTREMELY_STRONG)
thrown_items[A] = A
- for(var/turf/F in range(T,power))
+ for(var/turf/F in RANGE_TURFS(power, T))
new /obj/effect/temp_visual/gravpush(F)
/obj/projectile/gravitychaos
@@ -98,5 +98,5 @@
continue
A.safe_throw_at(get_edge_target_turf(A, pick(GLOB.cardinals)), power+1, 1, force = MOVE_FORCE_EXTREMELY_STRONG)
thrown_items[A] = A
- for(var/turf/Z in range(T,power))
+ for(var/turf/Z as anything in RANGE_TURFS(power,T))
new /obj/effect/temp_visual/gravpush(Z)
diff --git a/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm b/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm
index 9c939eb1e7a..9c351cdc983 100644
--- a/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm
+++ b/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm
@@ -67,7 +67,7 @@
else if(prob(reac_volume))
target_floor.burn_tile()
if(isfloorturf(target_floor))
- for(var/turf/nearby_turf in range(1, target_floor))
+ for(var/turf/nearby_turf in RANGE_TURFS(1, target_floor))
if(!locate(/obj/effect/hotspot) in nearby_turf)
new /obj/effect/hotspot(nearby_turf)
diff --git a/code/modules/reagents/chemistry/recipes.dm b/code/modules/reagents/chemistry/recipes.dm
index d00b060e362..1874e026ea6 100644
--- a/code/modules/reagents/chemistry/recipes.dm
+++ b/code/modules/reagents/chemistry/recipes.dm
@@ -430,7 +430,7 @@
if(fire_range == 0)
new /obj/effect/hotspot(location)
return
- for(var/turf/turf as anything in range(fire_range, location))
+ for(var/turf/turf as anything in RANGE_TURFS(fire_range, location))
new /obj/effect/hotspot(turf)
///////////END FIRE BASED EXPLOSIONS
diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm
index 3edba02d2f9..f3dcadbb454 100644
--- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm
+++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm
@@ -73,8 +73,8 @@
/datum/chemical_reaction/reagent_explosion/rdx_explosion2/on_reaction(datum/equilibrium/reaction, datum/reagents/holder, created_volume)
var/fire_range = round(created_volume/30)
var/turf/T = get_turf(holder.my_atom)
- for(var/turf/turf in range(fire_range,T))
- new /obj/effect/hotspot(turf)
+ for(var/turf/target as anything in RANGE_TURFS(fire_range,T))
+ new /obj/effect/hotspot(target)
holder.chem_temp = 500
..()
@@ -87,7 +87,7 @@
/datum/chemical_reaction/reagent_explosion/rdx_explosion3/on_reaction(datum/equilibrium/reaction, datum/reagents/holder, created_volume)
var/fire_range = round(created_volume/20)
var/turf/T = get_turf(holder.my_atom)
- for(var/turf/turf in range(fire_range,T))
+ for(var/turf/turf as anything in RANGE_TURFS(fire_range,T))
new /obj/effect/hotspot(turf)
holder.chem_temp = 750
..()
@@ -232,8 +232,8 @@
/datum/chemical_reaction/clf3/on_reaction(datum/equilibrium/reaction, datum/reagents/holder, created_volume)
var/turf/T = get_turf(holder.my_atom)
- for(var/turf/turf in range(1,T))
- new /obj/effect/hotspot(turf)
+ for(var/turf/target as anything in RANGE_TURFS(1,T))
+ new /obj/effect/hotspot(target)
holder.chem_temp = 1000 // hot as shit
/datum/chemical_reaction/reagent_explosion/methsplosion
@@ -246,8 +246,8 @@
/datum/chemical_reaction/reagent_explosion/methsplosion/on_reaction(datum/equilibrium/reaction, datum/reagents/holder, created_volume)
var/turf/T = get_turf(holder.my_atom)
- for(var/turf/turf in range(1,T))
- new /obj/effect/hotspot(turf)
+ for(var/turf/target in RANGE_TURFS(1,T))
+ new /obj/effect/hotspot(target)
holder.chem_temp = 1000 // hot as shit
..()
diff --git a/code/modules/research/xenobiology/crossbreeding/charged.dm b/code/modules/research/xenobiology/crossbreeding/charged.dm
index ffe03db73a3..7b41c0a4661 100644
--- a/code/modules/research/xenobiology/crossbreeding/charged.dm
+++ b/code/modules/research/xenobiology/crossbreeding/charged.dm
@@ -42,7 +42,8 @@ Charged extracts:
effect_desc = "Instantly makes a large burst of flame for a moment."
/obj/item/slimecross/charged/orange/do_effect(mob/user)
- for(var/turf/turf in range(5,get_turf(user)))
+ var/turf/targetturf = get_turf(user)
+ for(var/turf/turf as anything in RANGE_TURFS(5,targetturf))
if(!locate(/obj/effect/hotspot) in turf)
new /obj/effect/hotspot(turf)
..()
diff --git a/code/modules/research/xenobiology/crossbreeding/regenerative.dm b/code/modules/research/xenobiology/crossbreeding/regenerative.dm
index 0c4a7e1249b..8eb1e0a8562 100644
--- a/code/modules/research/xenobiology/crossbreeding/regenerative.dm
+++ b/code/modules/research/xenobiology/crossbreeding/regenerative.dm
@@ -43,9 +43,9 @@ Regenerative extracts:
/obj/item/slimecross/regenerative/orange/core_effect_before(mob/living/target, mob/user)
target.visible_message("The [src] boils over!")
- for(var/turf/turf in range(1,target))
- if(!locate(/obj/effect/hotspot) in turf)
- new /obj/effect/hotspot(turf)
+ for(var/turf/targetturf in RANGE_TURFS(1,target))
+ if(!locate(/obj/effect/hotspot) in targetturf)
+ new /obj/effect/hotspot(targetturf)
/obj/item/slimecross/regenerative/purple
colour = "purple"
diff --git a/code/modules/spells/spell_types/turf_teleport.dm b/code/modules/spells/spell_types/turf_teleport.dm
index ab82fbb4fb0..f9ae58ee750 100644
--- a/code/modules/spells/spell_types/turf_teleport.dm
+++ b/code/modules/spells/spell_types/turf_teleport.dm
@@ -15,8 +15,8 @@
playsound(get_turf(user), sound1, 50,TRUE)
for(var/mob/living/target in targets)
var/list/turfs = new/list()
- for(var/turf/T in range(target,outer_tele_radius))
- if(T in range(target,inner_tele_radius))
+ for(var/turf/T as anything in RANGE_TURFS(outer_tele_radius, target))
+ if(T in RANGE_TURFS(inner_tele_radius, target))
continue
if(isspaceturf(T) && !include_space)
continue
@@ -30,8 +30,8 @@
if(!turfs.len)
var/list/turfs_to_pick_from = list()
- for(var/turf/T in orange(target,outer_tele_radius))
- if(!(T in orange(target,inner_tele_radius)))
+ for(var/turf/T as anything in RANGE_TURFS(outer_tele_radius, target))
+ if(!(T in RANGE_TURFS(inner_tele_radius, target)))
turfs_to_pick_from += T
turfs += pick(/turf in turfs_to_pick_from)
diff --git a/code/modules/swarmers/swarmer_act.dm b/code/modules/swarmers/swarmer_act.dm
index e69950b2d9a..fc9e2273890 100644
--- a/code/modules/swarmers/swarmer_act.dm
+++ b/code/modules/swarmers/swarmer_act.dm
@@ -109,7 +109,7 @@
/obj/machinery/door/swarmer_act(mob/living/simple_animal/hostile/swarmer/actor)
var/isonshuttle = istype(get_area(src), /area/shuttle)
- for(var/turf/turf_in_range in range(1, src))
+ for(var/turf/turf_in_range as anything in RANGE_TURFS(1, src))
var/area/turf_area = get_area(turf_in_range)
//Check for dangerous pressure differences
if (turf_in_range.return_turf_delta_p() > DANGEROUS_DELTA_P)
@@ -193,7 +193,7 @@
/turf/closed/wall/swarmer_act(mob/living/simple_animal/hostile/swarmer/actor)
var/isonshuttle = istype(loc, /area/shuttle)
- for(var/turf/turf_in_range in range(1, src))
+ for(var/turf/turf_in_range as anything in RANGE_TURFS(1, src))
var/area/turf_area = get_area(turf_in_range)
if (turf_in_range.return_turf_delta_p() > DANGEROUS_DELTA_P)
to_chat(actor, "Destroying this object has the potential to cause an explosive pressure release. Aborting.")