diff --git a/code/__DEFINES/turfs.dm b/code/__DEFINES/turfs.dm index a4fcb170dec..c00dd6adb90 100644 --- a/code/__DEFINES/turfs.dm +++ b/code/__DEFINES/turfs.dm @@ -27,6 +27,22 @@ #define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3])) +/// 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 +#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)))) + +/// Returns an outline (neighboring turfs) of the given block +#define CORNER_OUTLINE(corner, width, height) ( \ + CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, -1) + \ + CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, height) + \ + CORNER_BLOCK_OFFSET(corner, 1, height, -1, 0) + \ + CORNER_BLOCK_OFFSET(corner, 1, height, width, 0)) + +/// Returns a list of around us +#define TURF_NEIGHBORS(turf) CORNER_BLOCK_OFFSET(turf, 2, 2, -1, -1) + /// The pipes, disposals, and wires are hidden #define UNDERFLOOR_HIDDEN 0 /// The pipes, disposals, and wires are visible but cannot be interacted with diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm index 5e0d1b83b27..2ad8e2a4121 100644 --- a/code/__HELPERS/icon_smoothing.dm +++ b/code/__HELPERS/icon_smoothing.dm @@ -416,7 +416,7 @@ DEFINE_BITFIELD(smoothing_junction, list( //Icon smoothing helpers /proc/smooth_zlevel(zlevel, now = FALSE) - var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) + var/list/away_turfs = Z_TURFS(zlevel) for(var/turf/turf_to_smooth as anything in away_turfs) if(turf_to_smooth.smoothing_flags & (SMOOTH_CORNERS|SMOOTH_BITMASK)) if(now) diff --git a/code/__HELPERS/turfs.dm b/code/__HELPERS/turfs.dm index 4d877a66c3e..e67c439ee7a 100644 --- a/code/__HELPERS/turfs.dm +++ b/code/__HELPERS/turfs.dm @@ -84,7 +84,9 @@ Turf and target are separate 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/current_turf in block(locate(center.x + b1xerror, center.y + b1yerror, location.z), locate(center.x + b2xerror, center.y + b2yerror, location.z))) + var/width = b2xerror - b1xerror + var/height = b2yerror - b1yerror + for(var/turf/current_turf as anything in CORNER_BLOCK_OFFSET(center, width, height, b1xerror, b1yerror)) if(density_check && current_turf.density) continue//If density was specified. if(closed_turf_check && isclosedturf(current_turf)) diff --git a/code/controllers/subsystem/explosions.dm b/code/controllers/subsystem/explosions.dm index a7becb28706..ef14d078fb4 100644 --- a/code/controllers/subsystem/explosions.dm +++ b/code/controllers/subsystem/explosions.dm @@ -590,16 +590,24 @@ SUBSYSTEM_DEF(explosions) var/highest_y = our_y + i // top left to one before top right if(highest_y <= max_y) - outlist += block(locate(max(lowest_x, 1), highest_y, our_z), locate(min(highest_x - 1, max_x), highest_y, our_z)) + outlist += block( + locate(max(lowest_x, 1), highest_y, our_z), + locate(min(highest_x - 1, max_x), highest_y, our_z)) // top right to one before bottom right if(highest_x <= max_x) - outlist += block(locate(highest_x, min(highest_y, max_y), our_z), locate(highest_x, max(lowest_y + 1, 1), our_z)) + outlist += block( + locate(highest_x, min(highest_y, max_y), our_z), + locate(highest_x, max(lowest_y + 1, 1), our_z)) // bottom right to one before bottom left if(lowest_y >= 1) - outlist += block(locate(min(highest_x, max_x), lowest_y, our_z), locate(max(lowest_x + 1, 1), lowest_y, our_z)) + outlist += block( + locate(min(highest_x, max_x), lowest_y, our_z), + locate(max(lowest_x + 1, 1), lowest_y, our_z)) // bottom left to one before top left if(lowest_x >= 1) - outlist += block(locate(lowest_x, max(lowest_y, 1), our_z), locate(lowest_x, min(highest_y - 1, max_y), our_z)) + outlist += block( + locate(lowest_x, max(lowest_y, 1), our_z), + locate(lowest_x, min(highest_y - 1, max_y), our_z)) return outlist diff --git a/code/controllers/subsystem/minor_mapping.dm b/code/controllers/subsystem/minor_mapping.dm index d606986edb1..6f40cc4d41c 100644 --- a/code/controllers/subsystem/minor_mapping.dm +++ b/code/controllers/subsystem/minor_mapping.dm @@ -52,7 +52,7 @@ SUBSYSTEM_DEF(minor_mapping) var/list/all_turfs for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) - all_turfs += block(locate(1,1,z), locate(world.maxx,world.maxy,z)) + all_turfs += Z_TURFS(z) for(var/turf/open/floor/plating/T in all_turfs) if(T.is_blocked_turf()) continue @@ -65,7 +65,7 @@ SUBSYSTEM_DEF(minor_mapping) var/list/suitable = list() for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) - for(var/turf/detected_turf as anything in block(locate(1,1,z), locate(world.maxx,world.maxy,z))) + for(var/turf/detected_turf as anything in Z_TURFS(z)) if(isfloorturf(detected_turf) && detected_turf.underfloor_accessibility == UNDERFLOOR_HIDDEN) suitable += detected_turf diff --git a/code/controllers/subsystem/spatial_gridmap.dm b/code/controllers/subsystem/spatial_gridmap.dm index 9d8bc5356b7..447f1a70701 100644 --- a/code/controllers/subsystem/spatial_gridmap.dm +++ b/code/controllers/subsystem/spatial_gridmap.dm @@ -634,7 +634,7 @@ SUBSYSTEM_DEF(spatial_grid) turfs = GLOB.station_turfs else - turfs = block(locate(1,1,z), locate(world.maxx, world.maxy, z)) + turfs = Z_TURFS(z) for(var/client_to_insert in 0 to insert_clients) var/turf/random_turf = pick(turfs) diff --git a/code/datums/lazy_template.dm b/code/datums/lazy_template.dm index 812ad856485..af6df50e96f 100644 --- a/code/datums/lazy_template.dm +++ b/code/datums/lazy_template.dm @@ -54,8 +54,7 @@ if(!reservation) CRASH("Failed to reserve a block for lazy template: '[key]'") - var/turf/reservation_bottom_left = coords2turf(reservation.bottom_left_coords) - if(!loading.load(reservation_bottom_left)) + if(!loading.load(coords2turf(reservation.bottom_left_coords))) CRASH("Failed to load lazy template: '[key]'") reservations += reservation diff --git a/code/datums/station_integrity.dm b/code/datums/station_integrity.dm index f38434c1fa5..ebd37c9858c 100644 --- a/code/datums/station_integrity.dm +++ b/code/datums/station_integrity.dm @@ -25,7 +25,7 @@ grille = 0 mach = 0 for(var/Z in SSmapping.levels_by_trait(ZTRAIT_STATION)) - for(var/turf/T in block(locate(1,1,Z), locate(world.maxx,world.maxy,Z))) + for(var/turf/T as anything in Z_TURFS(Z)) // don't count shuttles since they may have just left if(istype(T.loc, /area/shuttle)) continue diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 0d04fcab2c4..702212b1bc6 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -158,8 +158,9 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( if(thisarea.lighting_effects) new_turf.add_overlay(thisarea.lighting_effects[SSmapping.z_level_to_plane_offset[z] + 1]) - QUEUE_SMOOTH_NEIGHBORS(src) - QUEUE_SMOOTH(src) + if(flags_1 & INITIALIZED_1) // only queue for smoothing if SSatom initialized us + QUEUE_SMOOTH_NEIGHBORS(src) + QUEUE_SMOOTH(src) return new_turf diff --git a/code/game/turfs/open/river.dm b/code/game/turfs/open/river.dm index 5171d840821..e71488015e0 100644 --- a/code/game/turfs/open/river.dm +++ b/code/game/turfs/open/river.dm @@ -7,7 +7,10 @@ /proc/spawn_rivers(target_z, nodes = 4, turf_type = /turf/open/lava/smooth/lava_land_surface, whitelist_area = /area/lavaland/surface/outdoors/unexplored, min_x = RANDOM_LOWER_X, min_y = RANDOM_LOWER_Y, max_x = RANDOM_UPPER_X, max_y = RANDOM_UPPER_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/width = max_x - min_x + var/height = max_y - min_y + var/turf/corner = locate(min_x, min_y, target_z) + var/list/possible_locs = CORNER_BLOCK(corner, width, height) while(num_spawned < nodes && possible_locs.len) var/turf/T = pick(possible_locs) var/area/A = get_area(T) diff --git a/code/game/world.dm b/code/game/world.dm index 34c653978f0..f550a7513c7 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -369,7 +369,9 @@ GLOBAL_VAR(restart_counter) if(!max_zs_to_load) 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, max_zs_to_load)) + var/list/to_add = block( + locate(old_max + 1, 1, 1), + locate(maxx, maxy, max_zs_to_load)) global_area.contained_turfs += to_add /world/proc/increaseMaxY(new_maxy, max_zs_to_load = maxz) @@ -380,7 +382,9 @@ GLOBAL_VAR(restart_counter) if(!max_zs_to_load) 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, max_zs_to_load)) + var/list/to_add = block( + locate(1, old_maxy + 1, 1), + locate(maxx, maxy, max_zs_to_load)) global_area.contained_turfs += to_add /world/proc/incrementMaxZ() diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 146e152cb42..c8aa474f15d 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -996,10 +996,6 @@ GLOBAL_PROTECT(admin_verbs_poll) if(!check_rights(R_ADMIN)) return - if(SSticker.current_state != GAME_STATE_PLAYING) - to_chat(usr, span_warning("The game hasnt started yet!")) - return - var/list/choices = LAZY_TEMPLATE_KEY_LIST_ALL() var/choice = tgui_input_list(usr, "Key?", "Lazy Loader", choices) if(!choice) diff --git a/code/modules/antagonists/blob/powers.dm b/code/modules/antagonists/blob/powers.dm index 9f211f5c115..765b9314495 100644 --- a/code/modules/antagonists/blob/powers.dm +++ b/code/modules/antagonists/blob/powers.dm @@ -353,7 +353,7 @@ /** Rally spores to a location */ /mob/camera/blob/proc/rally_spores(turf/tile) to_chat(src, "You rally your spores.") - var/list/surrounding_turfs = block(locate(tile.x - 1, tile.y - 1, tile.z), locate(tile.x + 1, tile.y + 1, tile.z)) + var/list/surrounding_turfs = TURF_NEIGHBORS(tile) if(!length(surrounding_turfs)) return FALSE for(var/mob/living/simple_animal/hostile/blob/blobspore/spore as anything in blob_mobs) diff --git a/code/modules/awaymissions/gateway.dm b/code/modules/awaymissions/gateway.dm index 458e874a7a0..74da8555bd7 100644 --- a/code/modules/awaymissions/gateway.dm +++ b/code/modules/awaymissions/gateway.dm @@ -431,7 +431,7 @@ GLOBAL_LIST_EMPTY(gateway_destinations) cam_background.add_filter("portal_blur", 1, list("type" = "blur", "size" = 0.5)) - vis_contents += block(locate(center_turf.x - 1, center_turf.y - 1, center_turf.z), locate(center_turf.x + 1, center_turf.y + 1, center_turf.z)) + vis_contents += TURF_NEIGHBORS(center_turf) cam_background.icon_state = "scanline4" cam_background.color = "#adadff" cam_background.alpha = 128 diff --git a/code/modules/mapping/map_template.dm b/code/modules/mapping/map_template.dm index 359cf932fb0..40bef56bd5e 100644 --- a/code/modules/mapping/map_template.dm +++ b/code/modules/mapping/map_template.dm @@ -157,11 +157,8 @@ if((T.y+height) - 1 > world.maxy) return - var/list/border = block(locate(max(T.x-1, 1), max(T.y-1, 1), T.z), - locate(min(T.x+width+1, world.maxx), min(T.y+height+1, world.maxy), T.z)) - // iterate over turfs in the border and clear them from active atmos processing - for(var/turf/border_turf as anything in border) + for(var/turf/border_turf as anything in CORNER_BLOCK_OFFSET(T, width + 2, height + 2, -1, -1)) SSair.remove_from_active(border_turf) for(var/turf/sub_turf as anything in border_turf.atmos_adjacent_turfs) sub_turf.atmos_adjacent_turfs?.Remove(border_turf) @@ -179,6 +176,7 @@ parsed.turf_blacklist = turf_blacklist if(!parsed.load(T.x, T.y, T.z, cropMap=TRUE, no_changeturf=(SSatoms.initialized == INITIALIZATION_INSSATOMS), placeOnTop=should_place_on_top)) return + var/list/bounds = parsed.bounds if(!bounds) return diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index 77250dcf826..4eb1512191a 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -280,7 +280,10 @@ SSmapping.build_area_turfs(z_index) if(!no_changeturf) - for(var/turf/T as anything in 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( + 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) //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) diff --git a/code/modules/mapping/space_management/space_reservation.dm b/code/modules/mapping/space_management/space_reservation.dm index b6ec8801a7e..bb32d91fbca 100644 --- a/code/modules/mapping/space_management/space_reservation.dm +++ b/code/modules/mapping/space_management/space_reservation.dm @@ -3,11 +3,11 @@ //Yes, I'm sorry. /datum/turf_reservation var/list/reserved_turfs = list() + var/list/cordon_turfs = list() var/width = 0 var/height = 0 var/bottom_left_coords[3] var/top_right_coords[3] - var/wipe_reservation_on_release = TRUE var/turf_type = /turf/open/space /datum/turf_reservation/transit @@ -18,13 +18,47 @@ SSmapping.used_turfs -= reserved_turfs reserved_turfs = list() - for(var/turf/reserved_turf as anything in reserved_copy) + var/list/cordon_copy = cordon_turfs.Copy() + SSmapping.used_turfs -= cordon_turfs + cordon_turfs = list() + + var/release_turfs = reserved_copy + cordon_copy + + for(var/turf/reserved_turf as anything in release_turfs) SEND_SIGNAL(reserved_turf, COMSIG_TURF_RESERVATION_RELEASED, src) // Makes the linter happy, even tho we don't await this - INVOKE_ASYNC(SSmapping, TYPE_PROC_REF(/datum/controller/subsystem/mapping, reserve_turfs), reserved_copy) + INVOKE_ASYNC(SSmapping, TYPE_PROC_REF(/datum/controller/subsystem/mapping, reserve_turfs), release_turfs) + +/// Attempts to calaculate and store a list of turfs around the reservation for cordoning. Returns whether a valid cordon was calculated +/datum/turf_reservation/proc/calculate_cordon_turfs(turf/BL, turf/TR) + if(BL.x < 2 || BL.y < 2 || TR.x > (world.maxx - 2) || TR.y > (world.maxy - 2)) + return FALSE // no space for a cordon here + + var/list/possible_turfs = CORNER_OUTLINE(BL, width, height) + for(var/turf/cordon_turf as anything in possible_turfs) + if(!(cordon_turf.flags_1 & UNUSED_RESERVATION_TURF)) + return FALSE + cordon_turfs = possible_turfs + return TRUE + +/// Actually generates the cordon around the reservation, and marking the cordon turfs as reserved +/datum/turf_reservation/proc/generate_cordon() + for(var/turf/cordon_turf as anything in cordon_turfs) + var/area/misc/cordon/cordon_area = GLOB.areas_by_type[/area/misc/cordon] || new + var/area/old_area = cordon_turf.loc + old_area.turfs_to_uncontain += cordon_turf + cordon_area.contained_turfs += cordon_turf + cordon_area.contents += cordon_turf + cordon_turf.ChangeTurf(/turf/cordon, /turf/cordon) + + cordon_turf.flags_1 &= ~UNUSED_RESERVATION_TURF + SSmapping.unused_turfs["[cordon_turf.z]"] -= cordon_turf + SSmapping.used_turfs[cordon_turf] = src /datum/turf_reservation/proc/Reserve(width, height, zlevel) + src.width = width + src.height = height if(width > world.maxx || height > world.maxy || width < 1 || height < 1) return FALSE var/list/avail = SSmapping.unused_turfs["[zlevel]"] @@ -51,6 +85,8 @@ if(!(checking.flags_1 & UNUSED_RESERVATION_TURF)) passing = FALSE break + if(passing) // found a potentially valid area, now try to calculate its cordon + passing = calculate_cordon_turfs(BL, TR) if(!passing) continue break @@ -65,8 +101,7 @@ SSmapping.unused_turfs["[T.z]"] -= T SSmapping.used_turfs[T] = src T.ChangeTurf(turf_type, turf_type) - src.width = width - src.height = height + generate_cordon() return TRUE /datum/turf_reservation/New() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 7849bf9fd63..8960bf1a306 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1943,8 +1943,7 @@ GLOBAL_LIST_EMPTY(fire_appearances) if(istransparentturf(front_hole)) ceiling = front_hole else - var/list/checkturfs = block(locate(x-1,y-1,ceiling.z),locate(x+1,y+1,ceiling.z))-ceiling-front_hole //Try find hole near of us - for(var/turf/checkhole in checkturfs) + for(var/turf/checkhole in TURF_NEIGHBORS(ceiling)) if(istransparentturf(checkhole)) ceiling = checkhole break @@ -1992,8 +1991,8 @@ GLOBAL_LIST_EMPTY(fire_appearances) floor = front_hole lower_level = get_step_multiz(front_hole, DOWN) else - var/list/checkturfs = block(locate(x-1,y-1,z),locate(x+1,y+1,z))-floor //Try find hole near of us - for(var/turf/checkhole in checkturfs) + // Try to find a hole near us + for(var/turf/checkhole in TURF_NEIGHBORS(floor)) if(istransparentturf(checkhole)) floor = checkhole lower_level = get_step_multiz(checkhole, DOWN) diff --git a/code/modules/mob/living/silicon/ai/freelook/chunk.dm b/code/modules/mob/living/silicon/ai/freelook/chunk.dm index 7d3b192721b..9c3ead65c59 100644 --- a/code/modules/mob/living/silicon/ai/freelook/chunk.dm +++ b/code/modules/mob/living/silicon/ai/freelook/chunk.dm @@ -155,7 +155,8 @@ 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))) + var/turf/chunk_corner = locate(x, y, z_level) + for(var/turf/lad as anything in CORNER_BLOCK(chunk_corner, CHUNK_SIZE - 1, CHUNK_SIZE - 1)) var/image/our_image = new /image(mirror_from) our_image.loc = lad turfs[lad] = our_image diff --git a/code/modules/photography/camera/camera.dm b/code/modules/photography/camera/camera.dm index 2b6cd84fbfa..6c600c7266f 100644 --- a/code/modules/photography/camera/camera.dm +++ b/code/modules/photography/camera/camera.dm @@ -188,25 +188,27 @@ var/list/mobs = list() var/blueprints = FALSE var/clone_area = SSmapping.RequestBlockReservation(size_x * 2 + 1, size_y * 2 + 1) - for(var/turf/placeholder in block(locate(target_turf.x - size_x, target_turf.y - size_y, target_turf.z), locate(target_turf.x + size_x, target_turf.y + size_y, target_turf.z))) - var/turf/T = placeholder - while(istype(T, /turf/open/openspace)) //Multi-z photography - T = SSmapping.get_turf_below(T) - if(!T) + + var/width = size_x * 2 + var/height = size_y * 2 + for(var/turf/placeholder as anything in CORNER_BLOCK_OFFSET(target_turf, width, height, -size_x, -size_y)) + while(istype(placeholder, /turf/open/openspace)) //Multi-z photography + placeholder = SSmapping.get_turf_below(placeholder) + if(!placeholder) break - if(T && ((ai_user && GLOB.cameranet.checkTurfVis(placeholder)) || (placeholder in seen))) - turfs += T - for(var/mob/M in T) + if(placeholder && ((ai_user && GLOB.cameranet.checkTurfVis(placeholder)) || (placeholder in seen))) + turfs += placeholder + for(var/mob/M in placeholder) mobs += M - if(locate(/obj/item/areaeditor/blueprints) in T) + if(locate(/obj/item/areaeditor/blueprints) in placeholder) blueprints = TRUE - for(var/i in mobs) - var/mob/M = i - mobs_spotted += M - if(M.stat == DEAD) - dead_spotted += M - desc += M.get_photo_description(src) + + for(var/mob/mob as anything in mobs) + mobs_spotted += mob + if(mob.stat == DEAD) + dead_spotted += mob + desc += mob.get_photo_description(src) var/psize_x = (size_x * 2 + 1) * world.icon_size var/psize_y = (size_y * 2 + 1) * world.icon_size diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index ab23526dba3..800981581c5 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -170,7 +170,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) /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 = CORNER_BLOCK(our_turf, 3, 3) var/count = 10 for(var/turf/T in spawn_turfs) count-- diff --git a/code/modules/procedural_mapping/mapGenerators/repair.dm b/code/modules/procedural_mapping/mapGenerators/repair.dm index 03234bf78e5..c9df8496389 100644 --- a/code/modules/procedural_mapping/mapGenerators/repair.dm +++ b/code/modules/procedural_mapping/mapGenerators/repair.dm @@ -17,6 +17,8 @@ allowAtomsOnSpace = TRUE /datum/map_generator_module/reload_station_map/generate() + set waitfor = FALSE + if(!istype(mother, /datum/map_generator/repair/reload_station_map)) return var/datum/map_generator/repair/reload_station_map/mother1 = mother @@ -36,18 +38,18 @@ require_area_resort() - for(var/L in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], SSmapping.station_start), - locate(bounds[MAP_MAXX], bounds[MAP_MAXY], z_offset - 1))) - set waitfor = FALSE - var/turf/B = L - atoms += B - for(var/A in B) - atoms += A - if(istype(A,/obj/structure/cable)) - cables += A + var/list/generation_turfs = block( + locate(bounds[MAP_MINX], bounds[MAP_MINY], SSmapping.station_start), + locate(bounds[MAP_MAXX], bounds[MAP_MAXY], z_offset - 1)) + for(var/turf/gen_turf as anything in generation_turfs) + atoms += gen_turf + for(var/atom in gen_turf) + atoms += atom + if(istype(atom, /obj/structure/cable)) + cables += atom continue - if(istype(A,/obj/machinery/atmospherics)) - atmos_machines += A + if(istype(atom, /obj/machinery/atmospherics)) + atmos_machines += atom SSatoms.InitializeAtoms(atoms) SSmachines.setup_template_powernets(cables) diff --git a/code/modules/research/bepis.dm b/code/modules/research/bepis.dm index ffd3a0d74e2..d3e901a48b5 100644 --- a/code/modules/research/bepis.dm +++ b/code/modules/research/bepis.dm @@ -245,7 +245,9 @@ var/gauss_major = 0 var/gauss_minor = 0 var/gauss_real = 0 - var/list/turfs = block(locate(x-1,y-1,z),locate(x+1,y+1,z)) //NO MORE DISCS IN WINDOWS + + var/turf/my_turf = get_turf(src) + var/list/turfs = TURF_NEIGHBORS(my_turf) //NO MORE DISCS IN WINDOWS while(length(turfs)) var/turf/T = pick_n_take(turfs) if(T.is_blocked_turf(TRUE)) @@ -253,6 +255,7 @@ else dropturf = T break + if (!dropturf) dropturf = drop_location() gauss_major = (gaussian(major_threshold, std) - negative_cash_offset) //This is the randomized profit value that this experiment has to surpass to unlock a tech. diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 993c1d43832..adda9d1f90b 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -560,7 +560,9 @@ unregister() destination = null previous = null - QDEL_NULL(assigned_transit) //don't need it where we're goin'! + if(!QDELETED(assigned_transit)) + qdel(assigned_transit, force = TRUE) + assigned_transit = null shuttle_areas = null remove_ripples() return ..() diff --git a/code/modules/station_goals/bsa.dm b/code/modules/station_goals/bsa.dm index f8983a1159b..fd62e95da0a 100644 --- a/code/modules/station_goals/bsa.dm +++ b/code/modules/station_goals/bsa.dm @@ -105,17 +105,18 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE) /obj/machinery/bsa/middle/proc/has_space() var/cannon_dir = get_cannon_direction() - var/x_min - var/x_max + var/width = 10 + var/offset switch(cannon_dir) if(EAST) - x_min = x - 4 //replace with defines later - x_max = x + 6 + offset = -4 if(WEST) - x_min = x + 4 - x_max = x - 6 + offset = -6 + else + return FALSE - for(var/turf/T in block(locate(x_min,y-1,z),locate(x_max,y+1,z))) + var/turf/base = get_turf(src) + for(var/turf/T as anything in CORNER_BLOCK_OFFSET(base, width, 3, offset, -1)) if(T.density || isspaceturf(T)) return FALSE return TRUE diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index 9018f412e0d..0aab091aaa1 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -66,7 +66,7 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests()) /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 in Z_TURFS(run_loc_floor_bottom_left.z)) for (var/content in turf.contents) if (istype(content, /obj/effect/landmark)) continue