[FIX] Personal lockers fix (#27131)

* We can't have nice code

* Trailing newline

* Also fixes double closing sound

* Move invalid ID check all the way up

* Early return makes this if statement unnecessary.

---------

Co-authored-by: adrermail@gmail.com <adrermail@gmail.com>
This commit is contained in:
Chap
2024-10-23 21:14:56 +00:00
committed by GitHub
co-authored by adrermail@gmail.com <adrermail@gmail.com>
parent 3b944d6786
commit 25df9aacd8
2 changed files with 13 additions and 5 deletions
@@ -79,7 +79,7 @@
door_overlay.overlays += emissive_blocker(door_overlay.icon, door_overlay.icon_state, alpha = door_overlay.alpha) // If we don't do this the door doesn't block emissives and it looks weird.
else if(!opened && has_closed_overlay)
. += "[closed_door_sprite || icon_state]_closed"
if(opened)
return
@@ -255,7 +255,6 @@
if(enable_door_overlay)
animate_door(TRUE)
update_appearance()
playsound(loc, close_sound, close_sound_volume, TRUE, -3)
density = TRUE
return TRUE
@@ -39,6 +39,14 @@
if(opened || !istype(W, /obj/item/card/id))
return ..()
if(broken)
to_chat(user, "<span class='warning'>The locker appears to be broken.</span>")
return
if(user.loc == src)
to_chat(user, "<span class='notice'>You can't reach the lock from inside.</span>")
return
if(istype(W, /obj/item/card/id/guest))
to_chat(user, "<span class='warning'>Invalid identification card.</span>")
return
@@ -47,16 +55,17 @@
if(!I || !I.registered_name)
return
else if(allowed(user) || !registered_name || (istype(I) && (registered_name == I.registered_name)))
if(allowed(user) || !registered_name || (istype(I) && (registered_name == I.registered_name)))
//they can open all lockers, or nobody owns this, or they own this locker
togglelock(user)
locked = !locked
update_icon()
if(!locked)
registered_name = null
desc = initial(desc)
if(!registered_name && locked)
registered_name = I.registered_name
desc = "Owned by [I.registered_name]."
desc = "Owned by [I.registered_name]."
else
to_chat(user, "<span class='warning'>Access denied.</span>")