diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm
index f8cec8b3054..f64c0a293ee 100644
--- a/code/game/machinery/doors/brigdoors.dm
+++ b/code/game/machinery/doors/brigdoors.dm
@@ -1,106 +1,24 @@
-// NOTE: Each brig door and door_control must be placed on top of an other on the map, use offset to
-// put the control on a wall.
-// ID variable on door and on door control links them together.
-
-/obj/machinery/computer/door_control
- name = "Door Control"
- icon = 'stationobjs.dmi'
- icon_state = "sec_computer"
- req_access = list(access_brig)
-// var/authenticated = 0.0 if anyone wants to make it so you need to log in in future go ahead.
- var/id = 1.0 // ID of door control and door it operates
-
-/obj/machinery/computer/door_control/proc/alarm()
- if(stat & (NOPOWER|BROKEN))
- return
- for(var/obj/machinery/door/window/brigdoor/M in world)
- if (M.id == src.id)
- if(M.density)
- spawn( 0 )
- M.open()
-// else
-// spawn( 0 )
-// M.close()
- src.updateUsrDialog()
- return
-
-//Allows the AI to control doors, see human attack_hand function below
-/obj/machinery/computer/door_control/attack_ai(var/mob/user as mob)
- return src.attack_hand(user)
-
-//Allows monkeys to control doors, see human attack_hand function below
-/obj/machinery/computer/door_control/attack_paw(var/mob/user as mob)
- return src.attack_hand(user)
-
-// A security door_control computer for centralizing all brig door locks.
-/obj/machinery/computer/door_control/attack_hand(var/mob/user as mob)
- if(..())
- return
- var/dat = "
Brig Computer
"
- user.machine = src
- for(var/obj/machinery/door/window/brigdoor/M in world)
- if(M.id == 1)
- dat += text("Door 1: [(M.density ? "Closed" : "Opened")]
")
- else if(M.id == 2)
- dat += text("Door 2: [(M.density ? "Closed" : "Opened")]
")
- else if(M.id == 3)
- dat += text("Door 3: [(M.density ? "Closed" : "Opened")]
")
- else if(M.id == 4)
- dat += text("Door 4: [(M.density ? "Closed" : "Opened")]
")
- else if(M.id == 5)
- dat += text("Door 5: [(M.density ? "Closed" : "Opened")]
")
- else
- world << "Invalid ID detected on brigdoor ([M.x],[M.y],[M.z]) with id [M.id]"
- dat += text("
Open All
")
- dat += text("Close All
")
- dat += text("
Close")
- user << browse(dat, "window=computer;size=400x500")
- onclose(user, "computer")
- return
-
-//Allows the door_control computer to open/close brig doors.
-/obj/machinery/computer/door_control/Topic(href, href_list)
- if(..())
- return
- if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
- usr.machine = src
- if (href_list["setid"])
- if(src.allowed(usr))
- src.id = text2num(href_list["setid"])
- src.alarm()
- if (href_list["openall"])
- if(src.allowed(usr))
- for(var/obj/machinery/door/window/brigdoor/M in world)
- if(M.density)
- M.open()
- if (href_list["closeall"])
- if(src.allowed(usr))
- for(var/obj/machinery/door/window/brigdoor/M in world)
- if(!M.density)
- M.close()
- src.add_fingerprint(usr)
- src.updateUsrDialog()
- return
-
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-// new door timer code, mostly taken from status display.
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Brig Door control displays.
+// Description: This is a controls the timer for the brig doors, displays the timer on itself and
+// has a popup window when used, allowing to set the timer.
+// Code Notes: Combination of old brigdoor.dm code from rev4407 and the status_display.dm code
+// Date: 01/September/2010
+// Programmer: Veryinky
+/////////////////////////////////////////////////////////////////////////////////////////////////
/obj/machinery/door_timer
name = "Door Timer"
icon = 'status_display.dmi'
icon_state = "frame"
desc = "A remote control for a door."
req_access = list(access_brig)
- anchored = 1.0 // can't pick it up
- density = 0 // can walk through it.
- var/id = null // id of door it controls.
- var/time = 0.0 // defaults to 0 seconds timer
- var/timing = 0.0 // boolean, true/1 timer is on, false/0 means it's not timing
- var/picture_state // icon_state of alert picture
-
+ anchored = 1.0 // can't pick it up
+ density = 0 // can walk through it.
+ var/id = null // id of door it controls.
+ var/time = 1 // defaults to 0 seconds timer
+ var/timing = 1 // boolean, true/1 timer is on, false/0 means it's not timing
+ var/childproof = 0 // boolean, when activating the door controls, locks door for 1 minute
+ var/picture_state // icon_state of alert picture, if not displaying text/numbers
//Main door timer loop, if it's timing and time is >0 reduce time by 1.
// if it's less than 0, open door, reset timer
@@ -111,21 +29,26 @@
if (src.time > 0)
src.time = round(src.time) - 1
else
- alarm() // open doors
+ src.opendoor() // open doors, reset timer, clear status screen
src.time = 0
src.timing = 0
src.updateDialog()
src.update_icon()
+ else // keep door open may cause lag as it's checking every second if someone closed door
+ for(var/obj/machinery/door/window/brigdoor/M in world)
+ if (M.id == src.id)
+ if(M.density)
+ spawn( 0 )
+ M.open()
return
// has the door power sitatuation changed, if so update icon.
/obj/machinery/door_timer/power_change()
update_icon()
-// alarm() checks if door_timer has power, if so it checks if the
+// open/closedoor checks if door_timer has power, if so it checks if the
// linked door is open/closed (by density) then opens it/closes it.
-// It's also supposed to unlock the secure closets in the brig. TEST THIS
-/obj/machinery/door_timer/proc/alarm()
+/obj/machinery/door_timer/proc/opendoor()
if(stat & (NOPOWER|BROKEN))
return
for(var/obj/machinery/door/window/brigdoor/M in world)
@@ -133,15 +56,23 @@
if(M.density)
spawn( 0 )
M.open()
- for(var/obj/secure_closet/brig/B in world)
- if (B.id == src.id)
- if(B.locked)
- B.locked = 0
- B.icon_state = text("[(B.locked ? "1" : null)]secloset0")
src.updateUsrDialog()
src.update_icon()
return
+/obj/machinery/door_timer/proc/closedoor()
+ if(stat & (NOPOWER|BROKEN))
+ return
+ for(var/obj/machinery/door/window/brigdoor/M in world)
+ if (M.id == src.id)
+ if(!M.density)
+ spawn( 0 )
+ M.close()
+ src.updateUsrDialog()
+ src.update_icon()
+ return
+
+
//Allows AIs to use door_timer, see human attack_hand function below
/obj/machinery/door_timer/attack_ai(var/mob/user as mob)
return src.attack_hand(user)
@@ -157,17 +88,18 @@
/obj/machinery/door_timer/attack_hand(var/mob/user as mob)
if(..())
return
-
var/dat = "Door [src.id] controls"
user.machine = src
var/d2
+ if (!src.timing)
+ update_display("SET","TIME")
if (src.timing)
- d2 = text("Stop Timed
", src)
+ d2 = text("Stop Timer
", src)
else
- d2 = text("Initiate Time
", src)
+ d2 = text("Set Timer
", src)
var/second = src.time % 60
var/minute = (src.time - second) / 60
- dat += text("
\nTimer System: [d2]\nTime Left: [(minute ? text("[minute]:") : null)][second] - - + +")
+ dat += text("
\nTimer System: [d2]\nTime Left: [(minute ? text("[minute]:") : null)][second] - - + +")
for(var/obj/machinery/flasher/F in world)
if(F.id == src.id)
if(F.last_flash && world.time < F.last_flash + 150)
@@ -182,9 +114,8 @@
//Function for using door_timer dialog input, checks if user has permission
// href_list to
// "time" turns on timer
-// "tp" closes door
+// "tp" value to modify timer
// "fc" activates flasher
-
// Also updates dialog window and timer icon
/obj/machinery/door_timer/Topic(href, href_list)
if(..())
@@ -194,17 +125,15 @@
if (href_list["time"])
if(src.allowed(usr))
src.timing = text2num(href_list["time"])
+ src.closedoor()
else
- if (href_list["tp"])
+ if (href_list["tp"]) //adjust timer, close door if not already closed
if(src.allowed(usr))
var/tp = text2num(href_list["tp"])
src.time += tp
src.time = min(max(round(src.time), 0), 600)
- for(var/obj/machinery/door/window/brigdoor/M in world)
- if (M.id == src.id)
- if(!M.density)
- spawn( 0 )
- M.close()
+ src.timing = 1
+ src.closedoor()
if (href_list["fc"])
if(src.allowed(usr))
for (var/obj/machinery/flasher/F in world)
@@ -213,6 +142,8 @@
src.add_fingerprint(usr)
src.updateUsrDialog()
src.update_icon()
+ if (!src.timing) // was a timer set? if not, open door.
+ src.opendoor()
return
//icon update function
@@ -221,8 +152,9 @@
// if timing=true, run update display function
/obj/machinery/door_timer/proc/update_icon()
var/disp1
- oview() << id
- disp1 = "[add_zero(num2text((time / 60) % 60),2)]~[add_zero(num2text(time % 60), 2)]"
+ var/disp2
+ disp1 = uppertext(id)
+ disp2 = "[add_zero(num2text((time / 60) % 60),2)]~[add_zero(num2text(time % 60), 2)]"
if(stat & (NOPOWER))
icon_state = "frame"
return
@@ -233,11 +165,7 @@
else
if(src.timing)
spawn( 5 )
- update_display(id, disp1)
- else
- spawn( 5 )
- update_display(id, null)
-
+ update_display(disp1, disp2)
// Adds an icon in case the screen is broken/off, stolen from status_display.dm
/obj/machinery/door_timer/proc/set_picture(var/state)