Skip to content

Commit

Permalink
Merge pull request #3675 from MistakeNot4892/devupdate
Browse files Browse the repository at this point in the history
Dev update from staging.
  • Loading branch information
MistakeNot4892 authored Feb 11, 2024
2 parents ee88ab1 + 720de38 commit ec54c4c
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 159 deletions.
54 changes: 20 additions & 34 deletions code/__defines/ZAS.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,28 @@
#define TURF_HAS_VALID_ZONE(T) (isturf(T) && T:zone && !T:zone:invalid)
#define SHOULD_PARTICIPATE_IN_ZONES(T) (isturf(T) && T:zone_membership_candidate && (!T:external_atmosphere_participation || !T:is_outside()))

#define ATMOS_CANPASS_MOVABLE(ret, AM, TARG_TURF) \
switch (AM.atmos_canpass) { \
if (CANPASS_ALWAYS) { } \
if (CANPASS_DENSITY) { \
if (AM.density) { \
ret |= AIR_BLOCKED; \
} \
} \
if (CANPASS_PROC) { \
ret |= (AIR_BLOCKED * !AM.CanPass(null, TARG_TURF, 0, 0)) | (ZONE_BLOCKED * !AM.CanPass(null, TARG_TURF, 1.5, 1)); \
} \
if (CANPASS_NEVER) { \
ret = BLOCKED; \
} \
}

#ifdef MULTIZAS

var/global/list/csrfz_check = list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST, NORTHUP, EASTUP, WESTUP, SOUTHUP, NORTHDOWN, EASTDOWN, WESTDOWN, SOUTHDOWN)
var/global/list/gzn_check = list(NORTH, SOUTH, EAST, WEST, UP, DOWN)

#define ATMOS_CANPASS_TURF(ret,A,B) \
#define ATMOS_CANPASS_TURF(ret, A, B) \
if (A.blocks_air & AIR_BLOCKED || B.blocks_air & AIR_BLOCKED) { \
ret = BLOCKED; \
} \
Expand All @@ -64,22 +80,7 @@ var/global/list/gzn_check = list(NORTH, SOUTH, EAST, WEST, UP, DOWN)
ret = 0;\
for (var/thing in A) { \
var/atom/movable/AM = thing; \
switch (AM.atmos_canpass) { \
if (CANPASS_ALWAYS) { \
continue; \
} \
if (CANPASS_DENSITY) { \
if (AM.density) { \
ret |= AIR_BLOCKED; \
} \
} \
if (CANPASS_PROC) { \
ret |= (AIR_BLOCKED * !AM.CanPass(null, B, 0, 0)) | (ZONE_BLOCKED * !AM.CanPass(null, B, 1.5, 1)); \
} \
if (CANPASS_NEVER) { \
ret = BLOCKED; \
} \
} \
ATMOS_CANPASS_MOVABLE(ret, AM, B); \
if (ret == BLOCKED) { \
break;\
}\
Expand All @@ -90,7 +91,7 @@ var/global/list/gzn_check = list(NORTH, SOUTH, EAST, WEST, UP, DOWN)
var/global/list/csrfz_check = list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST)
var/global/list/gzn_check = list(NORTH, SOUTH, EAST, WEST)

#define ATMOS_CANPASS_TURF(ret,A,B) \
#define ATMOS_CANPASS_TURF(ret, A, B) \
if (A.blocks_air & AIR_BLOCKED || B.blocks_air & AIR_BLOCKED) { \
ret = BLOCKED; \
} \
Expand All @@ -101,22 +102,7 @@ var/global/list/gzn_check = list(NORTH, SOUTH, EAST, WEST)
ret = 0;\
for (var/thing in A) { \
var/atom/movable/AM = thing; \
switch (AM.atmos_canpass) { \
if (CANPASS_ALWAYS) { \
continue; \
} \
if (CANPASS_DENSITY) { \
if (AM.density) { \
ret |= AIR_BLOCKED; \
} \
} \
if (CANPASS_PROC) { \
ret |= (AIR_BLOCKED * !AM.CanPass(null, B, 0, 0)) | (ZONE_BLOCKED * !AM.CanPass(null, B, 1.5, 1)); \
} \
if (CANPASS_NEVER) { \
ret = BLOCKED; \
} \
} \
ATMOS_CANPASS_MOVABLE(ret, AM, B); \
if (ret == BLOCKED) { \
break;\
}\
Expand Down
33 changes: 24 additions & 9 deletions code/_helpers/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,31 @@
* Gets the highest and lowest pressures from the tiles in cardinal directions
* around us, then checks the difference.
*/
/proc/getOPressureDifferential(var/turf/loc)
var/minp=16777216;
var/maxp=0;
/proc/get_surrounding_pressure_differential(var/turf/loc, atom/originator)
var/minp = INFINITY
var/maxp = 0
var/has_neighbour = FALSE
var/airblock // zeroed by ATMOS_CANPASS_TURF, declared early as microopt
for(var/dir in global.cardinal)
var/turf/T = get_step(loc,dir)
var/datum/gas_mixture/environment = T.return_air()
var/cp = environment?.return_pressure()
if(cp<minp)minp=cp
if(cp>maxp)maxp=cp
return abs(minp-maxp)
var/turf/neighbour = get_step(loc,dir)
if(!neighbour)
continue
for(var/obj/O in loc)
if(originator && O == originator)
continue
ATMOS_CANPASS_MOVABLE(airblock, O, neighbour)
. |= airblock
if(airblock & AIR_BLOCKED)
continue
ATMOS_CANPASS_TURF(airblock, neighbour, loc)
if(airblock & AIR_BLOCKED)
continue
var/datum/gas_mixture/environment = neighbour.return_air()
var/cp = environment ? environment.return_pressure() : 0
has_neighbour = TRUE
minp = min(minp, cp)
maxp = max(maxp, cp)
return has_neighbour ? abs(minp-maxp) : 0

/proc/convert_k2c(var/temp)
return ((temp - T0C))
Expand Down
6 changes: 3 additions & 3 deletions code/controllers/subsystems/air.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
var/list/curr_hotspot = processing_hotspots
var/list/curr_zones = zones_to_update

var/airblock // zeroed by ATMOS_CANPASS_TURF, declared early as microopt
while (curr_tiles.len)
var/turf/T = curr_tiles[curr_tiles.len]
curr_tiles.len--
Expand All @@ -185,9 +186,8 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
continue

//check if the turf is self-zone-blocked
var/c_airblock
ATMOS_CANPASS_TURF(c_airblock, T, T)
if(c_airblock & ZONE_BLOCKED)
ATMOS_CANPASS_TURF(airblock, T, T)
if(airblock & ZONE_BLOCKED)
deferred += T
if (no_mc_tick)
CHECK_TICK
Expand Down
18 changes: 13 additions & 5 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
var/changed = 0
lockdown=0
// Pressure alerts
pdiff = getOPressureDifferential(src.loc)
pdiff = get_surrounding_pressure_differential(loc, src)
if(pdiff >= FIREDOOR_MAX_PRESSURE_DIFF)
lockdown = 1
if(!pdiff_alert)
Expand Down Expand Up @@ -356,14 +356,22 @@
// Only opens when all areas connecting with our turf have an air alarm and are cleared
/obj/machinery/door/firedoor/proc/can_safely_open()
var/turf/neighbour
var/turf/myturf = loc
if(!istype(myturf))
return TRUE
for(var/dir in global.cardinal)
neighbour = get_step(src.loc, dir)
if(neighbour.c_airblock(src.loc) & AIR_BLOCKED)
neighbour = get_step(myturf, dir)
if(!neighbour)
continue
var/airblock // zeroed by ATMOS_CANPASS_TURF, declared early as microopt
ATMOS_CANPASS_TURF(airblock, neighbour, myturf)
if(airblock & AIR_BLOCKED)
continue
for(var/obj/O in src.loc)
for(var/obj/O in myturf)
if(istype(O, /obj/machinery/door))
continue
. |= O.c_airblock(neighbour)
ATMOS_CANPASS_MOVABLE(airblock, O, neighbour)
. |= airblock
if(. & AIR_BLOCKED)
continue
var/area/A = get_area(neighbour)
Expand Down
7 changes: 5 additions & 2 deletions code/game/objects/effects/chem/chemsmoke.dm
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@

pending += location

var/airblock // zeroed by ATMOS_CANPASS_TURF
while(pending.len)
for(var/turf/current in pending)
for(var/D in global.cardinal)
Expand All @@ -259,9 +260,11 @@
continue
if(!(target in targetTurfs))
continue
if(current.c_airblock(target)) //this is needed to stop chemsmoke from passing through thin window walls
ATMOS_CANPASS_TURF(airblock, current, target)
if(airblock) //this is needed to stop chemsmoke from passing through thin window walls
continue
if(target.c_airblock(current))
ATMOS_CANPASS_TURF(airblock, target, current)
if(airblock)
continue
pending += target

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/item_mob_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var/global/list/icon_state_cache = list()
adjusted_overlay.plane = I.plane
adjusted_overlay.layer = I.layer
overlay.overlays += adjusted_overlay
. = overlay
return overlay

//Special proc belts use to compose their icon
/obj/item/proc/get_on_belt_overlay()
Expand Down
35 changes: 24 additions & 11 deletions code/game/objects/structures/inflatable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,32 @@
check_environment()

/obj/structure/inflatable/proc/check_environment()
var/min_pressure = INFINITY
var/max_pressure = 0
var/max_local_temp = 0

for(var/check_dir in global.cardinal)
var/turf/T = get_step(get_turf(src), check_dir)
var/datum/gas_mixture/env = T.return_air()
var/pressure = env.return_pressure()
min_pressure = min(min_pressure, pressure)
max_pressure = max(max_pressure, pressure)
max_local_temp = max(max_local_temp, env.temperature)
var/turf/my_turf = get_turf(src)
if(!my_turf || !prob(50))
return

if(prob(50) && (max_pressure - min_pressure > max_pressure_diff || max_local_temp > max_temp))
var/airblock // zeroed by ATMOS_CANPASS_TURF
var/max_local_temp = 0
var/take_environment_damage = get_surrounding_pressure_differential(my_turf, src) > max_pressure_diff
if(!take_environment_damage)
for(var/check_dir in global.cardinal)
var/turf/neighbour = get_step(my_turf, check_dir)
if(!istype(neighbour))
continue
for(var/obj/O in my_turf)
if(O == src)
continue
ATMOS_CANPASS_MOVABLE(airblock, O, neighbour)
. |= airblock
if(airblock & AIR_BLOCKED)
continue
ATMOS_CANPASS_TURF(airblock, neighbour, my_turf)
if(airblock & AIR_BLOCKED)
continue
max_local_temp = max(max_local_temp, neighbour.return_air()?.temperature)

if(take_environment_damage || max_local_temp > max_temp)
take_damage(1)

/obj/structure/inflatable/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
Expand Down
20 changes: 0 additions & 20 deletions code/modules/ZAS/Atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,5 @@
fluid_update()
return TRUE

//Basically another way of calling CanPass(null, other, 0, 0) and CanPass(null, other, 1.5, 1).
//Returns:
// 0 - Not blocked
// AIR_BLOCKED - Blocked
// ZONE_BLOCKED - Not blocked, but zone boundaries will not cross.
// BLOCKED - Blocked, zone boundaries will not cross even if opened.
/atom/proc/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif
return (AIR_BLOCKED*!CanPass(null, other, 0, 0))|(ZONE_BLOCKED*!CanPass(null, other, 1.5, 1))

/turf/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif

. = 0
ATMOS_CANPASS_TURF(., src, other)

/atom/movable
var/atmos_canpass = CANPASS_ALWAYS
10 changes: 7 additions & 3 deletions code/modules/ZAS/Diagnostic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
if(!direction)
return

var/airblock
if(direction == "N/A")
to_chat(mob, "Testing self-blocking...")
if(!(T.c_airblock(T) & AIR_BLOCKED))
ATMOS_CANPASS_TURF(airblock, T, T)
if(!(airblock & AIR_BLOCKED))
to_chat(mob, "The turf can pass air! :D")
else
to_chat(mob, "No air passage :x")
Expand All @@ -44,8 +46,10 @@
if(!istype(other_turf))
return

var/t_block = T.c_airblock(other_turf)
var/o_block = other_turf.c_airblock(T)
var/t_block
ATMOS_CANPASS_TURF(t_block, T, other_turf)
var/o_block
ATMOS_CANPASS_TURF(o_block, other_turf, T)

to_chat(mob, "Testing connection between ([T.x], [T.y], [T.z]) and ([other_turf.x], [other_turf.y], [other_turf.z])...")
if(o_block & AIR_BLOCKED)
Expand Down
Loading

0 comments on commit ec54c4c

Please sign in to comment.