From a01f41e9049f0466fbbb4f54342e0ea808b8557f Mon Sep 17 00:00:00 2001 From: DGamerL <108773801+DGamerL@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:08:11 +0200 Subject: [PATCH] [s] Blocks any doubled wall mount placement (#27016) * Blocks any doubled wall mount placement * Fixes direction stuff * Remove old code --- code/__HELPERS/unsorted.dm | 32 ++++--------------- .../objects/items/mountable_frames/frames.dm | 6 ++-- .../items/mountable_frames/mountables.dm | 11 ++++--- 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index c73a61bb1c2..b826bfed206 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1141,41 +1141,23 @@ Checks if that loc and dir has a item on the wall */ GLOBAL_LIST_INIT(wall_items, typecacheof(list(/obj/machinery/power/apc, /obj/machinery/alarm, /obj/item/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/status_display, /obj/machinery/requests_console, /obj/structure/sign, /obj/machinery/newscaster, /obj/machinery/firealarm, /obj/structure/noticeboard, /obj/machinery/door_control, /obj/machinery/computer/security/telescreen, /obj/machinery/airlock_controller, /obj/item/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/structure/sign, /obj/machinery/barsign))) + /obj/structure/sign, /obj/machinery/barsign, /obj/machinery/light, /obj/machinery/light_construct))) /proc/gotwallitem(loc, dir) for(var/obj/O in loc) - if(is_type_in_typecache(O, GLOB.wall_items)) - //Direction works sometimes - if(O.dir == dir) - return 1 + if(is_type_in_typecache(O, GLOB.wall_items) && dir == O.dir) + return TRUE - //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 - - //Some stuff is placed directly on the wallturf (signs) + // Some stuff is placed directly on the wallturf (signs) for(var/obj/O in get_step(loc, dir)) if(is_type_in_typecache(O, GLOB.wall_items)) - if(abs(O.pixel_x) <= 10 && abs(O.pixel_y) <= 10) - return 1 - return 0 + return TRUE + return FALSE /proc/atan2(x, y) if(!x && !y) return 0 diff --git a/code/game/objects/items/mountable_frames/frames.dm b/code/game/objects/items/mountable_frames/frames.dm index 5823064a91a..6da3982e04d 100644 --- a/code/game/objects/items/mountable_frames/frames.dm +++ b/code/game/objects/items/mountable_frames/frames.dm @@ -22,15 +22,15 @@ /obj/item/mounted/frame/try_build(turf/on_wall, mob/user) if(!..()) - return + return FALSE var/turf/build_turf = get_turf(user) if((mount_requirements & MOUNTED_FRAME_SIMFLOOR) && !isfloorturf(build_turf)) to_chat(user, "[src] cannot be placed on this spot.") - return + return FALSE if(mount_requirements & MOUNTED_FRAME_NOSPACE) var/area/my_area = get_area(build_turf) if(!istype(my_area) || !my_area.requires_power || isspacearea(my_area)) to_chat(user, "[src] cannot be placed in this area.") - return + return FALSE return TRUE diff --git a/code/game/objects/items/mountable_frames/mountables.dm b/code/game/objects/items/mountable_frames/mountables.dm index 4047cbd94a5..31fa665a51b 100644 --- a/code/game/objects/items/mountable_frames/mountables.dm +++ b/code/game/objects/items/mountable_frames/mountables.dm @@ -14,17 +14,18 @@ /obj/item/mounted/proc/try_build(turf/on_wall, mob/user, proximity_flag) //checks if(!on_wall || !user) - return + return FALSE if(!proximity_flag) //if we aren't next to the turf - return + return FALSE + if(!allow_floor_mounting) if(!(get_dir(on_wall, user) in GLOB.cardinal)) to_chat(user, "You need to be standing next to [on_wall] to place [src].") - return + return FALSE - if(gotwallitem(get_turf(user), get_dir(on_wall, user))) + if(gotwallitem(get_turf(user), get_dir(user, on_wall))) to_chat(user, "There's already an item on this wall!") - return + return FALSE return TRUE