From e39b509cd894e463c8c63a51fea5502e4325300c Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Mon, 17 Jan 2022 01:02:26 +0100
Subject: [PATCH] [MIRROR] Safe code documentation [MDB IGNORE] (#10758)
* Safe code documentation (#64096)
Adds better documentation and variable naming to safe code. Also removed one variable that hasn't done anything in years.
* Safe code documentation
Co-authored-by: dragomagol <66640614+dragomagol@users.noreply.github.com>
---
code/game/objects/items/storage/secure.dm | 113 +++++++++---------
.../mission_code/stationCollision.dm | 7 +-
2 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/code/game/objects/items/storage/secure.dm b/code/game/objects/items/storage/secure.dm
index 852ba4b72ff..4a9bba6ea12 100644
--- a/code/game/objects/items/storage/secure.dm
+++ b/code/game/objects/items/storage/secure.dm
@@ -7,23 +7,31 @@
* Wall Safe
*/
-// -----------------------------
-// Generic Item
-// -----------------------------
+///Generic Safe
/obj/item/storage/secure
name = "secstorage"
- var/icon_locking = "secureb"
- var/icon_sparking = "securespark"
- var/icon_opened = "secure0"
- var/code = ""
- var/l_code = null
- var/l_set = FALSE
- var/l_setshort = FALSE
- var/l_hacking = FALSE
- var/open = FALSE
- var/can_hack_open = TRUE
- w_class = WEIGHT_CLASS_NORMAL
desc = "This shouldn't exist. If it does, create an issue report."
+ w_class = WEIGHT_CLASS_NORMAL
+
+ /// icon_state of locked safe
+ var/icon_locking = "secureb"
+ /// icon_state of sparking safe
+ var/icon_sparking = "securespark"
+ /// icon_state of opened safe
+ var/icon_opened = "secure0"
+ /// The code entered by the user
+ var/entered_code
+ /// The code that will open this safe
+ var/lock_code
+ /// Does this lock have a code set?
+ var/lock_set = FALSE
+ /// Is this lock currently being hacked?
+ var/lock_hacking = FALSE
+ /// Is the safe service panel open?
+ var/panel_open = FALSE
+ /// Is this door hackable?
+ var/can_hack_open = TRUE
+
/obj/item/storage/secure/ComponentInitialize()
. = ..()
@@ -34,30 +42,30 @@
/obj/item/storage/secure/examine(mob/user)
. = ..()
if(can_hack_open)
- . += "The service panel is currently [open ? "unscrewed" : "screwed shut"]."
+ . += "The service panel is currently [panel_open ? "unscrewed" : "screwed shut"]."
-/obj/item/storage/secure/attackby(obj/item/W, mob/user, params)
+/obj/item/storage/secure/attackby(obj/item/weapon, mob/user, params)
if(can_hack_open && SEND_SIGNAL(src, COMSIG_IS_STORAGE_LOCKED))
- if (W.tool_behaviour == TOOL_SCREWDRIVER)
- if (W.use_tool(src, user, 20))
- open = !open
- to_chat(user, span_notice("You [open ? "open" : "close"] the service panel."))
+ if (weapon.tool_behaviour == TOOL_SCREWDRIVER)
+ if (weapon.use_tool(src, user, 20))
+ panel_open = !panel_open
+ to_chat(user, span_notice("You [panel_open ? "open" : "close"] the service panel."))
return
- if (W.tool_behaviour == TOOL_WIRECUTTER)
+ if (weapon.tool_behaviour == TOOL_WIRECUTTER)
to_chat(user, span_danger("[src] is protected from this sort of tampering, yet it appears the internal memory wires can still be pulsed."))
return
- if (W.tool_behaviour == TOOL_MULTITOOL)
- if(l_hacking)
+ if (weapon.tool_behaviour == TOOL_MULTITOOL)
+ if(lock_hacking)
to_chat(user, span_danger("This safe is already being hacked."))
return
- if(open == TRUE)
+ if(panel_open == TRUE)
to_chat(user, span_danger("Now attempting to reset internal memory, please hold."))
- l_hacking = TRUE
- if (W.use_tool(src, user, 400))
+ lock_hacking = TRUE
+ if (weapon.use_tool(src, user, 400))
to_chat(user, span_danger("Internal memory reset - lock has been disengaged."))
- l_set = FALSE
+ lock_set = FALSE
- l_hacking = FALSE
+ lock_hacking = FALSE
return
to_chat(user, span_warning("You must unscrew the service panel before you can pulse the wiring!"))
@@ -71,11 +79,9 @@
user.set_machine(src)
var/dat = text("[]
\n\nLock Status: []",src, (locked ? "LOCKED" : "UNLOCKED"))
var/message = "Code"
- if ((l_set == 0) && (!l_setshort))
+ if (lock_set == 0)
dat += text("
\n5-DIGIT PASSCODE NOT SET.
ENTER NEW PASSCODE.")
- if (l_setshort)
- dat += text("
\nALERT: MEMORY SYSTEM ERROR - 6040 201") - message = text("[]", code) + message = text("[]", entered_code) if (!locked) message = "*****" dat += text("