Skip to content

Commit

Permalink
bugfix: Multi-Z Patch(grav, cable, shuttle, tcomms) (ss220-space#4862)
Browse files Browse the repository at this point in the history
* bugfix: Multi-Z Patch(grav, cable, shuttle, tcomms)

* fixes turfs deconstruction on upper levels
  • Loading branch information
BeebBeebBoob authored Apr 12, 2024
1 parent ed79359 commit ee85eef
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 13 deletions.
13 changes: 13 additions & 0 deletions code/__HELPERS/level_check.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@
// For expansion later
/proc/atoms_share_level(atom/A, atom/B)
return A && B && A.z == B.z

/**
* Checks if source_loc and checking_loc is both on the station, or on the same z level.
* This is because the station's several levels aren't considered the same z, so multi-z stations need this special case.
* returns TRUE if connection is valid, FALSE otherwise.
*/
/proc/is_valid_z_level(turf/source_loc, turf/checking_loc)
// if we're both on "station", regardless of multi-z, we'll pass by.
if(is_station_level(source_loc.z) && is_station_level(checking_loc.z))
return TRUE
if(source_loc.z == checking_loc.z)
return TRUE
return FALSE
17 changes: 17 additions & 0 deletions code/game/machinery/tcomms/core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
. = ..()
link_password = GenerateKey()
reachable_zlevels |= loc.z
var/turf/above = GET_TURF_ABOVE(loc)
while(above)
reachable_zlevels |= above.z
above = GET_TURF_ABOVE(above)
var/turf/below = GET_TURF_BELOW(loc)
while(below)
reachable_zlevels |= below.z
below = GET_TURF_BELOW(below)
component_parts += new /obj/item/circuitboard/tcomms/core(null)
if(check_power_on())
active = TRUE
Expand Down Expand Up @@ -121,6 +129,15 @@
reachable_zlevels = list()
// Add itself as a reachable Z-level
reachable_zlevels |= loc.z
// add adjacent zlevels above and below
var/turf/above = GET_TURF_ABOVE(loc)
while(above)
reachable_zlevels |= above.z
above = GET_TURF_ABOVE(above)
var/turf/below = GET_TURF_BELOW(loc)
while(below)
reachable_zlevels |= below.z
below = GET_TURF_BELOW(below)
// Add all the linked relays in
for(var/obj/machinery/tcomms/relay/R in linked_relays)
// Only if the relay is active
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
vis_flags = VIS_INHERIT_ID|VIS_INHERIT_PLANE // Important for interaction with and visualization of openspace.

var/intact = TRUE
var/turf/baseturf = /turf/space
var/turf/baseturf = /turf/baseturf_bottom
/// negative for faster, positive for slower
var/slowdown = 0
/// It's a check that determines if the turf is transparent to reveal the stuff(pipes, safe, cables and e.t.c.) without looking on intact
Expand Down
10 changes: 5 additions & 5 deletions code/modules/power/cable_multiz.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@
return

var/obj/structure/cable/multiz/above = locate(/obj/structure/cable/multiz) in (GET_TURF_ABOVE(our_turf))
if(above)
P_list += above // get that which were connected above
var/obj/structure/cable/multiz/below = locate(/obj/structure/cable/multiz) in (GET_TURF_BELOW(our_turf))
P_list += power_list(loc, src, 0, 0, cable_only = 1)//... and on turf
if(below)
P_list += below // and below...
P_list += power_list(loc, src, 0, 0, cable_only = 1)//... and on turf ourselves

if(P_list.len == 0 && !above && !below)//If we so happened to be alone cable, not connected to anything, including above and below.
powernet.remove_cable(src) // So we gonna just delete ourself
Expand All @@ -118,7 +122,3 @@

// queue it to rebuild
SSmachines.deferred_powernet_rebuilds += O
if(above)
SSmachines.deferred_powernet_rebuilds += above[1]
if(below)
SSmachines.deferred_powernet_rebuilds += below[1]
22 changes: 16 additions & 6 deletions code/modules/power/gravitygenerator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
var/sound/alert_sound = sound('sound/effects/alert.ogg')
for(var/mob/shaked as anything in GLOB.mob_list)
var/turf/mob_turf = get_turf(shaked)
if(!mob_turf || our_turf.z != mob_turf.z)
if(!istype(mob_turf))
continue
if(!is_valid_z_level(our_turf, mob_turf))
continue
if(isliving(shaked))
var/mob/living/living_shaked = shaked
Expand All @@ -453,12 +455,20 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
var/turf/our_turf = get_turf(src)
if(!our_turf)
return
if(!GLOB.gravity_generators["[our_turf.z]"])
GLOB.gravity_generators["[our_turf.z]"] = list()
if(on)
GLOB.gravity_generators["[our_turf.z]"] |= src
var/list/z_list = list()
// Multi-Z, station gravity generator generates gravity on all STATION_LEVEL z-levels.
if(check_level_trait(our_turf.z, STATION_LEVEL))
for(var/z in levels_by_trait(STATION_LEVEL))
z_list += z
else
GLOB.gravity_generators["[our_turf.z]"] -= src
z_list += our_turf.z
for(var/z in z_list)
if(!GLOB.gravity_generators["[z]"])
GLOB.gravity_generators["[z]"] = list()
if(on)
GLOB.gravity_generators["[z]"] |= src
else
GLOB.gravity_generators["[z]"] -= src


// Misc
Expand Down
2 changes: 1 addition & 1 deletion code/modules/shuttle/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
T1.shuttleRotate(rotation)

var/turf/new_ceiling = GET_TURF_ABOVE(T1) // Do it before atmos readjust.
if(new_ceiling)
if(new_ceiling && (isspaceturf(new_ceiling) || isopenspaceturf(new_ceiling))) //Check for open one, not wall
// generate ceiling
new_ceiling.ChangeTurf(/turf/simulated/floor/engine/hull/ceiling)

Expand Down

0 comments on commit ee85eef

Please sign in to comment.