Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed May 9, 2024
1 parent 92655a0 commit e337317
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 98 deletions.
22 changes: 13 additions & 9 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)
block( \
(CENTER).x-(RADIUS), (CENTER).y-(RADIUS), (CENTER).z, \
(CENTER).x+(RADIUS), (CENTER).y+(RADIUS), (CENTER).z \
)

#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max((CENTER).x-(H_RADIUS),1), max((CENTER).y-(V_RADIUS),1), (CENTER).z), \
locate(min((CENTER).x+(H_RADIUS),world.maxx), min((CENTER).y+(V_RADIUS),world.maxy), (CENTER).z) \
(CENTER).x-(H_RADIUS), (CENTER).y-(V_RADIUS), (CENTER).z, \
(CENTER).x+(H_RADIUS), (CENTER).y+(V_RADIUS), (CENTER).z \
)

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

/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width, checks for being outside the world border for you
/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width
#define CORNER_BLOCK(corner, width, height) CORNER_BLOCK_OFFSET(corner, width, height, 0, 0)

/// Returns a list of turfs similar to CORNER_BLOCK but with offsets
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) ((block(locate(corner.x + offset_x, corner.y + offset_y, corner.z), locate(min(corner.x + (width - 1) + offset_x, world.maxx), min(corner.y + (height - 1) + offset_y, world.maxy), corner.z))))
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) \
block( \
(corner).x + (offset_x), (corner).y + (offset_y), (corner).z, \
(corner).x + ((width) - 1) + (offset_x), (corner).y + ((height) - 1) + (offset_y), (corner).z \
)

/// Returns an outline (neighboring turfs) of the given block
#define CORNER_OUTLINE(corner, width, height) ( \
Expand Down
3 changes: 1 addition & 2 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@
if(orange)
turfs -= get_turf(center)
. = list()
for(var/V in turfs)
var/turf/T = V
for(var/turf/T as anything in turfs)
. += T
. += T.contents
if(areas)
Expand Down
3 changes: 1 addition & 2 deletions code/controllers/subsystem/interior.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ SUBSYSTEM_DEF(interior)

var/list/bounds = template.load(locate(bottom_left.x + (INTERIOR_BORDER_SIZE / 2), bottom_left.y + (INTERIOR_BORDER_SIZE / 2), bottom_left.z), centered = FALSE)

var/list/turfs = block( locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
var/list/turfs = block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])

var/list/areas = list()
for(var/turf/current_turf as anything in turfs)
Expand Down
4 changes: 1 addition & 3 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ SUBSYSTEM_DEF(mapping)
if(!level_trait(z,ZTRAIT_RESERVED))
clearing_reserved_turfs = FALSE
CRASH("Invalid z level prepared for reservations.")
var/turf/A = get_turf(locate(SHUTTLE_TRANSIT_BORDER,SHUTTLE_TRANSIT_BORDER,z))
var/turf/B = get_turf(locate(world.maxx - SHUTTLE_TRANSIT_BORDER,world.maxy - SHUTTLE_TRANSIT_BORDER,z))
var/block = block(A, B)
var/block = block(SHUTTLE_TRANSIT_BORDER, SHUTTLE_TRANSIT_BORDER, z, world.maxx - SHUTTLE_TRANSIT_BORDER, world.maxy - SHUTTLE_TRANSIT_BORDER, z)
for(var/turf/T as anything in block)
// No need to empty() these, because they just got created and are already /turf/open/space/basic.
T.turf_flags = UNUSED_RESERVATION_TURF
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
LAZYINITLIST(affected_turfs)
if(range <= 2)
//Range here is 1 because actual range of lighting mask is 1 tile even if it says that range is 2
for(var/turf/lit_turf in RANGE_TURFS(1, current_holder.loc))
for(var/turf/lit_turf as anything in RANGE_TURFS(1, current_holder.loc))
lit_turf.dynamic_lumcount += lum_power
affected_turfs += lit_turf
else
Expand Down
6 changes: 1 addition & 5 deletions code/datums/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@
. = ..()
if(!.)
return
var/list/turfs = block( locate(.[MAP_MINX], .[MAP_MINY], .[MAP_MINZ]),
locate(.[MAP_MAXX], .[MAP_MAXY], .[MAP_MAXZ]))
for(var/i in 1 to turfs.len)
var/turf/place = turfs[i]

for(var/turf/place as anything in block(.[MAP_MINX], .[MAP_MINY], .[MAP_MINZ], .[MAP_MAXX], .[MAP_MAXY], .[MAP_MAXZ]))
// ================== CM Change ==================
// We perform atom initialization of the docking_ports BEFORE skipping space,
// because our lifeboats have their corners as object props and still
Expand Down
8 changes: 1 addition & 7 deletions code/datums/tutorial/_tutorial.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ GLOBAL_LIST_EMPTY_TYPED(ongoing_tutorials, /datum/tutorial)
/datum/tutorial/proc/verify_template_loaded()
// We subtract 1 from x and y because the bottom left corner doesn't start at the walls.
var/turf/true_bottom_left_corner = reservation.bottom_left_turfs[1]
// We subtract 1 from x and y here because the bottom left corner counts as the first tile
var/turf/top_right_corner = locate(
true_bottom_left_corner.x + initial(tutorial_template.width) - 1,
true_bottom_left_corner.y + initial(tutorial_template.height) - 1,
true_bottom_left_corner.z
)
for(var/turf/tile as anything in block(true_bottom_left_corner, top_right_corner))
for(var/turf/tile as anything in CORNER_BLOCK(true_bottom_left_corner, initial(tutorial_template.width), initial(tutorial_template.height)))
// For some reason I'm unsure of, the template will not always fully load, leaving some tiles to be space tiles. So, we check all tiles in the (small) tutorial area
// and tell start_tutorial to abort if there's any space tiles.
if(istype(tile, /turf/open/space))
Expand Down
8 changes: 2 additions & 6 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt"))
if(!map_load_z_cutoff)
return
// var/area/global_area = GLOB.areas_by_type[world.area] // We're guaranteed to be touching the global area, so we'll just do this
// var/list/to_add = block(
// locate(old_max + 1, 1, 1),
// locate(maxx, maxy, map_load_z_cutoff))
// var/list/to_add = block(old_max + 1, 1, 1, maxx, maxy, map_load_z_cutoff)
// global_area.contained_turfs += to_add

/world/proc/increase_max_y(new_maxy, map_load_z_cutoff = maxz)
Expand All @@ -345,9 +343,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt"))
if(!map_load_z_cutoff)
return
// var/area/global_area = GLOB.areas_by_type[world.area] // We're guarenteed to be touching the global area, so we'll just do this
// var/list/to_add = block(
// locate(1, old_maxy + 1, 1),
// locate(maxx, maxy, map_load_z_cutoff))
// var/list/to_add = block(1, old_maxy + 1, 1, maxx, maxy, map_load_z_cutoff)
// global_area.contained_turfs += to_add

/world/proc/incrementMaxZ()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/buildmode/submodes/area_edit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var/choice = alert("Are you sure you want to fill area?", "Area Fill Confirmation", "Yes", "No")
if(choice != "Yes")
return
for(var/turf/T in block(get_turf(cornerA),get_turf(cornerB)))
for(var/turf/T as anything in block(get_turf(cornerA),get_turf(cornerB)))
storedarea.contents.Add(T)
log_admin("Build Mode: [key_name(c)] set the area of the region from [AREACOORD(cornerA)] through [AREACOORD(cornerB)] to [storedarea].")

5 changes: 2 additions & 3 deletions code/modules/buildmode/submodes/fill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
if(LAZYACCESS(modifiers, LEFT_CLICK)) //rectangular
if(LAZYACCESS(modifiers, CTRL_CLICK))
var/list/deletion_area = block(get_turf(cornerA),get_turf(cornerB))
for(var/deleted_turfs in deletion_area)
var/turf/T = deleted_turfs
for(var/turf/T as anything in deletion_area)
for(var/atom/movable/AM in T)
qdel(AM)
T.ScrapeAway(INFINITY, CHANGETURF_DEFER_CHANGE)
Expand All @@ -59,7 +58,7 @@
var/choice = alert("Your selected area is [selection_size] tiles! Continue?", "Large Fill Confirmation", CONFIRM_YES, CONFIRM_NO)
if(choice != CONFIRM_YES)
return
for(var/turf/T in block(get_turf(cornerA),get_turf(cornerB)))
for(var/turf/T as anything in deletion_area)
if(ispath(objholder,/turf))
T = T.ChangeTurf(objholder)
T.setDir(BM.build_dir)
Expand Down
7 changes: 3 additions & 4 deletions code/modules/cm_tech/techtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@
// (The `+ 2` on both of these is 1 for a buffer tile, and 1 for the outer `/turf/closed/void`.)
var/area_max_x = longest_tier * 2 + 2
var/area_max_y = length(all_techs) * 3 + 2
for(var/t in block(locate(1, 1, zlevel.z_value), locate(area_max_x, area_max_y, zlevel.z_value)))
var/turf/pos = t
for(var/A in pos)
for(var/turf/pos as anything in block(1, 1, zlevel.z_value, area_max_x, area_max_y, zlevel.z_value))
for(var/A as anything in pos)
qdel(A)

if(pos.x == area_max_x || pos.y == area_max_y)
Expand All @@ -83,7 +82,7 @@
var/x_offset = (longest_tier - tier_length) + 1

var/datum/tier/T = tree_tiers[tier]
for(var/turf/pos in block(locate(x_offset, y_offset, zlevel.z_value), locate(x_offset + tier_length*2, y_offset + 2, zlevel.z_value)))
for(var/turf/pos as anything in block(x_offset, y_offset, zlevel.z_value, x_offset + tier_length*2, y_offset + 2, zlevel.z_value))
pos.ChangeTurf(/turf/open/blank)
pos.color = "#000000"
LAZYADD(T.tier_turfs, pos)
Expand Down
9 changes: 2 additions & 7 deletions code/modules/holidays/halloween/decorators.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
var/list/turf/valid_turfs = list()
var/list/ground_levels = SSmapping.levels_by_trait(ZTRAIT_GROUND)
for(var/ground_z in ground_levels)
var/list/turf/all_turfs = block(locate(1, 1, ground_z), locate(world.maxx, world.maxy, ground_z))
for(var/turf/open/turf in all_turfs)
for(var/turf/open/turf in Z_TURFS(ground_z))
if(turf.is_groundmap_turf)
var/valid = TRUE
for(var/atom/movable/movable as anything in turf.contents)
Expand All @@ -42,11 +41,7 @@
if(!length(valid_turfs))
break
var/turf/considered_turf = pick(valid_turfs)
var/x_min = max(1, considered_turf.x - exclusion_range)
var/y_min = max(1, considered_turf.y - exclusion_range)
var/x_max = min(world.maxx, considered_turf.x + exclusion_range)
var/y_max = min(world.maxy, considered_turf.y + exclusion_range)
var/list/turf/denied_turfs = block(locate(x_min, y_min, considered_turf.z), locate(x_max, y_max, considered_turf.z))
var/list/turf/denied_turfs = RANGE_TURFS(exclusion_range, considered_turf)
valid_turfs -= denied_turfs
picked_turfs += considered_turf

Expand Down
20 changes: 3 additions & 17 deletions code/modules/mapping/map_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,7 @@
var/list/obj/docking_port/stationary/ports = list()
var/list/area/areas = list()

var/list/turfs = block(
locate(
bounds[MAP_MINX],
bounds[MAP_MINY],
bounds[MAP_MINZ]
),
locate(
bounds[MAP_MAXX],
bounds[MAP_MAXY],
bounds[MAP_MAXZ]
)
)
var/list/turfs = block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])
for(var/turf/current_turf as anything in turfs)
var/area/current_turfs_area = current_turf.loc
areas |= current_turfs_area
Expand Down Expand Up @@ -163,12 +152,9 @@
return

/datum/map_template/proc/get_affected_turfs(turf/T, centered = FALSE)
var/turf/placement = T
if(centered)
var/turf/corner = locate(placement.x - round(width/2), placement.y - round(height/2), placement.z)
if(corner)
placement = corner
return block(placement, locate(placement.x+width-1, placement.y+height-1, placement.z))
return RECT_TURFS(floor(width / 2), floor(height / 2), T)
return CORNER_BLOCK(T, width, height)


//for your ever biggening badminnery kevinz000
Expand Down
5 changes: 1 addition & 4 deletions code/modules/mapping/reader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,7 @@
// SSmapping.build_area_turfs(z_index)

if(!no_changeturf)
var/list/turfs = block(
locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
for(var/turf/T as anything in turfs)
for(var/turf/T as anything in block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
//we do this after we load everything in. if we don't, we'll have weird atmos bugs regarding atmos adjacent turfs
T.AfterChange(CHANGETURF_IGNORE_AIR)

Expand Down
3 changes: 1 addition & 2 deletions code/modules/mapping/space_management/space_reservation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@
if(!final)
continue
passing = TRUE
for(var/I in final)
var/turf/checking = I
for(var/turf/checking as anything in final)
if(!(checking.turf_flags & UNUSED_RESERVATION_TURF))
passing = FALSE
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
return

var/list/alerts = list()
for(var/i in RANGE_TURFS(Floor(width/2), T))
for(var/i as anything in RANGE_TURFS(Floor(width/2), T))
alerts += new /obj/effect/warning/alien(i)

if(!do_after(Q, time_taken, INTERRUPT_NO_NEEDHAND, BUSY_ICON_FRIENDLY))
Expand Down
4 changes: 1 addition & 3 deletions code/modules/nightmare/nmtasks/mapload.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@
var/list/bounds = parsed.bounds
if(length(bounds) < 6)
return
var/list/turf_block = block( locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
var/list/area/arealist = list()
var/list/atom/atomlist = list()
for(var/turf/turf as anything in turf_block)
for(var/turf/turf as anything in block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
atomlist += turf
if(turf.loc)
arealist |= turf.loc
Expand Down
3 changes: 1 addition & 2 deletions code/modules/nightmare/nmtasks/mapscheduler.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
var/list/tainted = list()

for(var/list/bounds as anything in tainted_bounds)
var/list/TT = block( locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
var/list/TT = block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])
tainted |= TT

for(var/turf/T as anything in tainted)
Expand Down
8 changes: 2 additions & 6 deletions code/modules/shuttle/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@
///returns turfs within our projected rectangle in no particular order
/obj/docking_port/proc/return_turfs()
var/list/L = return_coords()
var/turf/T0 = locate(L[1],L[2],z)
var/turf/T1 = locate(L[3],L[4],z)
return block(T0,T1)
return block(L[1], L[2], z, L[3], L[4], z)

/obj/docking_port/proc/return_center_turf()
var/list/L = return_coords()
Expand Down Expand Up @@ -159,9 +157,7 @@
//Debug proc used to highlight bounding area
/obj/docking_port/proc/highlight(_color)
var/list/L = return_coords()
var/turf/T0 = locate(L[1],L[2],z)
var/turf/T1 = locate(L[3],L[4],z)
for(var/turf/T in block(T0,T1))
for(var/turf/T as anything in block(L[1], L[2], z, L[3], L[4], z))
T.color = _color
T.maptext = null
if(_color)
Expand Down
3 changes: 1 addition & 2 deletions code/modules/tents/folded_tents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@

/obj/item/folded_tent/proc/get_deployment_area(turf/ref_turf)
RETURN_TYPE(/list/turf)
var/turf/block_end_turf = locate(ref_turf.x + dim_x - 1, ref_turf.y + dim_y - 1, ref_turf.z)
return block(ref_turf, block_end_turf)
return CORNER_BLOCK(ref_turf, dim_x, dim_y)

/obj/item/folded_tent/attack_self(mob/living/user)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/unit_tests/unit_test.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GLOBAL_VAR_INIT(focused_test, focused_test())
/datum/unit_test/Destroy()
QDEL_LIST(allocated)
// clear the test area
for (var/turf/turf in block(locate(1, 1, run_loc_floor_bottom_left.z), locate(world.maxx, world.maxy, run_loc_floor_bottom_left.z)))
for (var/turf/turf as anything in Z_TURFS(run_loc_floor_bottom_left.z))
for (var/content in turf.contents)
if (istype(content, /obj/effect/landmark))
continue
Expand Down
6 changes: 3 additions & 3 deletions code/modules/vehicles/interior/interior.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

var/list/passengers
var/list/bounds = get_bound_turfs()
for(var/turf/T in block(bounds[1], bounds[2]))
for(var/turf/T as anything in block(bounds[1], bounds[2]))
for(var/atom/A in T)
if(isliving(A))
LAZYADD(passengers, A)
Expand Down Expand Up @@ -322,7 +322,7 @@
/datum/interior/proc/find_entrances()
var/list/bounds = get_bound_turfs()

for(var/turf/T in block(bounds[1], bounds[2]))
for(var/turf/T as anything in block(bounds[1], bounds[2]))
var/obj/effect/landmark/interior/spawn/entrance/E = locate() in T
if(E)
LAZYADD(entrance_markers, E)
Expand All @@ -332,6 +332,6 @@
/datum/interior/proc/handle_landmarks()
var/list/bounds = get_bound_turfs()

for(var/turf/T in block(bounds[1], bounds[2]))
for(var/turf/T as anything in block(bounds[1], bounds[2]))
for(var/obj/effect/landmark/interior/L in T)
L.on_load(src)
17 changes: 10 additions & 7 deletions code/modules/vehicles/multitile/multitile_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,18 @@
/obj/vehicle/multitile/proc/can_move(direction)
var/can_move = TRUE

var/turf/min_turf = locate(x + bound_x / world.icon_size, y + bound_y / world.icon_size, z)
var/turf/max_turf = locate(min_turf.x + (bound_width / world.icon_size) - 1, min_turf.y + (bound_height / world.icon_size) - 1, z)
var/list/old_turfs = block(min_turf, max_turf)
var/bound_x_tiles = bound_x / world.icon_size
var/bound_y_tiles = bound_y / world.icon_size
var/turf/min_turf = locate(x + bound_x_tiles, y + bound_y_tiles, z)

var/bound_width_tiles = bound_width / world.icon_size
var/bound_height_tiles = bound_height / world.icon_size
var/list/old_turfs = CORNER_BLOCK(min_turf, bound_width_tiles, bound_height_tiles)

var/turf/new_loc = get_step(src, direction)
min_turf = locate(new_loc.x + bound_x / world.icon_size, new_loc.y + bound_y / world.icon_size, z)
max_turf = locate(min_turf.x + (bound_width / world.icon_size) - 1, min_turf.y + (bound_height / world.icon_size) - 1, z)
min_turf = locate(new_loc.x + bound_x_tiles, new_loc.y + bound_y_tiles, z)

for(var/turf/T in block(min_turf, max_turf))
for(var/turf/T as anything in CORNER_BLOCK(min_turf, bound_width_tiles, bound_height_tiles))
// only check the turfs we're moving to
if(T in old_turfs)
continue
Expand Down Expand Up @@ -264,7 +267,7 @@
break

var/list/bounds = interior.get_bound_turfs()
for(var/turf/T in block(bounds[1], bounds[2]))
for(var/turf/T as anything in block(bounds[1], bounds[2]))
for(var/atom/movable/A in T)
if(A.anchored)
continue
Expand Down

0 comments on commit e337317

Please sign in to comment.