diff --git a/code/__defines/_lists.dm b/code/__defines/_lists.dm
index 247e9dfeb0..582c026f3c 100644
--- a/code/__defines/_lists.dm
+++ b/code/__defines/_lists.dm
@@ -39,7 +39,7 @@
#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
// Null-safe L.Cut()
-#define LAZYCLEARLIST(L) if(L) L.Cut()
+#define LAZYCLEARLIST(L) if(L) { L.Cut(); L = null; }
// Reads L or an empty list if L is not a list. Note: Does NOT assign, L may be an expression.
#define SANITIZE_LIST(L) ( islist(L) ? L : list() )
diff --git a/code/controllers/subsystems/supply.dm b/code/controllers/subsystems/supply.dm
index f35ecee703..fc1d3dc6ef 100644
--- a/code/controllers/subsystems/supply.dm
+++ b/code/controllers/subsystems/supply.dm
@@ -200,10 +200,11 @@ SUBSYSTEM_DEF(supply)
else if(islist(SP.access) && SP.one_access)
var/list/L = SP.access // access var is a plain var, we need a list
A.req_one_access = L.Copy()
- A.req_access.Cut()
+ LAZYCLEARLIST(A.req_access)
else if(islist(SP.access) && !SP.one_access)
var/list/L = SP.access
A.req_access = L.Copy()
+ LAZYCLEARLIST(A.req_one_access)
else
log_debug("Supply pack with invalid access restriction [SP.access] encountered!")
diff --git a/code/game/gamemodes/sandbox/h_sandbox.dm b/code/game/gamemodes/sandbox/h_sandbox.dm
index 11f070f2f5..4f476293dd 100644
--- a/code/game/gamemodes/sandbox/h_sandbox.dm
+++ b/code/game/gamemodes/sandbox/h_sandbox.dm
@@ -102,7 +102,7 @@ datum/hSB
var/accesses = get_all_accesses()
for(var/A in accesses)
if(alert(usr, "Will this airlock require [get_access_desc(A)] access?", "Sandbox:", "Yes", "No") == "Yes")
- hsb.req_access += A
+ LAZYADD(hsb.req_access, A)
hsb.loc = usr.loc
to_chat(usr, "Sandbox: Created an airlock.")
diff --git a/code/game/jobs/access.dm b/code/game/jobs/access.dm
index 71809a2b72..d1b13e4628 100644
--- a/code/game/jobs/access.dm
+++ b/code/game/jobs/access.dm
@@ -1,21 +1,9 @@
-//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
-
-/obj/var/list/req_access = list()
-/obj/var/list/req_one_access = list()
+/obj/var/list/req_access
+/obj/var/list/req_one_access
//returns 1 if this mob has sufficient access to use this object
/obj/proc/allowed(mob/M)
- //check if it doesn't require any access at all
- if(src.check_access(null))
- return 1
-
- var/id = M.GetIdCard()
- if(id)
- return check_access(id)
- return 0
-
-///obj/item/proc/GetAccess()
-// return list()
+ return check_access(M?.GetIdCard())
/atom/movable/proc/GetAccess()
var/obj/item/weapon/card/id/id = GetIdCard()
@@ -25,25 +13,36 @@
return null
/obj/proc/check_access(obj/item/I)
- return check_access_list(I ? I.GetAccess() : list())
+ return check_access_list(I ? I.GetAccess() : null)
/obj/proc/check_access_list(var/list/L)
- if(!req_access) req_access = list()
- if(!req_one_access) req_one_access = list()
- if(!L) return 0
- if(!istype(L, /list)) return 0
+ // We don't require access
+ if(!LAZYLEN(req_access) && !LAZYLEN(req_one_access))
+ return TRUE
+
+ // They passed nothing, but we are something that requires access
+ if(!LAZYLEN(L))
+ return FALSE
+
+ // Run list comparisons
return has_access(req_access, req_one_access, L)
/proc/has_access(var/list/req_access, var/list/req_one_access, var/list/accesses)
+ // req_access list has priority if set
+ // Requires at least every access in list
for(var/req in req_access)
- if(!(req in accesses)) //doesn't have this access
- return 0
- if(req_one_access.len)
+ if(!(req in accesses))
+ return FALSE
+
+ // req_one_access is secondary if set
+ // Requires at least one access in list
+ if(LAZYLEN(req_one_access))
for(var/req in req_one_access)
- if(req in accesses) //has an access from the single access list
- return 1
- return 0
- return 1
+ if(req in accesses)
+ return TRUE
+ return FALSE
+
+ return TRUE
/proc/get_centcom_access(job)
switch(job)
diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm
index 64a3cc1fc7..9b14dc68bb 100644
--- a/code/game/machinery/deployable.dm
+++ b/code/game/machinery/deployable.dm
@@ -130,8 +130,8 @@ Deployable items
/obj/machinery/deployable/barrier/emag_act(var/remaining_charges, var/mob/user)
if(emagged == 0)
emagged = 1
- req_access.Cut()
- req_one_access.Cut()
+ LAZYCLEARLIST(req_access)
+ LAZYCLEARLIST(req_one_access)
to_chat(user, "You break the ID authentication lock on \the [src].")
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 1, src)
diff --git a/code/game/machinery/door_control.dm b/code/game/machinery/door_control.dm
index b8f7acd5bf..c74b4fa9a0 100644
--- a/code/game/machinery/door_control.dm
+++ b/code/game/machinery/door_control.dm
@@ -28,9 +28,9 @@
return attack_hand(user)
/obj/machinery/button/remote/emag_act(var/remaining_charges, var/mob/user)
- if(req_access.len || req_one_access.len)
- req_access = list()
- req_one_access = list()
+ if(LAZYLEN(req_access) || LAZYLEN(req_one_access))
+ LAZYCLEARLIST(req_access)
+ LAZYCLEARLIST(req_one_access)
playsound(src, "sparks", 100, 1)
return 1
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index c3b1ba1d95..01ece0eaa9 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -1388,10 +1388,10 @@ About the new airlock wires panel:
//update the door's access to match the electronics'
secured_wires = electronics.secure
if(electronics.one_access)
- req_access.Cut()
+ LAZYCLEARLIST(req_access)
req_one_access = src.electronics.conf_access
else
- req_one_access.Cut()
+ LAZYCLEARLIST(req_one_access)
req_access = src.electronics.conf_access
//get the name from the assembly
@@ -1437,12 +1437,10 @@ About the new airlock wires panel:
src.electronics = new/obj/item/weapon/airlock_electronics( src.loc )
//update the electronics to match the door's access
- if(!src.req_access)
- src.check_access()
- if(src.req_access.len)
- electronics.conf_access = src.req_access
- else if (src.req_one_access.len)
- electronics.conf_access = src.req_one_access
+ if(LAZYLEN(req_access))
+ electronics.conf_access = req_access
+ else if (LAZYLEN(req_one_access))
+ electronics.conf_access = req_one_access
electronics.one_access = 1
/obj/machinery/door/airlock/emp_act(var/severity)
diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm
index cfd0b3706c..a50e54ba75 100644
--- a/code/game/machinery/doors/windowdoor.dm
+++ b/code/game/machinery/doors/windowdoor.dm
@@ -20,7 +20,7 @@
/obj/machinery/door/window/New()
..()
update_nearby_tiles()
- if (src.req_access && src.req_access.len)
+ if(LAZYLEN(req_access))
src.icon_state = "[src.icon_state]"
src.base_state = src.icon_state
return
@@ -38,12 +38,10 @@
var/obj/item/weapon/airlock_electronics/ae
if(!electronics)
ae = new/obj/item/weapon/airlock_electronics( src.loc )
- if(!src.req_access)
- src.check_access()
- if(src.req_access.len)
- ae.conf_access = src.req_access
- else if (src.req_one_access.len)
- ae.conf_access = src.req_one_access
+ if(LAZYLEN(req_access))
+ ae.conf_access = req_access
+ else if (LAZYLEN(req_one_access))
+ ae.conf_access = req_one_access
ae.one_access = 1
else
ae = electronics
@@ -241,12 +239,10 @@
else
if(!electronics)
wa.electronics = new/obj/item/weapon/airlock_electronics()
- if(!src.req_access)
- src.check_access()
- if(src.req_access.len)
- wa.electronics.conf_access = src.req_access
- else if (src.req_one_access.len)
- wa.electronics.conf_access = src.req_one_access
+ if(LAZYLEN(req_access))
+ wa.electronics.conf_access = req_access
+ else if (LAZYLEN(req_one_access))
+ wa.electronics.conf_access = req_one_access
wa.electronics.one_access = 1
else
wa.electronics = electronics
diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm
index 189986d429..b827532da4 100644
--- a/code/modules/clothing/spacesuits/rig/rig.dm
+++ b/code/modules/clothing/spacesuits/rig/rig.dm
@@ -119,7 +119,7 @@
item_state = icon_state
wires = new(src)
- if((!req_access || !req_access.len) && (!req_one_access || !req_one_access.len))
+ if(!LAZYLEN(req_access) && !LAZYLEN(req_one_access))
locked = 0
spark_system = new()
diff --git a/code/modules/clothing/spacesuits/rig/rig_attackby.dm b/code/modules/clothing/spacesuits/rig/rig_attackby.dm
index 67080dd1e0..395484d53a 100644
--- a/code/modules/clothing/spacesuits/rig/rig_attackby.dm
+++ b/code/modules/clothing/spacesuits/rig/rig_attackby.dm
@@ -17,7 +17,7 @@
to_chat(user, "It looks like the locking system has been shorted out.")
return
- if((!req_access || !req_access.len) && (!req_one_access || !req_one_access.len))
+ if(!LAZYLEN(req_access) && !LAZYLEN(req_one_access))
locked = 0
to_chat(user, "\The [src] doesn't seem to have a locking mechanism.")
return
@@ -190,8 +190,8 @@
/obj/item/weapon/rig/emag_act(var/remaining_charges, var/mob/user)
if(!subverted)
- req_access.Cut()
- req_one_access.Cut()
+ LAZYCLEARLIST(req_access)
+ LAZYCLEARLIST(req_one_access)
locked = 0
subverted = 1
to_chat(user, "You short out the access protocol for the suit.")
diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm
index 5e85c0123c..aadafb9b66 100644
--- a/code/modules/customitems/item_spawning.dm
+++ b/code/modules/customitems/item_spawning.dm
@@ -190,7 +190,7 @@
// Check for required access.
var/obj/item/weapon/card/id/current_id = M.wear_id
- if(citem.req_access && citem.req_access > 0)
+ if(citem.req_access && citem.req_access > 0) // These are numbers, not lists
if(!(istype(current_id) && (citem.req_access in current_id.access)))
log_debug("Custom Item: [key_name(M)] Does not have required access.")
continue
diff --git a/code/modules/hydroponics/seed_storage.dm b/code/modules/hydroponics/seed_storage.dm
index 2c26ac8394..66273144b7 100644
--- a/code/modules/hydroponics/seed_storage.dm
+++ b/code/modules/hydroponics/seed_storage.dm
@@ -523,7 +523,7 @@
if(lockdown)
to_chat(user, "\The [src]'s control panel thunks, as its cover retracts.")
lockdown = 0
- if(req_access || req_one_access)
+ if(LAZYLEN(req_access) || LAZYLEN(req_one_access))
req_access = list()
req_one_access = list()
to_chat(user, "\The [src]'s access mechanism shorts out.")