Skip to content

Commit

Permalink
TGS Test Merge (#6692)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm13-github committed Aug 2, 2024
2 parents 2179978 + 834383b commit b33e3d1
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 47 deletions.
13 changes: 7 additions & 6 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
(CENTER).x-(RADIUS), (CENTER).y-(RADIUS), (CENTER).z, \
(CENTER).x+(RADIUS), (CENTER).y+(RADIUS), (CENTER).z \
)

/// Returns a list of turfs within H_RADIUS tiles horizontally and V_RADIUS tiles vertically of CENTER.
#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
(CENTER).x-(H_RADIUS), (CENTER).y-(V_RADIUS), (CENTER).z, \
(CENTER).x+(H_RADIUS), (CENTER).y+(V_RADIUS), (CENTER).z \
)

/// Returns a list of turfs within Dist tiles of Center. When Dist >= 5 faster than a `range()` filtered to `/turf`s.
#define RANGE_TURFS(Dist, Center) RECT_TURFS(Dist, Dist, Center)

/// Returns a list of turfs within Dist tiles of Center, excluding Center. When Dist >= 5 faster than an `orange()` filtered to `/turf`s.
#define ORANGE_TURFS(Dist, Center) (RANGE_TURFS(Dist, Center) - Center)

///Returns all turfs in a zlevel
#define Z_TURFS(ZLEVEL) block(1, 1, (ZLEVEL), world.maxx, world.maxy, (ZLEVEL))

Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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)
Expand Down
5 changes: 1 addition & 4 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1289,10 +1289,7 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
origin = get_turf(origin)
if(!origin)
return
var/list/turfs = list()
for(var/turf/T in orange(origin, outer_range))
if(!inner_range || get_dist(origin, T) >= inner_range)
turfs += T
var/list/turfs = (RANGE_TURFS(outer_range, origin) - RANGE_TURFS(inner_range - 1, origin))
if(length(turfs))
return pick(turfs)

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/door_display/door_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
if(F.id == id)
targets += F
if(has_wall_divider)
for(var/turf/closed/wall/almayer/research/containment/wall/divide/W in orange(src, 8))
for(var/turf/closed/wall/almayer/research/containment/wall/divide/W in ORANGE_TURFS(8, src))
targets += W

/obj/structure/machinery/door_display/research_cell/Destroy()
Expand Down
5 changes: 1 addition & 4 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@
return located_turfs

/obj/structure/machinery/door/proc/borders_space()
for(var/turf/target in range(1, src))
if(istype(target, /turf/open/space))
return TRUE
return FALSE
return !!(locate(/turf/open/space) in range(1, src))

/obj/structure/machinery/door/Collided(atom/movable/AM)
if(panel_open || operating)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/teleportation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
else
L["[com.id] (Inactive)"] = com.locked
var/list/turfs = list( )
for(var/turf/T in orange(10))
for(var/turf/T as anything in ORANGE_TURFS(10, src))
if(T.x>world.maxx-8 || T.x<8) continue //putting them at the edge is dumb
if(T.y>world.maxy-8 || T.y<8) continue
turfs += T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,19 +584,14 @@
src.visible_message(SPAN_NOTICE("The [src.name] has been squashed."),SPAN_MODERATE("You hear a smack."))
qdel(src)
return
for(var/turf/T in orange(M,outer_teleport_radius))
if(T in orange(M,inner_teleport_radius)) continue
for(var/turf/T as anything in (RANGE_TURFS(outer_teleport_radius, M) - RANGE_TURFS(inner_teleport_radius, M)))
if(istype(T,/turf/open/space)) continue
if(T.density) continue
if(T.x>world.maxx-outer_teleport_radius || T.x<outer_teleport_radius) continue
if(T.y>world.maxy-outer_teleport_radius || T.y<outer_teleport_radius) continue
turfs += T
if(!length(turfs))
var/list/turfs_to_pick_from = list()
for(var/turf/T in orange(M,outer_teleport_radius))
if(!(T in orange(M,inner_teleport_radius)))
turfs_to_pick_from += T
turfs += pick(/turf in turfs_to_pick_from)
turfs += pick(RANGE_TURFS(outer_teleport_radius, M) - RANGE_TURFS(inner_teleport_radius, M))
var/turf/picked = pick(turfs)
if(!isturf(picked)) return
switch(rand(1,2))//Decides randomly to teleport the thrower or the throwee.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/cm_aliens/structures/special/pylon_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
. = ..()

node = place_node()
for(var/turf/A in range(floor(cover_range*PYLON_COVERAGE_MULT), loc))
for(var/turf/A as anything in RANGE_TURFS(floor(cover_range*PYLON_COVERAGE_MULT), loc))
LAZYADD(A.linked_pylons, src)
linked_turfs += A

Expand Down
8 changes: 2 additions & 6 deletions code/modules/cm_marines/dropship_ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@

/obj/structure/ship_ammo/heavygun/detonate_on(turf/impact, obj/structure/dropship_equipment/weapon/fired_from)
set waitfor = 0
var/list/turf_list = list()
for(var/turf/T in range(bullet_spread_range, impact))
turf_list += T
var/list/turf_list = RANGE_TURFS(bullet_spread_range, impact)
var/soundplaycooldown = 0
var/debriscooldown = 0

Expand Down Expand Up @@ -243,9 +241,7 @@

/obj/structure/ship_ammo/laser_battery/detonate_on(turf/impact, obj/structure/dropship_equipment/weapon/fired_from)
set waitfor = 0
var/list/turf_list = list()
for(var/turf/T in range(3, impact)) //This is its area of effect
turf_list += T
var/list/turf_list = RANGE_TURFS(3, impact) //This is its area of effect
playsound(impact, 'sound/effects/pred_vision.ogg', 20, 1)
for(var/i=1 to 16) //This is how many tiles within that area of effect will be randomly ignited
var/turf/U = pick(turf_list)
Expand Down
8 changes: 2 additions & 6 deletions code/modules/cm_marines/dropship_equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@

ammo_accuracy_range /= 2 //buff for basically pointblanking the ground

var/list/possible_turfs = list()
for(var/turf/TU in range(ammo_accuracy_range, target_turf))
possible_turfs += TU
var/list/possible_turfs = RANGE_TURFS(ammo_accuracy_range, target_turf)
var/turf/impact = pick(possible_turfs)
sleep(3)
SA.source_mob = user
Expand Down Expand Up @@ -1328,9 +1326,7 @@

ammo_accuracy_range /= 2 //buff for basically pointblanking the ground

var/list/possible_turfs = list()
for(var/turf/TU in range(ammo_accuracy_range, target_turf))
possible_turfs += TU
var/list/possible_turfs = RANGE_TURFS(ammo_accuracy_range, target_turf)
var/turf/impact = pick(possible_turfs)
sleep(3)
SA.source_mob = user
Expand Down
5 changes: 1 addition & 4 deletions code/modules/cm_marines/orbital_cannon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,7 @@ GLOBAL_LIST_EMPTY(orbital_cannon_cancellation)
set waitfor = 0

var/range_num = 12
var/list/turf_list = list()

for(var/turf/T in range(range_num, target))
turf_list += T
var/list/turf_list = RANGE_TURFS(range_num, target)

for(var/i = 1 to total_amount)
for(var/k = 1 to instant_amount)
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@
if(pickup_recent_item_on_turf(user_turf))
return

var/range_list = orange(1, src)
for(var/turf/nearby_turf in range_list)
for(var/turf/nearby_turf in orange(1, src))
if(pickup_recent_item_on_turf(nearby_turf))
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
//1% chance to skitter madly away
if(!busy && prob(1))
/*var/list/move_targets = list()
for(var/turf/T in orange(20, src))
for(var/turf/T as anything in ORANGE_TURFS(20, src))
move_targets.Add(T)*/
stop_automated_movement = 1
walk_to(src, pick(orange(20, src)), 1, move_to_delay)
Expand Down
4 changes: 1 addition & 3 deletions code/modules/projectiles/ammo_boxes/misc_boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@
if(flare_amount > 0)
handle_side_effects(host_box, TRUE)

var/list/turf_list = list()
for(var/turf/T in range(5, (host_box ? host_box : src)))
turf_list += T
var/list/turf_list = RANGE_TURFS(5, (host_box ? host_box : src))
for(var/i = 1, i <= flare_amount, i++)
addtimer(CALLBACK(src, PROC_REF(explode), (host_box ? host_box : src), turf_list), rand(1, 6) SECONDS)
return
Expand Down

0 comments on commit b33e3d1

Please sign in to comment.