From f7a4d1bdebd0b5c18c731f7b2f50eaee51e70fdf Mon Sep 17 00:00:00 2001 From: Lohikar Date: Tue, 20 Feb 2018 16:52:25 -0600 Subject: [PATCH 1/4] Fix space wind --- code/ZAS/Airflow.dm | 31 +++++++++++++++++++++++-------- code/ZAS/ConnectionGroup.dm | 10 +++++----- code/__defines/ZAS.dm | 1 + 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/code/ZAS/Airflow.dm b/code/ZAS/Airflow.dm index 327e8b03ee5..c02ffb10d4f 100644 --- a/code/ZAS/Airflow.dm +++ b/code/ZAS/Airflow.dm @@ -141,13 +141,28 @@ mob/living/carbon/human/airflow_hit(atom/A) Stun(round(airflow_speed * vsc.airflow_stun/2)) . = ..() -zone/proc/movables() +zone/proc/movables(list/origins) . = list() - for(var/turf/T in contents) - CHECK_TICK + if (!origins || !origins.len) + return - for(var/aa in T) - var/atom/movable/A = aa - if(!A.simulated || A.anchored || istype(A, /obj/effect) || istype(A, /mob/abstract/eye)) - continue - . += A + var/list/A // this should be the longer list + var/list/B + if (contents.len > origins) + A = contents + B = origins + else + A = origins + B = contents + + for (var/t in A) + var/turf/T = t + for (var/tt in B) + var/turf/TT = tt + if (T.contents.len > !!T.lighting_overlay && get_dist(T, TT) <= EDGE_KNOCKDOWN_MAX_DISTANCE) + for (var/am in T) + var/atom/movable/AM = am + if (AM.simulated && !AM.anchored && !istype(AM, /obj/effect) && !istype(AM, /mob/abstract)) + .[AM] = TRUE + + CHECK_TICK diff --git a/code/ZAS/ConnectionGroup.dm b/code/ZAS/ConnectionGroup.dm index 27efb6ced96..78a1d43b8f4 100644 --- a/code/ZAS/ConnectionGroup.dm +++ b/code/ZAS/ConnectionGroup.dm @@ -169,11 +169,11 @@ Class Procs: var/list/attracted var/list/repelled if(differential > 0) - attracted = A.movables() - repelled = B.movables() + attracted = A.movables(connecting_turfs) + repelled = B.movables(connecting_turfs) else - attracted = B.movables() - repelled = A.movables() + attracted = B.movables(connecting_turfs) + repelled = A.movables(connecting_turfs) // These are async, with waitfor = FALSE flow(attracted, abs(differential), 0) @@ -239,7 +239,7 @@ Class Procs: var/differential = A.air.return_pressure() - air.return_pressure() if(abs(differential) >= vsc.airflow_lightest_pressure) - var/list/attracted = A.movables() + var/list/attracted = A.movables(connecting_turfs) // This call is async, with waitfor = FALSE flow(attracted, abs(differential), differential < 0) diff --git a/code/__defines/ZAS.dm b/code/__defines/ZAS.dm index e19de00e7a4..9c58cb7d314 100644 --- a/code/__defines/ZAS.dm +++ b/code/__defines/ZAS.dm @@ -7,6 +7,7 @@ #define BLOCKED 3 #define ZONE_MIN_SIZE 14 //zones with less than this many turfs will always merge, even if the connection is not direct +#define EDGE_KNOCKDOWN_MAX_DISTANCE 16 // Maximum distance between an airflow origin and a movable before knockdown no longer applies. #define CANPASS_ALWAYS 1 #define CANPASS_DENSITY 2 From f29ca756811bbc2f64df5d534157f89215d308d3 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Tue, 20 Feb 2018 16:53:29 -0600 Subject: [PATCH 2/4] changelog --- html/changelogs/lohikar-spacewind.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 html/changelogs/lohikar-spacewind.yml diff --git a/html/changelogs/lohikar-spacewind.yml b/html/changelogs/lohikar-spacewind.yml new file mode 100644 index 00000000000..eee1da79483 --- /dev/null +++ b/html/changelogs/lohikar-spacewind.yml @@ -0,0 +1,5 @@ +author: Lohikar + +delete-after: True +changes: + - bugfix: "ZAS Knockdown now has a distance cap. (Fixes 'space wind')" From 1a4b88edc3f95f370527f726203bb06b0653f389 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Wed, 21 Feb 2018 09:52:51 -0600 Subject: [PATCH 3/4] Make this a bit less insanely expensive --- code/ZAS/Airflow.dm | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/code/ZAS/Airflow.dm b/code/ZAS/Airflow.dm index c02ffb10d4f..e7af40835e5 100644 --- a/code/ZAS/Airflow.dm +++ b/code/ZAS/Airflow.dm @@ -146,23 +146,18 @@ zone/proc/movables(list/origins) if (!origins || !origins.len) return - var/list/A // this should be the longer list - var/list/B - if (contents.len > origins) - A = contents - B = origins - else - A = origins - B = contents - - for (var/t in A) - var/turf/T = t - for (var/tt in B) - var/turf/TT = tt - if (T.contents.len > !!T.lighting_overlay && get_dist(T, TT) <= EDGE_KNOCKDOWN_MAX_DISTANCE) - for (var/am in T) - var/atom/movable/AM = am - if (AM.simulated && !AM.anchored && !istype(AM, /obj/effect) && !istype(AM, /mob/abstract)) + var/turf/T + var/turf/TT + var/atom/movable/AM + for (var/t in contents) + T = t + for (var/am in T) + AM = am + if (AM.simulated && !AM.anchored && !istype(AM, /obj/effect) && !istype(AM, /mob/abstract)) + for (var/tt in origins) + TT = tt + if (get_dist(T, TT) <= EDGE_KNOCKDOWN_MAX_DISTANCE) .[AM] = TRUE + break - CHECK_TICK + CHECK_TICK From 7d08f139287f83e60cd3c9ca11978885fc801780 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Sat, 24 Feb 2018 00:30:53 -0600 Subject: [PATCH 4/4] Remove pointless typecasting, minor performance tweaks --- code/ZAS/Airflow.dm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/ZAS/Airflow.dm b/code/ZAS/Airflow.dm index e7af40835e5..089b59d6632 100644 --- a/code/ZAS/Airflow.dm +++ b/code/ZAS/Airflow.dm @@ -146,17 +146,15 @@ zone/proc/movables(list/origins) if (!origins || !origins.len) return - var/turf/T - var/turf/TT + var/static/list/movables_tcache = typecacheof(list(/obj/effect, /mob/abstract)) + var/atom/movable/AM - for (var/t in contents) - T = t - for (var/am in T) + for (var/testing_turf in contents) + for (var/am in testing_turf) AM = am - if (AM.simulated && !AM.anchored && !istype(AM, /obj/effect) && !istype(AM, /mob/abstract)) - for (var/tt in origins) - TT = tt - if (get_dist(T, TT) <= EDGE_KNOCKDOWN_MAX_DISTANCE) + if (AM.simulated && !AM.anchored && !movables_tcache[AM.type]) + for (var/source_turf in origins) + if (get_dist(testing_turf, source_turf) <= EDGE_KNOCKDOWN_MAX_DISTANCE) .[AM] = TRUE break