From 260e2da382fe5c4fcafda67995400d61f662d768 Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Wed, 5 Jul 2023 17:31:27 -0700 Subject: [PATCH] Macros multi-z code, removes the false premise of manual offsets (#76248) [Removes the pretense of relative multiz levels](https://github.com/tgstation/tgstation/pull/76248/commits/0293fdc2bd8c8af7a0d18da33265e060789c71f7) Our multiz system does not support having a z level that is only connected one way, or which goes down backwards or anything like that. That's a fiction of the trait system, the actual backend has never really supported this. This pr removes the assumptions we were making backend around this, and uses that to save cpu time. I am also converting multiz_levels from an assoc list to a pure one, which saves significantly on access times and cleans up the code somewhat. Also I'm making the get_below/get_above procs into macros, for the sake of cpu time. [Converts the starlight disease to use BYOND's directional defines instead of our own](https://github.com/tgstation/tgstation/commit/7d698f02d991eb4e1bde56314c657cf6e48ceb5d) To some extent spurred on by https://github.com/DaedalusDock/daedalusdock/pull/298, tho it was known before Faster multiz code, faster init, etc etc etc --- _maps/icebox.json | 8 ++-- _maps/multiz_debug.json | 8 ++-- _maps/northstar.json | 12 ++--- _maps/tramstation.json | 4 +- code/__DEFINES/mapping.dm | 6 +++ code/__DEFINES/maps.dm | 2 +- code/controllers/subsystem/mapping.dm | 45 ++++++++++--------- code/datums/diseases/advance/symptoms/heal.dm | 12 ++--- code/game/machinery/camera/camera.dm | 8 ++-- .../effects/decals/cleanable/aliens.dm | 5 +-- .../effects/decals/cleanable/humans.dm | 5 +-- .../effects/decals/cleanable/robots.dm | 5 +-- code/game/objects/effects/decals/decal.dm | 5 ++- .../objects/effects/spawners/random/random.dm | 5 ++- code/game/objects/structures/ladders.dm | 4 +- code/game/sound.dm | 4 +- code/game/turfs/open/chasm.dm | 4 ++ code/game/turfs/open/lava.dm | 8 ++-- code/game/turfs/open/space/space.dm | 13 +++--- code/game/turfs/turf.dm | 8 ++-- .../environmental/LINDA_system.dm | 4 +- .../atmospherics/machinery/pipes/multiz.dm | 4 +- code/modules/mapping/ruins.dm | 4 +- .../space_management/multiz_helpers.dm | 14 +++--- .../mapping/space_management/traits.dm | 19 -------- code/modules/mob/living/blood.dm | 2 + code/modules/mob/mob_movement.dm | 4 +- code/modules/photography/camera/camera.dm | 2 +- code/modules/power/multiz.dm | 8 ++-- tgstation.dme | 1 + 30 files changed, 113 insertions(+), 120 deletions(-) create mode 100644 code/__DEFINES/mapping.dm diff --git a/_maps/icebox.json b/_maps/icebox.json index 2e1be3eaad38..22376fda369b 100644 --- a/_maps/icebox.json +++ b/_maps/icebox.json @@ -17,7 +17,7 @@ ], "traits": [ { - "Up": 1, + "Up": true, "Mining": true, "Linkage": null, "Gravity": true, @@ -27,8 +27,8 @@ "No Parallax": true }, { - "Down": -1, - "Up": 1, + "Down": true, + "Up": true, "Mining": true, "Linkage": null, "Gravity": true, @@ -38,7 +38,7 @@ "No Parallax": true }, { - "Down": -1, + "Down": true, "Mining": true, "Linkage": null, "Gravity": true, diff --git a/_maps/multiz_debug.json b/_maps/multiz_debug.json index eaa71b7e2208..b380a2b7fd0a 100644 --- a/_maps/multiz_debug.json +++ b/_maps/multiz_debug.json @@ -5,17 +5,17 @@ "map_file": "multiz.dmm", "traits": [ { - "Up": 1, + "Up": true, "Linkage": "Cross" }, { - "Up": 1, - "Down": -1, + "Up": true, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" }, { - "Down": -1, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" } diff --git a/_maps/northstar.json b/_maps/northstar.json index c4b6915c646d..0dc25fd0df2f 100644 --- a/_maps/northstar.json +++ b/_maps/northstar.json @@ -14,23 +14,23 @@ "space_empty_levels": 2, "traits": [ { - "Up": 1, + "Up": true, "Linkage": "Cross" }, { - "Up": 1, - "Down": -1, + "Up": true, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" }, { - "Up": 1, - "Down": -1, + "Up": true, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" }, { - "Down": -1, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" } diff --git a/_maps/tramstation.json b/_maps/tramstation.json index d580a7b832a2..4968e18e41b6 100644 --- a/_maps/tramstation.json +++ b/_maps/tramstation.json @@ -11,12 +11,12 @@ }, "traits": [ { - "Up": 1, + "Up": true, "Baseturf": "/turf/open/misc/asteroid/airless", "Linkage": "Cross" }, { - "Down": -1, + "Down": true, "Baseturf": "/turf/open/openspace", "Linkage": "Cross" } diff --git a/code/__DEFINES/mapping.dm b/code/__DEFINES/mapping.dm new file mode 100644 index 000000000000..3c08679e2a4b --- /dev/null +++ b/code/__DEFINES/mapping.dm @@ -0,0 +1,6 @@ +// Defines for SSmapping's multiz_levels +/// TRUE if we're ok with going up +#define Z_LEVEL_UP 1 +/// TRUE if we're ok with going down +#define Z_LEVEL_DOWN 2 +#define LARGEST_Z_LEVEL_INDEX Z_LEVEL_DOWN diff --git a/code/__DEFINES/maps.dm b/code/__DEFINES/maps.dm index c74d0b739fc2..322eb40fd6d1 100644 --- a/code/__DEFINES/maps.dm +++ b/code/__DEFINES/maps.dm @@ -104,7 +104,7 @@ Always compile, always use that verb, and always make sure that it works for wha // number - default gravity if there's no gravity generators or area overrides present #define ZTRAIT_GRAVITY "Gravity" -// numeric offsets - e.g. {"Down": -1} means that chasms will fall to z - 1 rather than oblivion +// Whether this z level is linked up/down. Bool. #define ZTRAIT_UP "Up" #define ZTRAIT_DOWN "Down" diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 63df16973218..6a8e28331cfc 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -217,13 +217,13 @@ SUBSYSTEM_DEF(mapping) if(multiz_levels.len < z_level) multiz_levels.len = z_level - var/linked_down = level_trait(z_level, ZTRAIT_DOWN) - var/linked_up = level_trait(z_level, ZTRAIT_UP) - multiz_levels[z_level] = list() - if(linked_down) - multiz_levels[z_level]["[DOWN]"] = TRUE - if(linked_up) - multiz_levels[z_level]["[UP]"] = TRUE + var/z_above = level_trait(z_level, ZTRAIT_UP) + var/z_below = level_trait(z_level, ZTRAIT_DOWN) + if(!(z_above == TRUE || z_above == FALSE || z_above == null) || !(z_below == TRUE || z_below == FALSE || z_below == null)) + stack_trace("Warning, numeric mapping offsets are deprecated. Instead, mark z level connections by setting UP/DOWN to true if the connection is allowed") + multiz_levels[z_level] = new /list(LARGEST_Z_LEVEL_INDEX) + multiz_levels[z_level][Z_LEVEL_UP] = !!z_above + multiz_levels[z_level][Z_LEVEL_DOWN] = !!z_below /datum/controller/subsystem/mapping/proc/calculate_z_level_gravity(z_level_number) if(!isnum(z_level_number) || z_level_number < 1) @@ -970,24 +970,25 @@ GLOBAL_LIST_EMPTY(the_station_areas) /datum/controller/subsystem/mapping/proc/update_plane_tracking(datum/space_level/update_with) // We're essentially going to walk down the stack of connected z levels, and set their plane offset as we go - // Yes this will cause infinite loops if our templating is fucked. Fuck off - var/below_offset = 0 - // I'm sorry, it needs to start at 0 - var/current_level = -1 - var/current_z = update_with.z_value + var/plane_offset = 0 + var/datum/space_level/current_z = update_with var/list/datum/space_level/levels_checked = list() - do - current_level += 1 - current_z += below_offset - z_level_to_plane_offset[current_z] = current_level - var/datum/space_level/next_level = z_list[current_z] - below_offset = next_level.traits[ZTRAIT_DOWN] - levels_checked += next_level - while(below_offset) + var/list/z_stack = list() + while(TRUE) + var/z_level = current_z.z_value + z_stack += z_level + z_level_to_plane_offset[z_level] = plane_offset + levels_checked += current_z + if(!current_z.traits[ZTRAIT_DOWN]) // If there's nothing below, stop looking + break + // Otherwise, down down down we go + current_z = z_list[z_level - 1] + plane_offset += 1 /// Updates the lowest offset value for(var/datum/space_level/level_to_update in levels_checked) - z_level_to_lowest_plane_offset[level_to_update.z_value] = current_level + z_level_to_lowest_plane_offset[level_to_update.z_value] = plane_offset + z_level_to_stack[level_to_update.z_value] = z_stack // This can be affected by offsets, so we need to update it // PAIN @@ -995,7 +996,7 @@ GLOBAL_LIST_EMPTY(the_station_areas) generate_lighting_appearance_by_z(i) var/old_max = max_plane_offset - max_plane_offset = max(max_plane_offset, current_level) + max_plane_offset = max(max_plane_offset, plane_offset) if(max_plane_offset == old_max) return diff --git a/code/datums/diseases/advance/symptoms/heal.dm b/code/datums/diseases/advance/symptoms/heal.dm index 37a8d5d271cb..0e67a43b7137 100644 --- a/code/datums/diseases/advance/symptoms/heal.dm +++ b/code/datums/diseases/advance/symptoms/heal.dm @@ -76,7 +76,7 @@ /datum/symptom/heal/starlight/proc/CanTileHealDirectional(turf/turf_to_check, direction) if(direction == UP) - turf_to_check = GET_TURF_ABOVE(turf_to_check) + turf_to_check = turf_to_check.above() if(!turf_to_check) return STARLIGHT_CANNOT_HEAL var/area/area_to_check = get_area(turf_to_check) @@ -86,7 +86,7 @@ // while space covers normal space and those caused by explosions, // if there is a floor tile when checking above, that means // a roof exists so the outdoors should only work downwards - if(isspaceturf(turf_to_check) || (area_to_check.outdoors && direction == ZTRAIT_DOWN)) + if(isspaceturf(turf_to_check) || (area_to_check.outdoors && direction == DOWN)) if (levels_of_glass) return STARLIGHT_CAN_HEAL_WITH_PENALTY // Glass gives a penalty. return STARLIGHT_CAN_HEAL // No glass = can heal fully. @@ -99,7 +99,7 @@ if(istransparentturf(turf_to_check) || istype(turf_to_check, /turf/open/openspace)) // Check above or below us if(direction == UP) - turf_to_check = GET_TURF_ABOVE(turf_to_check) + turf_to_check = turf_to_check.above() else turf_to_check = GET_TURF_BELOW(turf_to_check) @@ -114,7 +114,7 @@ // Checking below, we assume that space is below us (as we're standing on station) // Checking above, we check that the area is "outdoors" before assuming if it is space or not. else - if(direction == ZTRAIT_DOWN || (direction == ZTRAIT_UP && area_to_check.outdoors)) + if(direction == DOWN || (direction == UP && area_to_check.outdoors)) if (levels_of_glass) return STARLIGHT_CAN_HEAL_WITH_PENALTY return STARLIGHT_CAN_HEAL @@ -122,12 +122,12 @@ return STARLIGHT_CANNOT_HEAL // Hit a non-space, Non-transparent turf - no healsies /datum/symptom/heal/starlight/proc/CanTileHeal(turf/original_turf, satisfied_with_penalty) - var/current_heal_level = CanTileHealDirectional(original_turf, ZTRAIT_DOWN) + var/current_heal_level = CanTileHealDirectional(original_turf, DOWN) if(current_heal_level == STARLIGHT_CAN_HEAL) return current_heal_level if(current_heal_level && satisfied_with_penalty) // do not care if there is a healing penalty or no return current_heal_level - var/heal_level_from_above = CanTileHealDirectional(original_turf, ZTRAIT_UP) + var/heal_level_from_above = CanTileHealDirectional(original_turf, UP) if(heal_level_from_above > current_heal_level) return heal_level_from_above else diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index b586cb2b28bb..da76024b3d12 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -536,6 +536,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/camera/xray, 0) /obj/machinery/camera/proc/can_see() var/list/see = null var/turf/pos = get_turf(src) + var/turf/directly_above = GET_TURF_ABOVE(pos) var/check_lower = pos != get_lowest_turf(pos) var/check_higher = pos != get_highest_turf(pos) @@ -545,23 +546,22 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/camera/xray, 0) see = get_hear(view_range, pos) if(check_lower || check_higher) // Haha datum var access KILL ME - var/datum/controller/subsystem/mapping/local_mapping = SSmapping for(var/turf/seen in see) if(check_lower) var/turf/visible = seen while(visible && istransparentturf(visible)) - var/turf/below = local_mapping.get_turf_below(visible) + var/turf/below = GET_TURF_BELOW(visible) for(var/turf/adjacent in range(1, below)) see += adjacent see += adjacent.contents visible = below if(check_higher) - var/turf/above = local_mapping.get_turf_above(seen) + var/turf/above = GET_TURF_ABOVE(seen) while(above && istransparentturf(above)) for(var/turf/adjacent in range(1, above)) see += adjacent see += adjacent.contents - above = local_mapping.get_turf_above(above) + above = GET_TURF_ABOVE(above) return see /obj/machinery/camera/proc/Togglelight(on=0) diff --git a/code/game/objects/effects/decals/cleanable/aliens.dm b/code/game/objects/effects/decals/cleanable/aliens.dm index 6da917e8aab9..dc6af8813476 100644 --- a/code/game/objects/effects/decals/cleanable/aliens.dm +++ b/code/game/objects/effects/decals/cleanable/aliens.dm @@ -40,9 +40,8 @@ return if(mapload) for (var/i in 1 to range) - var/turf/my_turf = get_turf(src) - if(!isgroundlessturf(my_turf) || GET_TURF_BELOW(my_turf)) - new /obj/effect/decal/cleanable/xenoblood/xsplatter(my_turf) + if(!isgroundlessturf(loc) || GET_TURF_BELOW(loc)) + new /obj/effect/decal/cleanable/xenoblood/xsplatter(loc) if (!step_to(src, get_step(src, direction), 0)) break return diff --git a/code/game/objects/effects/decals/cleanable/humans.dm b/code/game/objects/effects/decals/cleanable/humans.dm index 15ad4dbbb5b1..6aa38edd7623 100644 --- a/code/game/objects/effects/decals/cleanable/humans.dm +++ b/code/game/objects/effects/decals/cleanable/humans.dm @@ -159,9 +159,8 @@ return if(mapload) for (var/i in 1 to range) - var/turf/my_turf = get_turf(src) - if(!isgroundlessturf(my_turf) || GET_TURF_BELOW(my_turf)) - new /obj/effect/decal/cleanable/blood/splatter(my_turf) + if(!isgroundlessturf(loc) || GET_TURF_BELOW(loc)) + new /obj/effect/decal/cleanable/blood/splatter(loc) if (!step_to(src, get_step(src, direction), 0)) break return diff --git a/code/game/objects/effects/decals/cleanable/robots.dm b/code/game/objects/effects/decals/cleanable/robots.dm index d3af1e2846b0..049f59a8f1c9 100644 --- a/code/game/objects/effects/decals/cleanable/robots.dm +++ b/code/game/objects/effects/decals/cleanable/robots.dm @@ -25,9 +25,8 @@ return if(mapload) for (var/i in 1 to range) - var/turf/my_turf = get_turf(src) - if(prob(40) && (!isgroundlessturf(my_turf) || GET_TURF_BELOW(my_turf))) - new /obj/effect/decal/cleanable/oil/streak(my_turf) + if(prob(40) && (!isgroundlessturf(loc) || GET_TURF_BELOW(loc))) + new /obj/effect/decal/cleanable/oil/streak(loc) if (!step_to(src, get_step(src, direction), 0)) break return diff --git a/code/game/objects/effects/decals/decal.dm b/code/game/objects/effects/decals/decal.dm index 1f2193e9506c..fa6a178b5944 100644 --- a/code/game/objects/effects/decals/decal.dm +++ b/code/game/objects/effects/decals/decal.dm @@ -18,8 +18,9 @@ if(B && B.loc == loc) qdel(src) -/obj/effect/decal/proc/NeverShouldHaveComeHere(turf/T) - return isclosedturf(T) || isgroundlessturf(T) +///Checks if we are allowed to be in `here_turf`, and returns that result. Subtypes should override this when necessary. +/obj/effect/decal/proc/NeverShouldHaveComeHere(turf/here_turf) + return isclosedturf(here_turf) || (isgroundlessturf(here_turf) && !GET_TURF_BELOW(here_turf)) /obj/effect/decal/ex_act(severity, target) qdel(src) diff --git a/code/game/objects/effects/spawners/random/random.dm b/code/game/objects/effects/spawners/random/random.dm index 423821cf8731..62f8bb7cc42f 100644 --- a/code/game/objects/effects/spawners/random/random.dm +++ b/code/game/objects/effects/spawners/random/random.dm @@ -93,8 +93,9 @@ if(radius >= 0) for(var/turf/turf_in_view in view(radius, get_turf(src))) - if(!turf_in_view.density) - scatter_locations += turf_in_view + if(isclosedturf(turf_in_view) || (isgroundlessturf(turf_in_view) && !GET_TURF_BELOW(turf_in_view))) + continue + scatter_locations += turf_in_view return scatter_locations diff --git a/code/game/objects/structures/ladders.dm b/code/game/objects/structures/ladders.dm index 391280745b26..9b7b5590018e 100644 --- a/code/game/objects/structures/ladders.dm +++ b/code/game/objects/structures/ladders.dm @@ -50,14 +50,14 @@ var/obj/structure/ladder/L if (!down) - L = locate() in SSmapping.get_turf_below(T) + L = locate() in GET_TURF_BELOW(T) if (L) if(crafted == L.crafted) down = L L.up = src // Don't waste effort looping the other way L.update_appearance() if (!up) - L = locate() in SSmapping.get_turf_above(T) + L = locate() in GET_TURF_ABOVE(T) if (L) if(crafted == L.crafted) up = L diff --git a/code/game/sound.dm b/code/game/sound.dm index b0b0be8bcaf4..c495511fb369 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -110,8 +110,8 @@ GLOBAL_LIST_INIT(proxy_sound_channels, list( . = list()//output everything that successfully heard the sound - var/turf/above_turf = SSmapping.get_turf_above(turf_source) - var/turf/below_turf = SSmapping.get_turf_below(turf_source) + var/turf/above_turf = GET_TURF_ABOVE(turf_source) + var/turf/below_turf = GET_TURF_BELOW(turf_source) if(ignore_walls) diff --git a/code/game/turfs/open/chasm.dm b/code/game/turfs/open/chasm.dm index b78afdf4eb85..8d5a169b9891 100644 --- a/code/game/turfs/open/chasm.dm +++ b/code/game/turfs/open/chasm.dm @@ -75,6 +75,10 @@ else if(istype(C, /obj/item/stack/tile/iron)) build_with_floor_tiles(C, user) +/// Handles adding the chasm component to the turf (So stuff falls into it!) +/turf/open/chasm/proc/apply_components() + AddComponent(/datum/component/chasm, GET_TURF_BELOW(src)) + // Chasms for Lavaland, with planetary atmos and lava glow /turf/open/chasm/lavaland initial_gas_mix = LAVALAND_DEFAULT_ATMOS diff --git a/code/game/turfs/open/lava.dm b/code/game/turfs/open/lava.dm index 1c87ad7d5bb8..26a425ed0e56 100644 --- a/code/game/turfs/open/lava.dm +++ b/code/game/turfs/open/lava.dm @@ -70,10 +70,10 @@ var/border_turf = FALSE var/list/turfs_to_check = RANGE_TURFS(1, src) if(GET_LOWEST_STACK_OFFSET(z)) - var/turf/above = SSmapping.get_turf_above(src) + var/turf/above = GET_TURF_ABOVE(src) if(above) turfs_to_check += RANGE_TURFS(1, above) - var/turf/below = SSmapping.get_turf_below(src) + var/turf/below = GET_TURF_BELOW(src) if(below) turfs_to_check += RANGE_TURFS(1, below) @@ -95,10 +95,10 @@ // We have gone from a lava turf to a non lava turf, time to let them know var/list/turfs_to_check = RANGE_TURFS(1, result) if(GET_LOWEST_STACK_OFFSET(z)) - var/turf/above = SSmapping.get_turf_above(result) + var/turf/above = GET_TURF_ABOVE(result) if(above) turfs_to_check += RANGE_TURFS(1, above) - var/turf/below = SSmapping.get_turf_below(result) + var/turf/below = GET_TURF_BELOW(result) if(below) turfs_to_check += RANGE_TURFS(1, below) for(var/turf/open/lava/inform in turfs_to_check) diff --git a/code/game/turfs/open/space/space.dm b/code/game/turfs/open/space/space.dm index 3c8e3060c1fd..f485743a93e5 100644 --- a/code/game/turfs/open/space/space.dm +++ b/code/game/turfs/open/space/space.dm @@ -77,10 +77,10 @@ GLOBAL_VAR_INIT(starlight_color, pick(COLOR_TEAL, COLOR_GREEN, COLOR_CYAN, COLOR SSair.add_to_active(src, TRUE) if(SSmapping.max_plane_offset) - var/turf/T = SSmapping.get_turf_above(src) + var/turf/T = GET_TURF_ABOVE(src) if(T) T.multiz_turf_new(src, DOWN) - T = SSmapping.get_turf_below(src) + T = GET_TURF_BELOW(src) if(T) T.multiz_turf_new(src, UP) @@ -302,10 +302,9 @@ GLOBAL_VAR_INIT(starlight_color, pick(COLOR_TEAL, COLOR_GREEN, COLOR_CYAN, COLOR return FALSE /turf/open/space/openspace/enable_starlight() - var/turf/below = SSmapping.get_turf_below(src) - if(istype(below, /turf/open/space/openspace)) - // Override = TRUE beacuse we could have our starlight updated many times without a failure, which'd trigger this - RegisterSignal(below, COMSIG_TURF_CHANGE, PROC_REF(on_below_change), override = TRUE) + var/turf/below = GET_TURF_BELOW(src) + // Override = TRUE beacuse we could have our starlight updated many times without a failure, which'd trigger this + RegisterSignal(below, COMSIG_TURF_CHANGE, PROC_REF(on_below_change), override = TRUE) if(!isspaceturf(below)) return set_light(2) @@ -315,7 +314,7 @@ GLOBAL_VAR_INIT(starlight_color, pick(COLOR_TEAL, COLOR_GREEN, COLOR_CYAN, COLOR if(.) return // If we're here, the starlight is not to be - var/turf/below = SSmapping.get_turf_below(src) + var/turf/below = GET_TURF_BELOW(src) UnregisterSignal(below, COMSIG_TURF_CHANGE) /turf/open/space/openspace/proc/on_below_change(turf/source, path, list/new_baseturfs, flags, list/post_change_callbacks) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 2bdabf6f9be4..8b0c1dff3323 100755 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -125,10 +125,10 @@ GLOBAL_LIST_EMPTY(station_turfs) if(!SSmapping.plane_offset_blacklist["[plane]"]) plane = plane - (PLANE_RANGE * SSmapping.z_level_to_plane_offset[z]) - var/turf/T = SSmapping.get_turf_above(src) + var/turf/T = GET_TURF_ABOVE(src) if(T) T.multiz_turf_new(src, DOWN) - T = SSmapping.get_turf_below(src) + T = GET_TURF_BELOW(src) if(T) T.multiz_turf_new(src, UP) @@ -182,10 +182,10 @@ GLOBAL_LIST_EMPTY(station_turfs) stack_trace("Incorrect turf deletion") changing_turf = FALSE if(GET_LOWEST_STACK_OFFSET(z)) - var/turf/T = SSmapping.get_turf_above(src) + var/turf/T = GET_TURF_ABOVE(src) if(T) T.multiz_turf_del(src, DOWN) - T = SSmapping.get_turf_below(src) + T = GET_TURF_BELOW(src) if(T) T.multiz_turf_del(src, UP) if(force) diff --git a/code/modules/atmospherics/environmental/LINDA_system.dm b/code/modules/atmospherics/environmental/LINDA_system.dm index b4c84fc11d27..f913f6d34ec7 100644 --- a/code/modules/atmospherics/environmental/LINDA_system.dm +++ b/code/modules/atmospherics/environmental/LINDA_system.dm @@ -75,10 +75,10 @@ // Multiz is shitcode welcome home var/turf/current_turf = (direction & (UP|DOWN)) ? \ (direction & UP) ? \ - (z_traits["16"]) ? \ + (z_traits[Z_LEVEL_UP]) ? \ (get_step(locate(x, y, z + 1), NONE)) : \ (null) : \ - (z_traits["32"]) ? \ + (z_traits[Z_LEVEL_DOWN]) ? \ (get_step(locate(x, y, z - 1), NONE)) : \ (null) : \ (get_step(src, direction)) diff --git a/code/modules/atmospherics/machinery/pipes/multiz.dm b/code/modules/atmospherics/machinery/pipes/multiz.dm index a756166e1514..8416421a4ea2 100644 --- a/code/modules/atmospherics/machinery/pipes/multiz.dm +++ b/code/modules/atmospherics/machinery/pipes/multiz.dm @@ -49,12 +49,12 @@ ///Attempts to locate a multiz pipe that's above us, if it finds one it merges us into its pipenet /obj/machinery/atmospherics/pipe/multiz/pipeline_expansion() var/turf/local_turf = get_turf(src) - for(var/obj/machinery/atmospherics/pipe/multiz/above in SSmapping.get_turf_above(local_turf)) + for(var/obj/machinery/atmospherics/pipe/multiz/above in GET_TURF_ABOVE(local_turf)) if(!is_connectable(above, piping_layer)) continue nodes += above above.nodes += src //Two way travel :) - for(var/obj/machinery/atmospherics/pipe/multiz/below in SSmapping.get_turf_below(local_turf)) + for(var/obj/machinery/atmospherics/pipe/multiz/below in GET_TURF_BELOW(local_turf)) if(!is_connectable(below, piping_layer)) continue below.pipeline_expansion() //If we've got one below us, force it to add us on facebook diff --git a/code/modules/mapping/ruins.dm b/code/modules/mapping/ruins.dm index d916c31c9593..a7b9480a34e4 100644 --- a/code/modules/mapping/ruins.dm +++ b/code/modules/mapping/ruins.dm @@ -133,7 +133,7 @@ for(var/v in current_pick.always_spawn_with) if(current_pick.always_spawn_with[v] == PLACE_BELOW) var/turf/T = locate(1,1,target_z) - if(!SSmapping.get_turf_below(T)) + if(!GET_TURF_BELOW(T)) if(forced_z) continue outer else @@ -183,7 +183,7 @@ if(PLACE_DEFAULT) forced_ruins[linked] = -1 if(PLACE_BELOW) - forced_ruins[linked] = SSmapping.get_turf_below(placed_turf) + forced_ruins[linked] = GET_TURF_BELOW(placed_turf) if(PLACE_ISOLATED) forced_ruins[linked] = SSmapping.get_isolated_ruin_z() diff --git a/code/modules/mapping/space_management/multiz_helpers.dm b/code/modules/mapping/space_management/multiz_helpers.dm index 39617af8dc15..0c515d00d166 100644 --- a/code/modules/mapping/space_management/multiz_helpers.dm +++ b/code/modules/mapping/space_management/multiz_helpers.dm @@ -2,10 +2,10 @@ var/turf/us = get_turf(ref) if(dir & UP) dir &= ~UP - return get_step(GET_TURF_ABOVE(us), dir) + return get_step(GET_TURF_ABOVE(get_turf(ref)), dir) if(dir & DOWN) dir &= ~DOWN - return get_step(GET_TURF_BELOW(us), dir) + return get_step(GET_TURF_BELOW(get_turf(ref)), dir) return get_step(ref, dir) /proc/get_dir_multiz(turf/us, turf/them) @@ -29,24 +29,24 @@ return (dir | get_dir(us, them)) /turf/proc/above() - return get_step_multiz(src, UP) + return GET_TURF_ABOVE(src) /turf/proc/below() - return get_step_multiz(src, DOWN) + return GET_TURF_BELOW(src) /proc/get_lowest_turf(atom/ref) var/turf/us = get_turf(ref) var/next = GET_TURF_BELOW(us) while(next) us = next - next = SSmapping.get_turf_below(us) + next = GET_TURF_BELOW(us) return us // I wish this was lisp /proc/get_highest_turf(atom/ref) var/turf/us = get_turf(ref) - var/turf/next = GET_TURF_ABOVE(us) + var/next = GET_TURF_ABOVE(us) while(next) us = next - next = SSmapping.get_turf_above(us) + next = GET_TURF_ABOVE(us) return us diff --git a/code/modules/mapping/space_management/traits.dm b/code/modules/mapping/space_management/traits.dm index b68e3f77b8a7..9841f85ebd7e 100644 --- a/code/modules/mapping/space_management/traits.dm +++ b/code/modules/mapping/space_management/traits.dm @@ -49,25 +49,6 @@ final_return += level.z_value return final_return -/// Attempt to get the turf below the provided one according to Z traits -/datum/controller/subsystem/mapping/proc/get_turf_below(turf/T) - if (!T || !length(multiz_levels)) - return - var/offset = multiz_levels[T.z]["[DOWN]"] - if (!offset) - return - return locate(T.x, T.y, T.z - offset) - -/// Attempt to get the turf above the provided one according to Z traits -/datum/controller/subsystem/mapping/proc/get_turf_above(turf/T) - if (!T || !length(multiz_levels)) - return - - var/offset = multiz_levels[T.z]["[UP]"] - if (!offset) - return - return locate(T.x, T.y, T.z + offset) - /// Prefer not to use this one too often /datum/controller/subsystem/mapping/proc/get_station_center() var/station_z = levels_by_trait(ZTRAIT_STATION)[1] diff --git a/code/modules/mob/living/blood.dm b/code/modules/mob/living/blood.dm index dc5eefc24cbd..21b337521ff5 100644 --- a/code/modules/mob/living/blood.dm +++ b/code/modules/mob/living/blood.dm @@ -326,6 +326,8 @@ return if(!T) T = get_turf(src) + if(isclosedturf(T) || (isgroundlessturf(T) && !GET_TURF_BELOW(T))) + return var/datum/reagent/blood_type = get_blood_id() var/list/temp_blood_DNA diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index e84ab2604cb0..333eab324d52 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -521,7 +521,7 @@ set category = "IC" var/turf/current_turf = get_turf(src) - var/turf/above_turf = SSmapping.get_turf_above(current_turf) + var/turf/above_turf = GET_TURF_ABOVE(current_turf) var/ventcrawling_flag = HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING) ? ZMOVE_VENTCRAWLING : 0 if(!above_turf) @@ -548,7 +548,7 @@ set category = "IC" var/turf/current_turf = get_turf(src) - var/turf/below_turf = SSmapping.get_turf_below(current_turf) + var/turf/below_turf = GET_TURF_BELOW(current_turf) if(!below_turf) to_chat(src, span_warning("There's nowhere to go in that direction!")) return diff --git a/code/modules/photography/camera/camera.dm b/code/modules/photography/camera/camera.dm index 76470f4e83c5..2003fe122493 100644 --- a/code/modules/photography/camera/camera.dm +++ b/code/modules/photography/camera/camera.dm @@ -193,7 +193,7 @@ 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) + placeholder = GET_TURF_BELOW(placeholder) if(!placeholder) break diff --git a/code/modules/power/multiz.dm b/code/modules/power/multiz.dm index 3c9d9ee5c3ad..b4e91a71c60f 100644 --- a/code/modules/power/multiz.dm +++ b/code/modules/power/multiz.dm @@ -9,11 +9,11 @@ /obj/structure/cable/multilayer/multiz/get_cable_connections(powernetless_only) . = ..() var/turf/T = get_turf(src) - . += locate(/obj/structure/cable/multilayer/multiz) in (SSmapping.get_turf_below(T)) - . += locate(/obj/structure/cable/multilayer/multiz) in (SSmapping.get_turf_above(T)) + . += locate(/obj/structure/cable/multilayer/multiz) in (GET_TURF_BELOW(T)) + . += locate(/obj/structure/cable/multilayer/multiz) in (GET_TURF_ABOVE(T)) /obj/structure/cable/multilayer/multiz/examine(mob/user) . = ..() var/turf/T = get_turf(src) - . += span_notice("[locate(/obj/structure/cable/multilayer/multiz) in (SSmapping.get_turf_below(T)) ? "Detected" : "Undetected"] hub UP.") - . += span_notice("[locate(/obj/structure/cable/multilayer/multiz) in (SSmapping.get_turf_above(T)) ? "Detected" : "Undetected"] hub DOWN.") + . += span_notice("[locate(/obj/structure/cable/multilayer/multiz) in (GET_TURF_BELOW(T)) ? "Detected" : "Undetected"] hub UP.") + . += span_notice("[locate(/obj/structure/cable/multilayer/multiz) in (GET_TURF_ABOVE(T)) ? "Detected" : "Undetected"] hub DOWN.") diff --git a/tgstation.dme b/tgstation.dme index eb929b8b29a2..80053c66953a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -143,6 +143,7 @@ #include "code\__DEFINES\machines.dm" #include "code\__DEFINES\magic.dm" #include "code\__DEFINES\map_switch.dm" +#include "code\__DEFINES\mapping.dm" #include "code\__DEFINES\maps.dm" #include "code\__DEFINES\materials.dm" #include "code\__DEFINES\maths.dm"