Files
Bubberstation/code/modules/jobs/access.dm
SkyratBot 5a18ff0bbb [MIRROR] Completely Culls req_access_txt/req_one_access_txt [MDB IGNORE] (#18458)
* Completely Culls req_access_txt/req_one_access_txt (#72281)

Hey there,

Now that every instance of `req_access` and `req_one_access` is a list
of strings, there is absolutely no reason for
req_access_txt/req_access_one_txt to exist. In fact, any instance where
they were still used in the codebase was very convoluted and was very
broken! Don't worry, I fixed it all out, and life is good.

I also dmdoc the surviving access variables, because those were missing.
I went on the side of caution and made a more verbose documentation with
an example just to have people really grasp this (it took me a while to
actually get it)

I believe that we changed _everything_ over to the
req_access/req_one_access system earlier this year in VV, but the
problem is that _new mappers don't understand the difference between the
two systems_. In fact, the "txt" system is completely redundant since
all it does is transition stuff to the "base" system. So, let's just
completely cull the one that's all but deprecated and ensure this
confusion no longer arises. The whole purpose of "txt" seemed to be to
convert the access, but it's all pointless now that we can just read the
list directly.

I'm also 99% certain that the "access check" on vending machines broke
(and didn't seem to have correct logic in the first place? I
legitimately couldn't find a case where it could fail in testing, so I
changed that up), and that's fixed up now. Let me know if I was clueless
there. I know it's short-circuiting now as opposed to "all must be
true", but it just didn't work.

* Completely Culls req_access_txt/req_one_access_txt

* oh the misery

* makes them use the thing that actually works

* test to see if engineering access is breaking it

* Revert "test to see if engineering access is breaking it"

This reverts commit 3cc2c554ff18f435a51601782e64c76193298db7.

* Fix access checks when req_access is null (#72458)

## About The Pull Request
Fixes #72450 - This seems to be an oversight in some of the access
refactors we've been through recently. When there was an assumption in
`check_access_list()` that `req_access` would always be a list, and that
if it was not something terrible had gone wrong and the door should
default to public access.

With the cleanup of the _txt access vars and the introduction of mapping
access helpers, this assumption is no longer true. `req_access` will be
null when multiple helpers are painted onto the same door, so we need to
handle that properly. Thanks to @MrMelbert for spitting out the attached
fix in mapping general and letting me PR it after testing.

This really needs a suite of unit tests around it. San has helpfully
volunteered to work on that for three hours before getting frustrated.

## Why It's Good For The Game
No more public access to engineering lobby, lathe, etc.


## Changelog
🆑 Vire, MrMelbert
fix: The engineering lobby and lathe are no longer public access
fix: Doors will no longer be treated as public access when they have
multiple accesses set on them
/🆑

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Paxilmaniac <paxilmaniac@gmail.com>
Co-authored-by: Vire <66576896+Maurukas@users.noreply.github.com>
Co-authored-by: Tastyfish <crazychris32@gmail.com>
2023-01-12 11:43:52 -05:00

99 lines
3.3 KiB
Plaintext

//returns TRUE if this mob has sufficient access to use this object
/obj/proc/allowed(mob/accessor)
var/result_bitflags = SEND_SIGNAL(src, COMSIG_OBJ_ALLOWED, accessor)
if(result_bitflags & COMPONENT_OBJ_ALLOW)
return TRUE
if(result_bitflags & COMPONENT_OBJ_DISALLOW) // override all other checks
return FALSE
//check if it doesn't require any access at all
if(check_access(null))
return TRUE
if(!istype(accessor)) //likely a TK user.
return FALSE
if(issilicon(accessor))
if(ispAI(accessor))
return FALSE
if(!(ROLE_SYNDICATE in accessor.faction))
if((ACCESS_SYNDICATE in req_access) || (ACCESS_SYNDICATE_LEADER in req_access) || (ACCESS_SYNDICATE in req_one_access) || (ACCESS_SYNDICATE_LEADER in req_one_access))
return FALSE
if(onSyndieBase() && loc != accessor)
return FALSE
return TRUE //AI can do whatever it wants
if(isAdminGhostAI(accessor))
//Access can't stop the abuse
return TRUE
//If the mob has the simple_access component with the requried access, we let them in.
else if(SEND_SIGNAL(accessor, COMSIG_MOB_TRIED_ACCESS, src) & ACCESS_ALLOWED)
return TRUE
//If the mob is holding a valid ID, we let them in. get_active_held_item() is on the mob level, so no need to copypasta everywhere.
else if(check_access(accessor.get_active_held_item()))
return TRUE
//if they are wearing a card that has access, that works
else if(ishuman(accessor))
var/mob/living/carbon/human/human_accessor = accessor
if(check_access(human_accessor.wear_id))
return TRUE
//if they have a hacky abstract animal ID with the required access, let them in i guess...
else if(isanimal(accessor))
var/mob/living/simple_animal/animal = accessor
if(check_access(animal.access_card))
return TRUE
else if(isbrain(accessor) && istype(accessor.loc, /obj/item/mmi))
var/obj/item/mmi/brain_mmi = accessor.loc
if(ismecha(brain_mmi.loc))
var/obj/vehicle/sealed/mecha/big_stompy_robot = brain_mmi.loc
return check_access_list(big_stompy_robot.operation_req_access)
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
// 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)
if(!length(req_access) && !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)
/// Returns the SecHUD job icon state for whatever this object's ID card is, if it has one.
/obj/item/proc/get_sechud_job_icon_state()
var/obj/item/card/id/id_card = GetID()
return id_card?.get_trim_sechud_icon_state() || SECHUD_NO_ID