Skip to content

Commit

Permalink
Fix chainlink fence doors having incorrect icon/density (tgstation#64882
Browse files Browse the repository at this point in the history
)

Fence doors used a var to track if they were opened or not, but it doesn't sync consistently with the density var. Density was getting set when updating icon state instead of when toggling the door. This removes the unneeded open var and flips density only during toggle.
  • Loading branch information
cakexensen committed Feb 21, 2022
1 parent 9540532 commit 44fbe26
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions code/game/objects/structures/fence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@
desc = "Not very useful without a real lock."
icon_state = "door_closed"
cuttable = FALSE
var/open = FALSE

/obj/structure/fence/door/Initialize(mapload)
. = ..()

update_door_status()
update_icon_state()

/obj/structure/fence/door/opened
icon_state = "door_opened"
open = TRUE
density = TRUE
density = FALSE

/obj/structure/fence/door/attack_hand(mob/user, list/modifiers)
if(can_open(user))
Expand All @@ -129,14 +127,14 @@
return TRUE

/obj/structure/fence/door/proc/toggle(mob/user)
open = !open
visible_message(span_notice("\The [user] [open ? "opens" : "closes"] \the [src]."))
update_door_status()
visible_message(span_notice("\The [user] [density ? "opens" : "closes"] \the [src]."))
set_density(!density)
update_icon_state()
playsound(src, 'sound/machines/click.ogg', 100, TRUE)

/obj/structure/fence/door/proc/update_door_status()
set_density(!density)
/obj/structure/fence/door/update_icon_state()
icon_state = density ? "door_closed" : "door_opened"
return ..()

/obj/structure/fence/door/proc/can_open(mob/user)
return TRUE
Expand Down

0 comments on commit 44fbe26

Please sign in to comment.