diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index a85c69e7b81..928561abe94 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1314,44 +1314,32 @@ var/global/list/common_tools = list( Checks if that loc and dir has a item on the wall */ var/list/WALLITEMS = list( - "/obj/machinery/power/apc", "/obj/machinery/alarm", "/obj/item/device/radio/intercom", - "/obj/structure/extinguisher_cabinet", "/obj/structure/reagent_dispensers/peppertank", - "/obj/machinery/status_display", "/obj/machinery/requests_console", "/obj/machinery/light_switch", "/obj/effect/sign", - "/obj/machinery/newscaster", "/obj/machinery/firealarm", "/obj/structure/noticeboard", "/obj/machinery/door_control", - "/obj/machinery/computer/security/telescreen", "/obj/machinery/embedded_controller/radio/simple_vent_controller", - "/obj/item/weapon/storage/secure/safe", "/obj/machinery/door_timer", "/obj/machinery/flasher", "/obj/machinery/keycard_auth", - "/obj/structure/mirror", "/obj/structure/closet/fireaxecabinet", "/obj/machinery/computer/security/telescreen/entertainment" + /obj/machinery/power/apc, /obj/machinery/alarm, /obj/item/device/radio/intercom, + /obj/structure/extinguisher_cabinet, /obj/structure/reagent_dispensers/peppertank, + /obj/machinery/status_display, /obj/machinery/requests_console, /obj/machinery/light_switch, /obj/structure/sign, + /obj/machinery/newscaster, /obj/machinery/firealarm, /obj/structure/noticeboard, /obj/machinery/door_control, + /obj/machinery/computer/security/telescreen, /obj/machinery/embedded_controller/radio/simple_vent_controller, + /obj/item/weapon/storage/secure/safe, /obj/machinery/door_timer, /obj/machinery/flasher, /obj/machinery/keycard_auth, + /obj/structure/mirror, /obj/structure/closet/fireaxecabinet, /obj/machinery/computer/security/telescreen/entertainment ) /proc/gotwallitem(loc, dir) + var/locdir = get_step(loc, dir) for(var/obj/O in loc) - for(var/item in WALLITEMS) - if(istype(O, text2path(item))) - //Direction works sometimes - if(O.dir == dir) - return 1 - - //Some stuff doesn't use dir properly, so we need to check pixel instead - switch(dir) - if(SOUTH) - if(O.pixel_y > 10) - return 1 - if(NORTH) - if(O.pixel_y < -10) - return 1 - if(WEST) - if(O.pixel_x > 10) - return 1 - if(EAST) - if(O.pixel_x < -10) - return 1 + if(is_type_in_list(O, WALLITEMS)) + //Direction works sometimes + if(O.dir == dir) + return 1 + //Some stuff doesn't use dir properly, so we need to check pixel instead + //That's exactly what get_wall_mounted_turf() does + if(get_wall_mounted_turf(O) == locdir) + return 1 //Some stuff is placed directly on the wallturf (signs) - for(var/obj/O in get_step(loc, dir)) - for(var/item in WALLITEMS) - if(istype(O, text2path(item))) - if(O.pixel_x == 0 && O.pixel_y == 0) - return 1 + for(var/obj/O in locdir) + if(is_type_in_list(O, WALLITEMS)) + if(O.pixel_x == 0 && O.pixel_y == 0) + return 1 return 0 /proc/format_text(text) @@ -1405,3 +1393,21 @@ var/list/WALLITEMS = list( step(AM, pick(alldirs)) chance = max(chance - (initial_chance / steps), 0) steps-- + +/proc/get_wall_mounted_turf(atom/A) + /* This proc uses the pixel_x/y vars to guess the fake turf of a wall mounted atom. + Needless to say, this is an error prone method and possibly open to exploits. + It is however faster than using icon procs to get a more accurate reading. + I've only tested this proc on APCs. Use it with care.*/ + if(is_type_in_list(A, WALLITEMS)) + var/stepdir = 0 + + if(A.pixel_x > 10) stepdir |= EAST + if(A.pixel_x < -10) stepdir |= WEST + if(A.pixel_y > 10) stepdir |= NORTH + if(A.pixel_y < -10) stepdir |= SOUTH + + if(stepdir) + return get_step(A, stepdir) + return get_turf(A) + diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 857008e4edf..c6828169bd7 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -242,7 +242,8 @@ Class Procs: return //stop AIs from leaving windows open and using then after they lose vision //apc_override is needed here because AIs use their own APC when powerless - if(cameranet && !cameranet.checkTurfVis(get_turf(M)) && !apc_override) + //the snowflake get_wall_mounted_turf() is because APCs in maint aren't actually in view of the inner camera + if(cameranet && !cameranet.checkTurfVis(get_wall_mounted_turf(M)) && !apc_override) return return 1