mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
[MIRROR] Make req_[one_]access lazy
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
|
#define LAZYACCESSASSOC(L, I, K) L ? L[I] ? L[I][K] ? L[I][K] : null : null : null
|
||||||
|
|
||||||
// Null-safe L.Cut()
|
// 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.
|
// 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() )
|
#define SANITIZE_LIST(L) ( islist(L) ? L : list() )
|
||||||
|
|||||||
@@ -205,13 +205,19 @@ SUBSYSTEM_DEF(supply)
|
|||||||
else if(islist(SP.access) && SP.one_access)
|
else if(islist(SP.access) && SP.one_access)
|
||||||
var/list/L = SP.access // access var is a plain var, we need a list
|
var/list/L = SP.access // access var is a plain var, we need a list
|
||||||
A.req_one_access = L.Copy()
|
A.req_one_access = L.Copy()
|
||||||
|
<<<<<<< HEAD
|
||||||
if(A.req_access) //Chompstation Edit (TODO: Figure out why the fuck this works for others but not us)
|
if(A.req_access) //Chompstation Edit (TODO: Figure out why the fuck this works for others but not us)
|
||||||
A.req_access.Cut() //Chompstation Edit
|
A.req_access.Cut() //Chompstation Edit
|
||||||
A.req_access = null
|
A.req_access = null
|
||||||
|
||||||| parent of 8973063282... Merge pull request #10640 from VOREStation/upstream-merge-8122
|
||||||
|
A.req_access = null
|
||||||
|
=======
|
||||||
|
LAZYCLEARLIST(A.req_access)
|
||||||
|
>>>>>>> 8973063282... Merge pull request #10640 from VOREStation/upstream-merge-8122
|
||||||
else if(islist(SP.access) && !SP.one_access)
|
else if(islist(SP.access) && !SP.one_access)
|
||||||
var/list/L = SP.access
|
var/list/L = SP.access
|
||||||
A.req_access = L.Copy()
|
A.req_access = L.Copy()
|
||||||
A.req_one_access = null
|
LAZYCLEARLIST(A.req_one_access)
|
||||||
else
|
else
|
||||||
log_debug("<span class='danger'>Supply pack with invalid access restriction [SP.access] encountered!</span>")
|
log_debug("<span class='danger'>Supply pack with invalid access restriction [SP.access] encountered!</span>")
|
||||||
|
|
||||||
|
|||||||
@@ -28,33 +28,22 @@
|
|||||||
return has_access(req_access, req_one_access, L)
|
return has_access(req_access, req_one_access, L)
|
||||||
|
|
||||||
/proc/has_access(var/list/req_access, var/list/req_one_access, var/list/accesses)
|
/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
|
// req_access list has priority if set
|
||||||
// Requires at least every access in list
|
// Requires at least every access in list
|
||||||
if(LAZYLEN(req_access))
|
|
||||||
for(var/req in req_access)
|
for(var/req in req_access)
|
||||||
if(!(req in accesses))
|
if(!(req in accesses))
|
||||||
return FALSE
|
return FALSE
|
||||||
// Wasn't missing any accesses
|
|
||||||
return TRUE
|
|
||||||
|
|
||||||
// req_one_access is secondary if set
|
// req_one_access is secondary if set
|
||||||
// Requires at least one access in list
|
// Requires at least one access in list
|
||||||
|
if(LAZYLEN(req_one_access))
|
||||||
for(var/req in req_one_access)
|
for(var/req in req_one_access)
|
||||||
if(req in accesses)
|
if(req in accesses)
|
||||||
// Found at least one
|
|
||||||
return TRUE
|
return TRUE
|
||||||
|
|
||||||
// Didn't find anything that matched
|
|
||||||
return FALSE
|
return FALSE
|
||||||
|
|
||||||
|
return TRUE
|
||||||
|
|
||||||
/proc/get_centcom_access(job)
|
/proc/get_centcom_access(job)
|
||||||
switch(job)
|
switch(job)
|
||||||
if("VIP Guest")
|
if("VIP Guest")
|
||||||
|
|||||||
Reference in New Issue
Block a user