From 5c5a58107e5bee6f81a9c07265bdc8b7b719f4ce Mon Sep 17 00:00:00 2001 From: BeebBeebBoob Date: Wed, 19 Jun 2024 14:43:12 +0300 Subject: [PATCH] refactor: remove from all block proc all locate procs (#5208) --- code/__DEFINES/misc.dm | 12 ++++++------ code/__HELPERS/icon_smoothing.dm | 2 +- code/__HELPERS/unsorted.dm | 2 +- code/controllers/subsystem/air.dm | 2 +- code/datums/helper_datums/map_template.dm | 3 +-- code/datums/mapgen/LavalandGenerator.dm | 2 +- code/game/atoms_movable.dm | 8 +++----- code/game/gamemodes/blob/blob_report.dm | 2 +- code/game/gamemodes/blob/powers.dm | 2 +- code/game/gamemodes/steal_items.dm | 2 +- code/game/turfs/simulated/river.dm | 2 +- code/modules/awaymissions/maploader/reader.dm | 2 +- code/modules/awaymissions/zlevel.dm | 2 +- code/modules/events/wormholes.dm | 2 +- code/modules/mob/living/silicon/ai/freelook/chunk.dm | 2 +- code/modules/power/gravitygenerator.dm | 2 +- code/modules/shuttle/shuttle.dm | 8 ++------ code/modules/space_management/space_level.dm | 10 +++++----- code/modules/station_goals/bsa.dm | 2 +- code/modules/unit_tests/test_runner.dm | 2 +- 20 files changed, 32 insertions(+), 39 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index b8e49e91caf..9d6998b2ee3 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -113,17 +113,17 @@ #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) \ + max(CENTER.x - (H_RADIUS), 1), max(CENTER.y - (V_RADIUS), 1), CENTER.z, \ + min(CENTER.x + (H_RADIUS), world.maxx), min(CENTER.y + (V_RADIUS), world.maxy), CENTER.z \ ) /// Returns the turfs on the edge of a square with CENTER in the middle and with the given RADIUS. If used near the edge of the map, will still work fine. // order of the additions: top edge + bottom edge + left edge + right edge #define RANGE_EDGE_TURFS(RADIUS, CENTER)\ - (CENTER.y + RADIUS < world.maxy ? block(locate(max(CENTER.x - RADIUS, 1), min(CENTER.y + RADIUS, world.maxy), CENTER.z), locate(min(CENTER.x + RADIUS, world.maxx), min(CENTER.y + RADIUS, world.maxy), CENTER.z)) : list()) +\ - (CENTER.y - RADIUS > 1 ? block(locate(max(CENTER.x - RADIUS, 1), max(CENTER.y - RADIUS, 1), CENTER.z), locate(min(CENTER.x + RADIUS, world.maxx), max(CENTER.y - RADIUS, 1), CENTER.z)) : list()) +\ - (CENTER.x - RADIUS > 1 ? block(locate(max(CENTER.x - RADIUS, 1), min(CENTER.y + RADIUS - 1, world.maxy), CENTER.z), locate(max(CENTER.x - RADIUS, 1), max(CENTER.y - RADIUS + 1, 1), CENTER.z)) : list()) +\ - (CENTER.x + RADIUS < world.maxx ? block(locate(min(CENTER.x + RADIUS, world.maxx), min(CENTER.y + RADIUS - 1, world.maxy), CENTER.z), locate(min(CENTER.x + RADIUS, world.maxx), max(CENTER.y - RADIUS + 1, 1), CENTER.z)) : list()) + (CENTER.y + RADIUS < world.maxy ? block(max(CENTER.x - RADIUS, 1), min(CENTER.y + RADIUS, world.maxy), CENTER.z, min(CENTER.x + RADIUS, world.maxx), min(CENTER.y + RADIUS, world.maxy), CENTER.z) : list()) +\ + (CENTER.y - RADIUS > 1 ? block(max(CENTER.x - RADIUS, 1), max(CENTER.y - RADIUS, 1), CENTER.z, min(CENTER.x + RADIUS, world.maxx), max(CENTER.y - RADIUS, 1), CENTER.z) : list()) +\ + (CENTER.x - RADIUS > 1 ? block(max(CENTER.x - RADIUS, 1), min(CENTER.y + RADIUS - 1, world.maxy), CENTER.z, max(CENTER.x - RADIUS, 1), max(CENTER.y - RADIUS + 1, 1), CENTER.z) : list()) +\ + (CENTER.x + RADIUS < world.maxx ? block(min(CENTER.x + RADIUS, world.maxx), min(CENTER.y + RADIUS - 1, world.maxy), CENTER.z, min(CENTER.x + RADIUS, world.maxx), max(CENTER.y - RADIUS + 1, 1), CENTER.z) : list()) #define FOR_DVIEW(type, range, center, invis_flags) \ diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm index 5022cacc22b..d0af420dc69 100644 --- a/code/__HELPERS/icon_smoothing.dm +++ b/code/__HELPERS/icon_smoothing.dm @@ -290,7 +290,7 @@ //Icon smoothing helpers /proc/smooth_zlevel(var/zlevel, now = FALSE) - var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) + var/list/away_turfs = block(1, 1, zlevel, world.maxx, world.maxy, zlevel) for(var/V in away_turfs) var/turf/T = V if(T.smooth) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 28d04493868..9ac37b0de4a 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -121,7 +121,7 @@ Turf and target are seperate in case you want to teleport some distance from a t var/turf/center = locate((destination.x+xoffset),(destination.y+yoffset),location.z)//So now, find the new center. //Now to find a box from center location and make that our destination. - for(var/turf/T in block(locate(center.x+b1xerror,center.y+b1yerror,location.z), locate(center.x+b2xerror,center.y+b2yerror,location.z) )) + for(var/turf/T in block(center.x+b1xerror,center.y+b1yerror,location.z, center.x+b2xerror,center.y+b2yerror,location.z) ) if(density&&T.density) continue//If density was specified. if(T.x>world.maxx || T.x<1) continue//Don't want them to teleport off the map. if(T.y>world.maxy || T.y<1) continue diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm index f6291333c5f..36612113ab6 100644 --- a/code/controllers/subsystem/air.dm +++ b/code/controllers/subsystem/air.dm @@ -323,7 +323,7 @@ SUBSYSTEM_DEF(air) /datum/controller/subsystem/air/proc/setup_allturfs() - var/list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz)) + var/list/turfs_to_init = block(1, 1, 1, world.maxx, world.maxy, world.maxz) // Clear active turfs - faster than removing every single turf in the world // one-by-one, and Initialize_Atmos only ever adds `src` back in. active_turfs.Cut() diff --git a/code/datums/helper_datums/map_template.dm b/code/datums/helper_datums/map_template.dm index 559edc6784f..3c6e5a2a0d4 100644 --- a/code/datums/helper_datums/map_template.dm +++ b/code/datums/helper_datums/map_template.dm @@ -87,8 +87,7 @@ var/max_x = min_x + width-1 var/max_y = min_y + height-1 - placement = locate(max(min_x,1), max(min_y,1), placement.z) - return block(placement, locate(min(max_x, world.maxx), min(max_y, world.maxy), placement.z)) + return block(max(min_x,1), max(min_y,1), placement.z, min(max_x, world.maxx), min(max_y, world.maxy), placement.z) /datum/map_template/proc/fits_in_map_bounds(turf/T, centered = 0) var/turf/placement = T diff --git a/code/datums/mapgen/LavalandGenerator.dm b/code/datums/mapgen/LavalandGenerator.dm index 64b6fc5608d..fec2ecf9b57 100644 --- a/code/datums/mapgen/LavalandGenerator.dm +++ b/code/datums/mapgen/LavalandGenerator.dm @@ -63,7 +63,7 @@ //time for noise var/node_gen = rustg_cnoise_generate("[initial_basalt_chance]", "[basalt_smoothing_interations]", "[basalt_birth_limit]", "[basalt_death_limit]", "[size_x + 1]", "[size_y + 1]") var/node_gen2 = rustg_cnoise_generate("[initial_granite_chance]", "[granite_smoothing_interations]", "[granite_birth_limit]", "[granite_death_limit]", "[size_x + 1]", "[size_y + 1]") - var/list/changing_turfs = block(locate(picked_turf.x - round(size_x/2),picked_turf.y - round(size_y/2),picked_turf.z),locate(picked_turf.x + round(size_x/2),picked_turf.y + round(size_y/2),picked_turf.z)) + var/list/changing_turfs = block(picked_turf.x - round(size_x/2),picked_turf.y - round(size_y/2),picked_turf.z, picked_turf.x + round(size_x/2),picked_turf.y + round(size_y/2),picked_turf.z) for(var/turf/T in changing_turfs) //shitcode if(!ismineralturf(T)) continue diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 011202abbef..2204ca88480 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -567,11 +567,9 @@ if(is_multi_tile && isturf(destination)) var/list/new_locs = block( destination, - locate( - min(world.maxx, destination.x + ROUND_UP(bound_width / 32)), - min(world.maxy, destination.y + ROUND_UP(bound_height / 32)), - destination.z - ) + min(world.maxx, destination.x + ROUND_UP(bound_width / 32)), + min(world.maxy, destination.y + ROUND_UP(bound_height / 32)), + destination.z ) if(old_area && old_area != destarea) old_area.Exited(src, movement_dir) diff --git a/code/game/gamemodes/blob/blob_report.dm b/code/game/gamemodes/blob/blob_report.dm index 3df9998fbf1..3f32d796a06 100644 --- a/code/game/gamemodes/blob/blob_report.dm +++ b/code/game/gamemodes/blob/blob_report.dm @@ -55,7 +55,7 @@ /datum/station_state/proc/count() - for(var/turf/T in block(locate(1,1,1), locate(world.maxx,world.maxy,1))) + for(var/turf/T in block(1,1,1, world.maxx,world.maxy,1)) if(isfloorturf(T)) if(!(T:burnt)) diff --git a/code/game/gamemodes/blob/powers.dm b/code/game/gamemodes/blob/powers.dm index 13ca24a397c..15528b90000 100644 --- a/code/game/gamemodes/blob/powers.dm +++ b/code/game/gamemodes/blob/powers.dm @@ -369,7 +369,7 @@ /mob/camera/blob/proc/rally_spores(var/turf/T) to_chat(src, "You rally your spores.") - var/list/surrounding_turfs = block(locate(T.x - 1, T.y - 1, T.z), locate(T.x + 1, T.y + 1, T.z)) + var/list/surrounding_turfs = block(T.x - 1, T.y - 1, T.z, T.x + 1, T.y + 1, T.z) if(!surrounding_turfs.len) return diff --git a/code/game/gamemodes/steal_items.dm b/code/game/gamemodes/steal_items.dm index 89836e130b3..bbdab91f317 100644 --- a/code/game/gamemodes/steal_items.dm +++ b/code/game/gamemodes/steal_items.dm @@ -39,7 +39,7 @@ GLOBAL_LIST_INIT(ungibbable_items_types, get_ungibbable_items_types()) . = list() var/list/stations_z = levels_by_trait(STATION_LEVEL) - var/list/station_turfs = block(locate(1, 1, stations_z[1]), locate(world.maxx, world.maxy, stations_z[length(stations_z)])) + var/list/station_turfs = block(1, 1, stations_z[1], world.maxx, world.maxy, stations_z[length(stations_z)]) for(var/turf/turf_check in station_turfs) if(ispath(typepath, /mob/living)) diff --git a/code/game/turfs/simulated/river.dm b/code/game/turfs/simulated/river.dm index ec9bee3232e..670e06cccf2 100644 --- a/code/game/turfs/simulated/river.dm +++ b/code/game/turfs/simulated/river.dm @@ -44,7 +44,7 @@ /datum/river_spawner/proc/generate(nodes = 4, min_x = RIVER_MIN_X, min_y = RIVER_MIN_Y, max_x = RIVER_MAX_X, max_y = RIVER_MAX_Y) var/list/river_nodes = list() var/num_spawned = 0 - var/list/possible_locs = block(locate(min_x, min_y, target_z), locate(max_x, max_y, target_z)) + var/list/possible_locs = block(min_x, min_y, target_z, max_x, max_y, target_z) while(num_spawned < nodes && possible_locs.len) var/turf/T = pick(possible_locs) var/area/A = get_area(T) diff --git a/code/modules/awaymissions/maploader/reader.dm b/code/modules/awaymissions/maploader/reader.dm index bd2f76952e1..c6935a335ee 100644 --- a/code/modules/awaymissions/maploader/reader.dm +++ b/code/modules/awaymissions/maploader/reader.dm @@ -159,7 +159,7 @@ GLOBAL_DATUM_INIT(_preloader, /datum/dmm_suite/preloader, new()) CRASH("Bad Map bounds in [fname], Min x: [bounds[MAP_MINX]], Min y: [bounds[MAP_MINY]], Min z: [bounds[MAP_MINZ]], Max x: [bounds[MAP_MAXX]], Max y: [bounds[MAP_MAXY]], Max z: [bounds[MAP_MAXZ]]") else if(!measureOnly) - for(var/t in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]), locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))) + for(var/t in block(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ], bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])) var/turf/T = t // we do this after we load everything in. if we don't; we'll have weird atmos bugs regarding atmos adjacent turfs T.AfterChange(TRUE, keep_cabling = TRUE) diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index e6a94de79e0..083451d4407 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -3,7 +3,7 @@ GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "config/away /proc/empty_rect(low_x,low_y, hi_x,hi_y, z) var/timer = start_watch() log_debug("Emptying region: ([low_x], [low_y]) to ([hi_x], [hi_y]) on z '[z]'") - empty_region(block(locate(low_x, low_y, z), locate(hi_x, hi_y, z))) + empty_region(block(low_x, low_y, z, hi_x, hi_y, z)) log_debug("Took [stop_watch(timer)]s") diff --git a/code/modules/events/wormholes.dm b/code/modules/events/wormholes.dm index 4395649dbba..8c25aefacec 100644 --- a/code/modules/events/wormholes.dm +++ b/code/modules/events/wormholes.dm @@ -18,7 +18,7 @@ if(!length(stations_z)) return - var/list/station_turfs = block(locate(1, 1, stations_z[1]), locate(world.maxx, world.maxy, stations_z[length(stations_z)])) + var/list/station_turfs = block(1, 1, stations_z[1], world.maxx, world.maxy, stations_z[length(stations_z)]) for(var/turf/simulated/floor/new_turf in station_turfs) pick_turfs |= new_turf diff --git a/code/modules/mob/living/silicon/ai/freelook/chunk.dm b/code/modules/mob/living/silicon/ai/freelook/chunk.dm index ba05d91125c..2ed6dd7d122 100644 --- a/code/modules/mob/living/silicon/ai/freelook/chunk.dm +++ b/code/modules/mob/living/silicon/ai/freelook/chunk.dm @@ -146,7 +146,7 @@ cameras["[z_level]"] = local_cameras var/image/mirror_from = GLOB.cameranet.obscured_images[GET_Z_PLANE_OFFSET(z_level) + 1] - for(var/turf/lad as anything in block(locate(max(x, 1), max(y, 1), z_level), locate(min(x + CHUNK_SIZE - 1, world.maxx), min(y + CHUNK_SIZE - 1, world.maxy), z_level))) + for(var/turf/lad as anything in block(max(x, 1), max(y, 1), z_level, min(x + CHUNK_SIZE - 1, world.maxx), min(y + CHUNK_SIZE - 1, world.maxy), z_level)) var/image/our_image = new /image(mirror_from) our_image.loc = lad turfs[lad] = our_image diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 9779d4a9fbc..3e97fa02493 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -163,7 +163,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne /obj/machinery/gravity_generator/main/proc/setup_parts() var/turf/our_turf = get_turf(src) // 9x9 block obtained from the bottom middle of the block - var/list/spawn_turfs = block(locate(our_turf.x - 1, our_turf.y + 2, our_turf.z), locate(our_turf.x + 1, our_turf.y, our_turf.z)) + var/list/spawn_turfs = block(our_turf.x - 1, our_turf.y + 2, our_turf.z, our_turf.x + 1, our_turf.y, our_turf.z) var/count = 10 for(var/turf/part_turf as anything in spawn_turfs) count-- diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 6e5c0454fa7..4863940d909 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -83,9 +83,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) //returns turfs within our projected rectangle in a specific order. //this ensures that turfs are copied over in the same order, regardless of any rotation @@ -133,9 +131,7 @@ /obj/docking_port/proc/highlight(_color) SET_PLANE_IMPLICIT(src, GHOST_PLANE) 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 in block(L[1], L[2], z, L[3], L[4], z)) T.color = _color T.maptext = null if(_color) diff --git a/code/modules/space_management/space_level.dm b/code/modules/space_management/space_level.dm index 6bb7aae2184..2e8d7575966 100644 --- a/code/modules/space_management/space_level.dm +++ b/code/modules/space_management/space_level.dm @@ -42,19 +42,19 @@ /datum/space_level/proc/build_space_destination_arrays() // We skip `add_to_transit` here because we want to skip the checks in order to save time // Bottom border - for(var/turf/space/S in block(locate(1,1,zpos),locate(world.maxx,TRANSITION_BORDER_SOUTH,zpos))) + for(var/turf/space/S in block(1,1,zpos, world.maxx,TRANSITION_BORDER_SOUTH,zpos)) transit_south |= S // Top border - for(var/turf/space/S in block(locate(1,world.maxy,zpos),locate(world.maxx,TRANSITION_BORDER_NORTH,zpos))) + for(var/turf/space/S in block(1,world.maxy,zpos, world.maxx,TRANSITION_BORDER_NORTH,zpos)) transit_north |= S // Left border - for(var/turf/space/S in block(locate(1,TRANSITION_BORDER_SOUTH + 1,zpos),locate(TRANSITION_BORDER_WEST,TRANSITION_BORDER_NORTH - 1,zpos))) + for(var/turf/space/S in block(1,TRANSITION_BORDER_SOUTH + 1,zpos, TRANSITION_BORDER_WEST,TRANSITION_BORDER_NORTH - 1,zpos)) transit_west |= S // Right border - for(var/turf/space/S in block(locate(TRANSITION_BORDER_EAST,TRANSITION_BORDER_SOUTH + 1,zpos),locate(world.maxx,TRANSITION_BORDER_NORTH - 1,zpos))) + for(var/turf/space/S in block(TRANSITION_BORDER_EAST,TRANSITION_BORDER_SOUTH + 1,zpos, world.maxx,TRANSITION_BORDER_NORTH - 1,zpos)) transit_east |= S /datum/space_level/proc/add_to_transit(turf/space/S) @@ -118,7 +118,7 @@ /datum/space_level/proc/get_turfs() - return block(locate(1, 1, zpos), locate(world.maxx, world.maxy, zpos)) + return block(1, 1, zpos, world.maxx, world.maxy, zpos) /datum/space_level/proc/set_linkage(transition_type) if(linkage == transition_type) diff --git a/code/modules/station_goals/bsa.dm b/code/modules/station_goals/bsa.dm index 4e551bb740a..1bfea57adff 100644 --- a/code/modules/station_goals/bsa.dm +++ b/code/modules/station_goals/bsa.dm @@ -118,7 +118,7 @@ x_min = x + BSA_SIZE_BACK x_max = x - BSA_SIZE_FRONT - for(var/turf/T in block(locate(x_min,y-1,z),locate(x_max,y+1,z))) + for(var/turf/T in block(x_min,y-1,z, x_max,y+1,z)) if(T.density || isspaceturf(T)) return FALSE return TRUE diff --git a/code/modules/unit_tests/test_runner.dm b/code/modules/unit_tests/test_runner.dm index 47dac9e79bf..712bccbcf44 100644 --- a/code/modules/unit_tests/test_runner.dm +++ b/code/modules/unit_tests/test_runner.dm @@ -29,7 +29,7 @@ test_logs[I] = list() durations[I] = 0 - for(var/turf/T in block(locate(1, 1, z_level), locate(world.maxx, world.maxy, z_level))) + for(var/turf/T in block(1, 1, z_level, world.maxx, world.maxy, z_level)) for(var/datum/map_per_tile_test/test in tests) if(test.failure_count < MAX_MAP_TEST_FAILURE_COUNT) var/duration = REALTIMEOFDAY