Skip to content

Commit

Permalink
Clean up firedoors and add proper emag behavior (#28087)
Browse files Browse the repository at this point in the history
* That was a lot of running around

* This ordering is better

* Update areas.dm

* Update firedoor.dm
  • Loading branch information
Vi3trice authored Feb 2, 2025
1 parent b56c390 commit 8a47c1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
9 changes: 8 additions & 1 deletion code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,17 @@
continue

// At this point, the area is safe and the door is technically functional.
// Firedoors do not close automatically by default, and setting it to false when the alarm is off prevents unnecessary timers from being created. Emagged doors are permanently disabled from automatically closing, or being operated by alarms altogether apart from the lights.
if(!D.emagged)
if(opening)
D.autoclose = FALSE
else
D.autoclose = TRUE

INVOKE_ASYNC(D, (opening ? TYPE_PROC_REF(/obj/machinery/door/firedoor, deactivate_alarm) : TYPE_PROC_REF(/obj/machinery/door/firedoor, activate_alarm)))
if(D.welded)
if(D.welded || D.emagged)
continue // Alarm is toggled, but door stuck

if(D.operating)
if((D.operating == DOOR_OPENING && opening) || (D.operating == DOOR_CLOSING && !opening))
continue
Expand Down
22 changes: 13 additions & 9 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
user.visible_message(
"<span class='notice'>[user] opens [src].</span>",
"<span class='notice'>You open [src].</span>")
open(auto_close = FALSE)
open()

/obj/machinery/door/firedoor/item_interaction(mob/living/user, obj/item/used, list/modifiers)
add_fingerprint(user)
Expand Down Expand Up @@ -187,6 +187,12 @@
welded = !welded
update_icon(UPDATE_OVERLAYS)

/obj/machinery/door/firedoor/emag_act(mob/user)
if(!density)
return
autoclose = FALSE
return ..()

/obj/machinery/door/firedoor/try_to_crowbar(obj/item/I, mob/user)
if(welded || operating)
return
Expand Down Expand Up @@ -245,15 +251,13 @@
adjust_light()
update_icon()

/obj/machinery/door/firedoor/open(auto_close = TRUE)
/obj/machinery/door/firedoor/open()
if(welded)
return
. = ..()
latetoggle(auto_close)
latetoggle()
if(active_alarm)
layer = closingLayer // Active firedoors take precedence and remain visible over closed airlocks.
if(auto_close)
autoclose = TRUE

/obj/machinery/door/firedoor/close()
. = ..()
Expand All @@ -263,20 +267,20 @@
if(active_alarm)
. = ..()

/obj/machinery/door/firedoor/proc/latetoggle(auto_close = TRUE)
/obj/machinery/door/firedoor/proc/latetoggle()
if(operating || !hasPower() || !nextstate)
return
if(nextstate == FD_OPEN)
INVOKE_ASYNC(src, PROC_REF(open), auto_close)
INVOKE_ASYNC(src, PROC_REF(open))
if(nextstate == FD_CLOSED)
INVOKE_ASYNC(src, PROC_REF(close))
nextstate = null

/obj/machinery/door/firedoor/proc/forcetoggle(magic = FALSE, auto_close = TRUE)
/obj/machinery/door/firedoor/proc/forcetoggle(magic = FALSE)
if(!magic && (operating || !hasPower()))
return
if(density)
open(auto_close)
open()
else
close()

Expand Down

0 comments on commit 8a47c1a

Please sign in to comment.