Files
Bubberstation/code/modules/jobs/access.dm
SkyratBot a05f7e863a [MIRROR] Fully implements the ID Card design document (#3729)
* Fully implements the ID Card design document

* Oh fuck that hurt.

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
Co-authored-by: Gandalf2k15 <jzo123@hotmail.com>
2021-03-03 01:54:25 +00:00

120 lines
3.2 KiB
Plaintext

//returns TRUE 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 TRUE
if(issilicon(M))
if(ispAI(M))
return FALSE
return TRUE //AI can do whatever it wants
if(isAdminGhostAI(M))
//Access can't stop the abuse
return TRUE
else if(istype(M) && SEND_SIGNAL(M, COMSIG_MOB_ALLOWED, src))
return TRUE
else if(ishuman(M))
var/mob/living/carbon/human/H = M
//if they are holding or wearing a card that has access, that works
if(check_access(H.get_active_held_item()) || src.check_access(H.wear_id))
return TRUE
else if(isalienadult(M))
var/mob/living/carbon/george = M
//they can only hold things :(
if(check_access(george.get_active_held_item()))
return TRUE
else if(isanimal(M))
var/mob/living/simple_animal/A = M
if(check_access(A.get_active_held_item()) || check_access(A.access_card))
return TRUE
return FALSE
/obj/item/proc/GetAccess()
return list()
/obj/item/proc/GetID()
return null
/obj/item/proc/RemoveID()
return null
/obj/item/proc/InsertID()
return FALSE
/obj/proc/text2access(access_text)
. = list()
if(!access_text)
return
var/list/split = splittext(access_text,";")
for(var/x in split)
var/n = text2num(x)
if(n)
. += n
//Call this before using req_access or req_one_access directly
/obj/proc/gen_access()
//These generations have been moved out of /obj/New() because they were slowing down the creation of objects that never even used the access system.
if(!req_access)
req_access = list()
for(var/a in text2access(req_access_txt))
req_access += a
if(!req_one_access)
req_one_access = list()
for(var/b in text2access(req_one_access_txt))
req_one_access += b
// Check if an item has access to this object
/obj/proc/check_access(obj/item/I)
return check_access_list(I ? I.GetAccess() : null)
/obj/proc/check_access_list(list/access_list)
gen_access()
if(!islist(req_access)) //something's very wrong
return TRUE
if(!req_access.len && !length(req_one_access))
return TRUE
if(!length(access_list) || !islist(access_list))
return FALSE
for(var/req in req_access)
if(!(req in access_list)) //doesn't have this access
return FALSE
if(length(req_one_access))
for(var/req in req_one_access)
if(req in access_list) //has an access from the single access list
return TRUE
return FALSE
return TRUE
/*
* Checks if this packet can access this device
*
* Normally just checks the access list however you can override it for
* hacking proposes or if wires are cut
*
* Arguments:
* * passkey - passkey from the datum/netdata packet
*/
/obj/proc/check_access_ntnet(list/passkey)
return check_access_list(passkey)
/obj/item/proc/GetJobName() //Used in secHUD icon generation
var/obj/item/card/id/id_card = GetID()
if(!id_card)
return
var/card_assignment = id_card.trim?.assignment
if(!card_assignment)
card_assignment = id_card.assignment
if(card_assignment in (SSjob.station_jobs + SSjob.additional_jobs_with_icons)) //Check if the job has a hud icon
return card_assignment
if(card_assignment in SSjob.centcom_jobs) //Return with the NT logo if it is a CentCom job
return "CentCom"
return "Unknown" //Return unknown if none of the above apply