From 4efacff9fae61cd7b584684bc343bf4a501229bb Mon Sep 17 00:00:00 2001 From: san7890 Date: Sun, 1 Jan 2023 06:52:02 -0700 Subject: [PATCH] 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. --- _maps/map_files/MetaStation/MetaStation.dmm | 6 ++--- .../maintenance_upperbridgeright_1.dmm | 2 +- .../maintenance_upperbridgeright_2.dmm | 2 +- code/game/machinery/buttons.dm | 4 +-- code/game/machinery/doors/airlock.dm | 1 - code/game/machinery/doors/airlock_types.dm | 2 +- code/game/objects/objs.dm | 7 +++-- .../structures/crates_lockers/closets.dm | 1 - code/modules/jobs/access.dm | 24 ----------------- code/modules/vending/_vending.dm | 27 ++++--------------- code/modules/vending/snack.dm | 2 +- .../wiremod/components/id/access_checker.dm | 4 --- 12 files changed, 19 insertions(+), 63 deletions(-) diff --git a/_maps/map_files/MetaStation/MetaStation.dmm b/_maps/map_files/MetaStation/MetaStation.dmm index 6e2d0f76424..fc6add0976e 100644 --- a/_maps/map_files/MetaStation/MetaStation.dmm +++ b/_maps/map_files/MetaStation/MetaStation.dmm @@ -46455,7 +46455,7 @@ /obj/machinery/door/window/right/directional/south{ dir = 8; name = "Jim Norton's Quebecois Coffee"; - req_one_access_txt = list("service","maint_tunnels") + req_one_access = list("service","maint_tunnels") }, /obj/effect/turf_decal/trimline/green/line, /turf/open/floor/iron/dark, @@ -50123,7 +50123,7 @@ /obj/machinery/button/door{ id = "ordnancebridge"; pixel_x = -24; - req_one_access_txt = list("maint_tunnels","science") + req_one_access = list("maint_tunnels","science") }, /obj/effect/turf_decal/caution/stand_clear{ dir = 1 @@ -50356,7 +50356,7 @@ /obj/machinery/button/door{ id = "ordnancebridge"; pixel_y = 24; - req_one_access_txt = list("maint_tunnels","science") + req_one_access = list("maint_tunnels","science") }, /obj/effect/turf_decal/caution/stand_clear{ dir = 4 diff --git a/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_1.dmm b/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_1.dmm index b26826a8a91..351cdddeccf 100644 --- a/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_1.dmm +++ b/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_1.dmm @@ -44,7 +44,7 @@ /obj/effect/turf_decal/delivery/red, /obj/item/key/security, /obj/machinery/door/window/left/directional/north{ - req_access_txt = "security"; + req_access = list("security"); name = "Secway Storage" }, /turf/open/floor/iron/smooth, diff --git a/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_2.dmm b/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_2.dmm index f845fae10d9..7bed8217832 100644 --- a/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_2.dmm +++ b/_maps/map_files/tramstation/modular_pieces/maintenance_upperbridgeright_2.dmm @@ -352,7 +352,7 @@ /obj/item/key/security, /obj/machinery/door/window/left/directional/north{ name = "Secway Storage"; - req_access_txt = "security" + req_access = list("security") }, /turf/open/floor/iron/smooth, /area/station/maintenance/department/security) diff --git a/code/game/machinery/buttons.dm b/code/game/machinery/buttons.dm index 004222a0ee5..c219c4814c6 100644 --- a/code/game/machinery/buttons.dm +++ b/code/game/machinery/buttons.dm @@ -39,9 +39,9 @@ src.check_access(null) - if(req_access.len || req_one_access.len) + if(length(req_access) || length(req_one_access)) board = new(src) - if(req_access.len) + if(length(req_access)) board.accesses = req_access else board.one_access = 1 diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index b30f8c38cae..458f65622d7 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -1364,7 +1364,6 @@ var/obj/item/electronics/airlock/ae if(!electronics) ae = new/obj/item/electronics/airlock(loc) - gen_access() if(length(req_one_access)) ae.one_access = 1 ae.accesses = req_one_access diff --git a/code/game/machinery/doors/airlock_types.dm b/code/game/machinery/doors/airlock_types.dm index 1b60b2539bf..618bc71cfa7 100644 --- a/code/game/machinery/doors/airlock_types.dm +++ b/code/game/machinery/doors/airlock_types.dm @@ -335,7 +335,7 @@ /obj/machinery/door/airlock/external/Initialize(mapload, ...) // default setting is for mapping only, let overrides work - if(!mapload || req_access_txt || req_one_access_txt) + if(!mapload) req_access = null return ..() diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index e6a4f8ceab7..78a08c351e7 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -28,10 +28,13 @@ var/infinite_reskin = FALSE // Access levels, used in modules\jobs\access.dm + /// List of accesses needed to use this object: The user must possess all accesses in this list in order to use the object. + /// Example: If req_access = list(ACCESS_ENGINE, ACCESS_CE)- then the user must have both ACCESS_ENGINE and ACCESS_CE in order to use the object. var/list/req_access - var/req_access_txt = "0" + /// List of accesses needed to use this object: The user must possess at least one access in this list in order to use the object. + /// Example: If req_one_access = list(ACCESS_ENGINE, ACCESS_CE)- then the user must have either ACCESS_ENGINE or ACCESS_CE in order to use the object. var/list/req_one_access - var/req_one_access_txt = "0" + /// Custom fire overlay icon var/custom_fire_overlay diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 092ad7726ba..563e475ef5c 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -490,7 +490,6 @@ var/obj/item/electronics/airlock/electronics_ref if (!electronics) electronics_ref = new /obj/item/electronics/airlock(loc) - gen_access() if (req_one_access.len) electronics_ref.one_access = 1 electronics_ref.accesses = req_one_access diff --git a/code/modules/jobs/access.dm b/code/modules/jobs/access.dm index 42837d56d0c..53d0dd58754 100644 --- a/code/modules/jobs/access.dm +++ b/code/modules/jobs/access.dm @@ -53,35 +53,11 @@ /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 diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index a101451ac50..605b2887070 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -169,10 +169,6 @@ ///A variable to change on a per instance basis on the map that allows the instance to force cost and ID requirements var/onstation_override = FALSE //change this on the object on the map to override the onstation check. DO NOT APPLY THIS GLOBALLY. - ///ID's that can load this vending machine wtih refills - var/list/canload_access_list - - var/list/vending_machine_input = list() ///Display header on the input view var/input_display_header = "Custom Vendor" @@ -806,30 +802,17 @@ . = ..() /** - * Is the passed in user allowed to load this vending machines compartments + * Is the passed in user allowed to load this vending machines compartments? This only is ran if we are using a /obj/item/storage/bag to load the vending machine, and not a dedicated restocker. * * Arguments: * * user - mob that is doing the loading of the vending machine */ /obj/machinery/vending/proc/compartmentLoadAccessCheck(mob/user) - if(!canload_access_list) + if(!req_access || allowed(user) || (obj_flags & EMAGGED) || !scan_id) return TRUE - else - var/do_you_have_access = FALSE - var/req_access_txt_holder = req_access_txt - for(var/i in canload_access_list) - req_access_txt = i - if(!allowed(user) && !(obj_flags & EMAGGED) && scan_id) - continue - else - do_you_have_access = TRUE - break //you passed don't bother looping anymore - req_access_txt = req_access_txt_holder // revert to normal (before the proc ran) - if(do_you_have_access) - return TRUE - else - to_chat(user, span_warning("[src]'s input compartment blinks red: Access denied.")) - return FALSE + + to_chat(user, span_warning("[src]'s input compartment blinks red: Access denied.")) + return FALSE /obj/machinery/vending/exchange_parts(mob/user, obj/item/storage/part_replacer/W) if(!istype(W)) diff --git a/code/modules/vending/snack.dm b/code/modules/vending/snack.dm index 251afbce76b..22d17761bf1 100644 --- a/code/modules/vending/snack.dm +++ b/code/modules/vending/snack.dm @@ -35,7 +35,7 @@ /obj/item/food/pistachios = 3, ) refill_canister = /obj/item/vending_refill/snack - canload_access_list = list(ACCESS_KITCHEN) + req_access = list(ACCESS_KITCHEN) default_price = PAYCHECK_CREW * 0.6 extra_price = PAYCHECK_CREW payment_department = ACCOUNT_SRV diff --git a/code/modules/wiremod/components/id/access_checker.dm b/code/modules/wiremod/components/id/access_checker.dm index f578bfd1575..038f4078ecb 100644 --- a/code/modules/wiremod/components/id/access_checker.dm +++ b/code/modules/wiremod/components/id/access_checker.dm @@ -16,10 +16,6 @@ "id-card" = "access", ) -/obj/item/circuit_component/compare/access/Initialize(mapload) - . = ..() - gen_access() - /obj/item/circuit_component/compare/access/get_ui_notices() . = ..() . += create_ui_notice("When \"Check Any\" is true, returns true if \"Access To Check\" contains ANY value in \"Required Access\".", "orange", "info")