mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 12:37:50 +01:00
Merge pull request #7536 from VOREStation/vplk-proper-atmos-canpass
Use can_atmos_pass to reduce proc-calls in c_airblock()
This commit is contained in:
+19
-4
@@ -16,13 +16,19 @@
|
||||
// Inputs: The turf the airflow is from, which may not be the same as loc. is_zone is for conditionally disallowing merging.
|
||||
// Outputs: Boolean if airflow can pass.
|
||||
/atom/proc/CanZASPass(turf/T, is_zone)
|
||||
// Behaviors defined here so when people directly call c_airblock it will still obey can_atmos_pass
|
||||
switch(can_atmos_pass)
|
||||
if(ATMOS_PASS_YES)
|
||||
return TRUE
|
||||
if(ATMOS_PASS_NO)
|
||||
return FALSE
|
||||
if(ATMOS_PASS_DENSITY)
|
||||
return !density
|
||||
if(ATMOS_PASS_PROC)
|
||||
// Cowardly refuse to recursively self-call CanZASPass. The hero BYOND needs?
|
||||
CRASH("can_atmos_pass = ATMOS_PASS_PROC but CanZASPass not overridden on [src] ([type])")
|
||||
else
|
||||
return can_atmos_pass
|
||||
|
||||
/turf/can_atmos_pass = ATMOS_PASS_NO
|
||||
CRASH("Invalid can_atmos_pass = [can_atmos_pass] on [src] ([type])")
|
||||
|
||||
/turf/CanPass(atom/movable/mover, turf/target)
|
||||
if(!target) return FALSE
|
||||
@@ -89,6 +95,15 @@ turf/c_airblock(turf/other)
|
||||
var/result = 0
|
||||
for(var/mm in contents)
|
||||
var/atom/movable/M = mm
|
||||
result |= M.c_airblock(other)
|
||||
switch(M.can_atmos_pass)
|
||||
if(ATMOS_PASS_YES)
|
||||
continue
|
||||
if(ATMOS_PASS_NO)
|
||||
return BLOCKED
|
||||
if(ATMOS_PASS_DENSITY)
|
||||
if(density)
|
||||
return BLOCKED
|
||||
if(ATMOS_PASS_PROC)
|
||||
result |= M.c_airblock(other)
|
||||
if(result == BLOCKED) return BLOCKED
|
||||
return result
|
||||
|
||||
@@ -4,3 +4,10 @@
|
||||
#define BLOCKED 3 // Blocked, zone boundaries will not cross even if opened.
|
||||
|
||||
#define ZONE_MIN_SIZE 14 // Zones with less than this many turfs will always merge, even if the connection is not direct
|
||||
|
||||
// Used for quickly making certain things allow airflow or not.
|
||||
// More complicated, conditional airflow should override CanZASPass().
|
||||
#define ATMOS_PASS_YES 1 // Always blocks air and zones.
|
||||
#define ATMOS_PASS_NO 2 // Never blocks air or zones.
|
||||
#define ATMOS_PASS_DENSITY 3 // Blocks air and zones if density = 1, allows both if density = 0
|
||||
#define ATMOS_PASS_PROC 4 // Call CanZASPass() using c_airblock
|
||||
|
||||
@@ -94,9 +94,3 @@
|
||||
#define ATMOSTANK_CO2 25000 // CO2 and PH are not critically important for station, only for toxins and alternative coolants, no need to store a lot of those.
|
||||
#define ATMOSTANK_PHORON 25000
|
||||
#define ATMOSTANK_NITROUSOXIDE 10000 // N2O doesn't have a real useful use, i guess it's on station just to allow refilling of sec's riot control canisters?
|
||||
|
||||
// Used for quickly making certain things allow airflow or not.
|
||||
// More complicated, conditional airflow should override CanZASPass().
|
||||
#define ATMOS_PASS_YES 1
|
||||
#define ATMOS_PASS_NO 0
|
||||
#define ATMOS_PASS_DENSITY -1 // Just checks density.
|
||||
@@ -269,7 +269,7 @@
|
||||
// If for some reason this is actually needed for something important, uncomment this.
|
||||
/obj/machinery/door/blast/CanZASPass(turf/T, is_zone)
|
||||
if(is_zone)
|
||||
return ATMOS_PASS_YES
|
||||
return TRUE
|
||||
return ..()
|
||||
*/
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
anchored = 1
|
||||
opacity = 1
|
||||
density = 1
|
||||
can_atmos_pass = ATMOS_PASS_DENSITY
|
||||
can_atmos_pass = ATMOS_PASS_PROC
|
||||
layer = DOOR_OPEN_LAYER
|
||||
var/open_layer = DOOR_OPEN_LAYER
|
||||
var/closed_layer = DOOR_CLOSED_LAYER
|
||||
@@ -157,8 +157,8 @@
|
||||
|
||||
/obj/machinery/door/CanZASPass(turf/T, is_zone)
|
||||
if(is_zone)
|
||||
return block_air_zones ? ATMOS_PASS_NO : ATMOS_PASS_YES
|
||||
return ..()
|
||||
return !block_air_zones // Block merging unless block_air_zones = 0
|
||||
return !density // Block airflow unless density = 0
|
||||
|
||||
/obj/machinery/door/proc/bumpopen(mob/user as mob)
|
||||
if(operating) return
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
opacity = 0
|
||||
var/obj/item/weapon/airlock_electronics/electronics = null
|
||||
explosion_resistance = 5
|
||||
can_atmos_pass = ATMOS_PASS_PROC
|
||||
air_properties_vary_with_direction = 1
|
||||
|
||||
/obj/machinery/door/window/New()
|
||||
@@ -94,9 +95,9 @@
|
||||
/obj/machinery/door/window/CanZASPass(turf/T, is_zone)
|
||||
if(get_dir(T, loc) == turn(dir, 180))
|
||||
if(is_zone) // No merging allowed.
|
||||
return ATMOS_PASS_NO
|
||||
return ..() // Air can flow if open (density == FALSE).
|
||||
return ATMOS_PASS_YES // Windoors don't block if not facing the right way.
|
||||
return FALSE
|
||||
return !density // Air can flow if open (density == FALSE).
|
||||
return TRUE // Windoors don't block if not facing the right way.
|
||||
|
||||
/obj/machinery/door/window/CheckExit(atom/movable/mover as mob|obj, turf/target as turf)
|
||||
if(istype(mover) && mover.checkpass(PASSGLASS))
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
anchored = 1
|
||||
density = 0
|
||||
opacity = 0
|
||||
can_atmos_pass = ATMOS_PASS_PROC
|
||||
|
||||
/obj/effect/zone_divider/CanZASPass(turf/T, is_zone)
|
||||
// Special case to prevent us from being part of a zone during the first air master tick.
|
||||
@@ -15,5 +16,5 @@
|
||||
if(air_master && air_master.current_cycle == 0)
|
||||
spawn(1)
|
||||
air_master.mark_for_update(get_turf(src))
|
||||
return ATMOS_PASS_NO
|
||||
return is_zone ? ATMOS_PASS_NO : ATMOS_PASS_YES // Anything except zones can pass
|
||||
return FALSE
|
||||
return is_zone ? FALSE : TRUE // Anything except zones can pass
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
desc = "A window."
|
||||
icon = 'icons/obj/structures_vr.dmi' // VOREStation Edit - New icons
|
||||
density = 1
|
||||
can_atmos_pass = ATMOS_PASS_DENSITY
|
||||
can_atmos_pass = ATMOS_PASS_PROC
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
|
||||
layer = WINDOW_LAYER
|
||||
@@ -144,8 +144,8 @@
|
||||
|
||||
/obj/structure/window/CanZASPass(turf/T, is_zone)
|
||||
if(is_fulltile() || get_dir(T, loc) == turn(dir, 180)) // Make sure we're handling the border correctly.
|
||||
return anchored ? ATMOS_PASS_NO : ATMOS_PASS_YES // If it's anchored, it'll block air.
|
||||
return ATMOS_PASS_YES // Don't stop airflow from the other sides.
|
||||
return !anchored // If it's anchored, it'll block air.
|
||||
return TRUE // Don't stop airflow from the other sides.
|
||||
|
||||
/obj/structure/window/CheckExit(atom/movable/O as mob|obj, target as turf)
|
||||
if(istype(O) && O.checkpass(PASSGLASS))
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
return !P.can_hit_target(src, P.permutated, src == P.original, TRUE)
|
||||
return (!mover.density || !density || lying)
|
||||
|
||||
/mob/CanZASPass(turf/T, is_zone)
|
||||
return ATMOS_PASS_YES
|
||||
|
||||
/mob/living/SelfMove(turf/n, direct)
|
||||
// If on walk intent, don't willingly step into hazardous tiles.
|
||||
// Unless the walker is confused.
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
icon_state = "compressor"
|
||||
anchored = TRUE
|
||||
density = TRUE
|
||||
can_atmos_pass = ATMOS_PASS_PROC
|
||||
circuit = /obj/item/weapon/circuitboard/machine/power_compressor
|
||||
var/obj/machinery/power/turbine/turbine
|
||||
var/datum/gas_mixture/gas_contained
|
||||
@@ -96,7 +97,7 @@
|
||||
|
||||
// When anchored, don't let air past us.
|
||||
/obj/machinery/compressor/CanZASPass(turf/T, is_zone)
|
||||
return anchored ? ATMOS_PASS_NO : ATMOS_PASS_YES
|
||||
return !anchored
|
||||
|
||||
/obj/machinery/compressor/proc/locate_machinery()
|
||||
if(turbine)
|
||||
|
||||
Reference in New Issue
Block a user