diff --git a/code/__defines/_lists.dm b/code/__defines/_lists.dm index 247e9dfeb0e..582c026f3c8 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 c55208d7dfe..47a0e0e7bd4 100644 --- a/code/controllers/subsystems/supply.dm +++ b/code/controllers/subsystems/supply.dm @@ -205,11 +205,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 = null + LAZYCLEARLIST(A.req_access) else if(islist(SP.access) && !SP.one_access) var/list/L = SP.access A.req_access = L.Copy() - A.req_one_access = null + LAZYCLEARLIST(A.req_one_access) else log_debug("Supply pack with invalid access restriction [SP.access] encountered!") diff --git a/code/game/jobs/access.dm b/code/game/jobs/access.dm index b7b1ab3aed5..e53fa62935b 100644 --- a/code/game/jobs/access.dm +++ b/code/game/jobs/access.dm @@ -28,32 +28,21 @@ return has_access(req_access, req_one_access, L) /proc/has_access(var/list/req_access, var/list/req_one_access, var/list/accesses) - // Doesn't have access lists, always works - if(!LAZYLEN(req_access) && !LAZYLEN(req_one_access)) - return TRUE - - // Didn't pass anything to compare - if(!LAZYLEN(accesses)) - return FALSE - // req_access list has priority if set // Requires at least every access in list - if(LAZYLEN(req_access)) - for(var/req in req_access) - if(!(req in accesses)) - return FALSE - // Wasn't missing any accesses - return TRUE + for(var/req in req_access) + if(!(req in accesses)) + return FALSE // req_one_access is secondary if set // Requires at least one access in list - for(var/req in req_one_access) - if(req in accesses) - // Found at least one - return TRUE + if(LAZYLEN(req_one_access)) + for(var/req in req_one_access) + if(req in accesses) + return TRUE + return FALSE - // Didn't find anything that matched - return FALSE + return TRUE /proc/get_centcom_access(job) switch(job)