From c6a9bdb4b24f95a3a895713ee66662e6a587a868 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Thu, 18 May 2017 16:37:50 -0500 Subject: [PATCH] Fixes clicking things under windows/doors. --- code/__DEFINES/flags.dm | 1 + code/_onclick/click.dm | 19 +++++++++++++++++++ code/game/machinery/doors/door.dm | 1 + code/game/objects/structures/window.dm | 12 ++++++------ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index b0742ae3ab..a5e69bdc7b 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -27,6 +27,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define BLOCK_GAS_SMOKE_EFFECT 4096 // blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY! #define THICKMATERIAL 8192 //prevents syringes, parapens and hypos if the external suit or helmet (if targeting head) has this flag. Example: space suits, biosuit, bombsuits, thick suits that cover your body. #define DROPDEL 16384 // When dropped, it calls qdel on itself +#define PREVENT_CLICK_UNDER 32768 //Prevent clicking things below it on the same turf eg. doors/ fulltile windows /* Secondary atom flags, access using the SECONDARY_FLAG macros */ diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 07dcfaee28..a0fc60a2fc 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -92,6 +92,9 @@ if(next_move > world.time) // in the year 2000... return + if(A.IsObscured()) + return + if(istype(loc,/obj/mecha)) var/obj/mecha/M = loc return M.click_action(A,src,params) @@ -141,6 +144,22 @@ else RangedAttack(A,params) +//Is the atom obscured by a PREVENT_CLICK_UNDER object above it +/atom/proc/IsObscured() + if(!isturf(loc)) //This only makes sense for things directly on turfs for now + return FALSE + var/turf/T = loc + for(var/atom/movable/AM in T) + if(AM.flags & PREVENT_CLICK_UNDER && AM.density && AM.layer > layer) + return TRUE + return FALSE + +/turf/IsObscured() + for(var/atom/movable/AM in src) + if(AM.flags & PREVENT_CLICK_UNDER && AM.density) + return TRUE + return FALSE + /atom/movable/proc/CanReach(atom/target,obj/item/tool,view_only = FALSE) if(isturf(target) || isturf(target.loc) || DirectAccess(target)) //Directly accessible atoms if(Adjacent(target) || (tool && CheckToolReach(src, target, tool.reach))) //Adjacent or reaching attacks diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 4e076e3338..b71aeaca8d 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -12,6 +12,7 @@ max_integrity = 350 armor = list(melee = 30, bullet = 30, laser = 20, energy = 20, bomb = 10, bio = 100, rad = 100, fire = 80, acid = 70) CanAtmosPass = ATMOS_PASS_DENSITY + flags = PREVENT_CLICK_UNDER var/secondsElectrified = 0 var/shockedby = list() diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index d5027a0c75..f594c4b513 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -440,7 +440,7 @@ dir = FULLTILE_WINDOW_DIR max_integrity = 50 fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER smooth = SMOOTH_TRUE canSmoothWith = list(/obj/structure/window/fulltile, /obj/structure/window/reinforced/fulltile,/obj/structure/window/reinforced/highpressure/fulltile, /obj/structure/window/reinforced/tinted/fulltile) glass_amount = 2 @@ -454,7 +454,7 @@ dir = FULLTILE_WINDOW_DIR max_integrity = 100 fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER smooth = SMOOTH_TRUE canSmoothWith = list(/obj/structure/window/fulltile, /obj/structure/window/reinforced/fulltile,/obj/structure/window/reinforced/highpressure/fulltile, /obj/structure/window/reinforced/tinted/fulltile) @@ -467,7 +467,7 @@ dir = FULLTILE_WINDOW_DIR max_integrity = 1000 fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER smooth = SMOOTH_TRUE canSmoothWith = list(/obj/structure/window/fulltile, /obj/structure/window/reinforced/fulltile,/obj/structure/window/reinforced/highpressure/fulltile, /obj/structure/window/reinforced/tinted/fulltile) level = 3 @@ -481,7 +481,7 @@ icon_state = "tinted_window" dir = FULLTILE_WINDOW_DIR fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER smooth = SMOOTH_TRUE canSmoothWith = list(/obj/structure/window/fulltile, /obj/structure/window/reinforced/fulltile,/obj/structure/window/reinforced/highpressure/fulltile, /obj/structure/window/reinforced/tinted/fulltile/) level = 3 @@ -504,7 +504,7 @@ max_integrity = 100 wtype = "shuttle" fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER reinf = 1 heat_resistance = 1600 armor = list(melee = 50, bullet = 0, laser = 0, energy = 0, bomb = 25, bio = 100, rad = 100, fire = 80, acid = 100) @@ -583,7 +583,7 @@ smooth = SMOOTH_TRUE canSmoothWith = null fulltile = 1 - flags = NONE + flags = PREVENT_CLICK_UNDER dir = FULLTILE_WINDOW_DIR max_integrity = 120 level = 3