From aedc5bae7a53c85544004b0c2077e88234152d9d Mon Sep 17 00:00:00 2001 From: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:16:22 -0500 Subject: [PATCH] `allowed` is now signals based instead of hardcoded slots (#94871) ## About The Pull Request ID cards/MMI mech access/simple mob access/pAIs now use signals instead of checking specific slots with mob checks. We do this through mob's ``get_access`` proc that collects all access a mob has with a collect_access signal. ## Why It's Good For The Game It looks cleaner and we no longer individually check `check_access` for every single item that may have access. It's cleaner to put it all together and check in one go with all the access we've got. This also makes it easier to add items that hold access that aren't necessarily IDs but you want to be able to open stuff with. ## Changelog :cl: refactor: ID checking for access has been reworked, please make a bug report if anything that's supposed to grant access is not working. /:cl: --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- .../signals/signals_mob/signals_mob_main.dm | 3 +- code/__DEFINES/dcs/signals/signals_object.dm | 5 --- code/datums/components/simple_access.dm | 13 +------ code/datums/elements/mob_access.dm | 25 ------------ code/game/machinery/defibrillator_mount.dm | 21 +++++----- code/game/objects/items/cards_ids.dm | 20 ++++++++-- .../food_and_drinks/restaurant/_venue.dm | 5 +-- code/modules/jobs/access.dm | 39 +++++-------------- code/modules/mob/living/basic/bots/_bots.dm | 7 ++-- .../mob/living/basic/minebots/minebot.dm | 2 +- .../mob/living/basic/pets/dog/corgi.dm | 8 ++-- code/modules/mob/living/living.dm | 6 +-- .../mob/living/simple_animal/bot/bot.dm | 9 +++++ .../mob/living/simple_animal/simple_animal.dm | 10 ----- code/modules/mob/mob.dm | 6 +++ .../file_system/programs/budgetordering.dm | 5 +-- code/modules/pai/pai.dm | 6 +++ code/modules/vehicles/mecha/mecha_helpers.dm | 5 +++ .../vehicles/mecha/mecha_mob_interaction.dm | 3 +- code/modules/wiremod/shell/airlock.dm | 8 ++-- tgstation.dme | 1 - 21 files changed, 82 insertions(+), 125 deletions(-) delete mode 100644 code/datums/elements/mob_access.dm diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm index 8b710d030f3..33b09d02b64 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm @@ -90,8 +90,7 @@ #define ACCESS_DISALLOWED (1<<1) #define LOCKED_ATOM_INCOMPATIBLE (1<<2) -///from the component /datum/component/simple_access -#define COMSIG_MOB_RETRIEVE_SIMPLE_ACCESS "retrieve_simple_access" +#define COMSIG_MOB_RETRIEVE_ACCESS "retrieve_access" ///from base of mob/can_cast_magic(): (mob/user, magic_flags, charge_cost) #define COMSIG_MOB_RESTRICT_MAGIC "mob_cast_magic" diff --git a/code/__DEFINES/dcs/signals/signals_object.dm b/code/__DEFINES/dcs/signals/signals_object.dm index a1c6bf38075..0da9c83b588 100644 --- a/code/__DEFINES/dcs/signals/signals_object.dm +++ b/code/__DEFINES/dcs/signals/signals_object.dm @@ -98,11 +98,6 @@ #define COMSIG_FIREALARM_ON_RESET "firealarm_reset" // /obj access signals - -#define COMSIG_OBJ_ALLOWED "door_try_to_activate" - #define COMPONENT_OBJ_ALLOW (1<<0) - #define COMPONENT_OBJ_DISALLOW (1<<1) - #define COMSIG_AIRLOCK_SHELL_ALLOWED "airlock_shell_try_allowed" // /obj/machinery/door/airlock signals diff --git a/code/datums/components/simple_access.dm b/code/datums/components/simple_access.dm index 3038b353290..19fe4adc826 100644 --- a/code/datums/components/simple_access.dm +++ b/code/datums/components/simple_access.dm @@ -9,8 +9,7 @@ if(!ismob(parent)) return COMPONENT_INCOMPATIBLE access = new_access - RegisterSignal(parent, COMSIG_MOB_TRIED_ACCESS, PROC_REF(on_tried_access)) - RegisterSignal(parent, COMSIG_MOB_RETRIEVE_SIMPLE_ACCESS, PROC_REF(retrieve_access)) + RegisterSignal(parent, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) if(!donor_atom) return if(isorgan(donor_atom)) @@ -19,16 +18,6 @@ RegisterSignal(donor_atom, COMSIG_IMPLANT_REMOVED, PROC_REF(on_donor_removed)) RegisterSignal(donor_atom, COMSIG_QDELETING, PROC_REF(on_donor_removed)) -/datum/component/simple_access/proc/on_tried_access(datum/source, atom/locked_thing) - SIGNAL_HANDLER - if(!isobj(locked_thing)) - return LOCKED_ATOM_INCOMPATIBLE - var/obj/locked_object = locked_thing - if(locked_object.check_access_list(access)) - return ACCESS_ALLOWED - else - return ACCESS_DISALLOWED - /datum/component/simple_access/proc/retrieve_access(datum/source, list/access_list) SIGNAL_HANDLER access_list += access diff --git a/code/datums/elements/mob_access.dm b/code/datums/elements/mob_access.dm deleted file mode 100644 index b93dd043fcb..00000000000 --- a/code/datums/elements/mob_access.dm +++ /dev/null @@ -1,25 +0,0 @@ -///element given to mobs that have levels of access -/datum/element/mob_access - element_flags = ELEMENT_BESPOKE - argument_hash_start_idx = 2 - /// What can this mob access? - var/list/my_access - -/datum/element/mob_access/Attach(datum/target, list/accesses) - . = ..() - if(!isliving(target)) - return ELEMENT_INCOMPATIBLE - if(!length(accesses)) - stack_trace("attempted to assign an empty access list to a mob!") - return - my_access = accesses - RegisterSignal(target, COMSIG_MOB_TRIED_ACCESS, PROC_REF(attempt_access)) - -/datum/element/mob_access/proc/attempt_access(datum/source, obj/door_attempt) - SIGNAL_HANDLER - - return (door_attempt.check_access_list(my_access)) ? ACCESS_ALLOWED : ACCESS_DISALLOWED - -/datum/element/mob_access/Detach(datum/source, ...) - UnregisterSignal(source, COMSIG_MOB_TRIED_ACCESS) - return ..() diff --git a/code/game/machinery/defibrillator_mount.dm b/code/game/machinery/defibrillator_mount.dm index d5ca3b4f766..eb871480c2e 100644 --- a/code/game/machinery/defibrillator_mount.dm +++ b/code/game/machinery/defibrillator_mount.dm @@ -108,19 +108,16 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/defibrillator_mount, 28) else if(defib && item == defib.paddles) defib.paddles.snap_back() return - var/obj/item/card/id = item.GetID() - if(id) - if(check_access(id) || SSsecurity_level.get_current_level_as_number() >= SEC_LEVEL_RED) //anyone can toggle the clamps in red alert! - if(!defib) - to_chat(user, span_warning("You can't engage the clamps on a defibrillator that isn't there.")) - return - clamps_locked = !clamps_locked - to_chat(user, span_notice("Clamps [clamps_locked ? "" : "dis"]engaged.")) - update_appearance() - else - to_chat(user, span_warning("Insufficient access.")) + + if(!item.GetID() || (!allowed(user) && SSsecurity_level.get_current_level_as_number() < SEC_LEVEL_RED)) //anyone can toggle the clamps in red alert! + to_chat(user, span_warning("Insufficient access.")) return - ..() + if(!defib) + to_chat(user, span_warning("You can't engage the clamps on a defibrillator that isn't there.")) + return + clamps_locked = !clamps_locked + to_chat(user, span_notice("Clamps [clamps_locked ? "" : "dis"]engaged.")) + update_appearance() /obj/machinery/defibrillator_mount/multitool_act(mob/living/user, obj/item/multitool) ..() diff --git a/code/game/objects/items/cards_ids.dm b/code/game/objects/items/cards_ids.dm index 62cccd38aba..a1d173dadfe 100644 --- a/code/game/objects/items/cards_ids.dm +++ b/code/game/objects/items/cards_ids.dm @@ -174,7 +174,7 @@ if (isitem(old_loc)) UnregisterSignal(old_loc, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)) if (ismob(old_loc.loc)) - UnregisterSignal(old_loc.loc, COMSIG_MOVABLE_POINTED) + UnregisterSignal(old_loc.loc, list(COMSIG_MOVABLE_POINTED, COMSIG_MOB_RETRIEVE_ACCESS)) . = ..() if (isitem(loc)) RegisterSignal(loc, COMSIG_ITEM_EQUIPPED, PROC_REF(on_loc_equipped)) @@ -184,9 +184,14 @@ . = ..() if (slot & ITEM_SLOT_ID) RegisterSignal(user, COMSIG_MOVABLE_POINTED, PROC_REF(on_pointed)) + if (slot & (ITEM_SLOT_ID|ITEM_SLOT_HANDS)) + RegisterSignal(user, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) + if (slot & ITEM_SLOT_POCKETS) + //putting it in your pocket doesn't let you use it as access. + UnregisterSignal(user, COMSIG_MOB_RETRIEVE_ACCESS) /obj/item/card/id/dropped(mob/user) - UnregisterSignal(user, COMSIG_MOVABLE_POINTED) + UnregisterSignal(user, list(COMSIG_MOVABLE_POINTED, COMSIG_MOB_RETRIEVE_ACCESS)) return ..() /obj/item/card/id/equipped(mob/user, slot, initial = FALSE) @@ -212,12 +217,19 @@ /obj/item/card/id/proc/on_loc_equipped(datum/source, mob/equipper, slot) SIGNAL_HANDLER - if (slot == ITEM_SLOT_ID) + if (slot & ITEM_SLOT_ID) RegisterSignal(equipper, COMSIG_MOVABLE_POINTED, PROC_REF(on_pointed)) + if (slot & (ITEM_SLOT_ID|ITEM_SLOT_HANDS)) + RegisterSignal(equipper, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) /obj/item/card/id/proc/on_loc_dropped(datum/source, mob/dropper) SIGNAL_HANDLER - UnregisterSignal(dropper, COMSIG_MOVABLE_POINTED) + UnregisterSignal(dropper, list(COMSIG_MOVABLE_POINTED, COMSIG_MOB_RETRIEVE_ACCESS)) + +///Called when we're being used as access. +/obj/item/card/id/proc/retrieve_access(datum/source, list/player_access) + SIGNAL_HANDLER + player_access += GetAccess() /obj/item/card/id/proc/on_pointed(mob/living/user, atom/pointed, obj/effect/temp_visual/point/point) SIGNAL_HANDLER diff --git a/code/modules/food_and_drinks/restaurant/_venue.dm b/code/modules/food_and_drinks/restaurant/_venue.dm index 9742111972d..c26aadf196a 100644 --- a/code/modules/food_and_drinks/restaurant/_venue.dm +++ b/code/modules/food_and_drinks/restaurant/_venue.dm @@ -224,11 +224,10 @@ update_icon() /obj/machinery/restaurant_portal/item_interaction(mob/living/user, obj/item/tool, list/modifiers) - var/obj/item/card/id/used_id = tool.GetID() - if(!istype(used_id)) + if(!tool.GetID()) return NONE - if(!check_access(used_id)) + if(!allowed(user)) balloon_alert(user, "insufficient access!") return ITEM_INTERACT_BLOCKING diff --git a/code/modules/jobs/access.dm b/code/modules/jobs/access.dm index d384bac67e0..b3e242d2e1f 100644 --- a/code/modules/jobs/access.dm +++ b/code/modules/jobs/access.dm @@ -4,51 +4,32 @@ * * accessor - mob trying to access this object, !!CAN BE NULL!! because of telekiesis because we're in hell */ /atom/movable/proc/allowed(mob/accessor) - var/result_bitflags = SEND_SIGNAL(src, COMSIG_OBJ_ALLOWED, accessor) - if(result_bitflags & COMPONENT_OBJ_ALLOW) + //check if it doesn't require any access at all, or the user is an Adminghost + if(check_access(null) || isAdminGhostAI(accessor)) return TRUE - if(result_bitflags & COMPONENT_OBJ_DISALLOW) // override all other checks + if(isnull(accessor)) //likely a TK user, and we checked for free access above. return FALSE - if(isnull(accessor)) //likely a TK user. - return check_access(null) - 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. var/attempted_access = SEND_SIGNAL(accessor, COMSIG_MOB_TRIED_ACCESS, src) if(attempted_access & ACCESS_ALLOWED) return TRUE if(attempted_access & ACCESS_DISALLOWED) return FALSE - //check if it doesn't require any access at all - if(check_access(null)) + + var/list/player_access = accessor.get_access() + + //now let's check access we got from the signal. + if(check_access_list(player_access)) return TRUE + if(HAS_SILICON_ACCESS(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 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()) || check_access(accessor.get_inactive_held_item())) - return TRUE - 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)) - var/obj/item/mmi/brain_mmi = get(accessor.loc, /obj/item/mmi) - if(brain_mmi && ismecha(brain_mmi.loc)) - var/obj/vehicle/sealed/mecha/big_stompy_robot = brain_mmi.loc - return check_access_list(big_stompy_robot.accesses) return FALSE // Check if an item has access to this object diff --git a/code/modules/mob/living/basic/bots/_bots.dm b/code/modules/mob/living/basic/bots/_bots.dm index ca0b768d5cb..740e55d7bc5 100644 --- a/code/modules/mob/living/basic/bots/_bots.dm +++ b/code/modules/mob/living/basic/bots/_bots.dm @@ -112,7 +112,7 @@ GLOBAL_LIST_INIT(command_strings, list( AddElement(/datum/element/ai_retaliate) RegisterSignal(src, COMSIG_MOVABLE_MOVED, PROC_REF(handle_loop_movement)) RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(after_attacked)) - RegisterSignal(src, COMSIG_MOB_TRIED_ACCESS, PROC_REF(attempt_access)) + RegisterSignal(src, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) add_traits(list(TRAIT_NO_GLIDE, TRAIT_SILICON_EMOTES_ALLOWED), INNATE_TRAIT) LoadComponent(/datum/component/bloodysoles/bot) GLOB.bots_list += src @@ -773,10 +773,9 @@ GLOBAL_LIST_INIT(command_strings, list( /mob/living/basic/bot/rust_heretic_act() adjust_brute_loss(400) -/mob/living/basic/bot/proc/attempt_access(mob/bot, obj/door_attempt) +/mob/living/basic/bot/proc/retrieve_access(mob/bot, list/player_access) SIGNAL_HANDLER - - return (door_attempt.check_access(access_card) ? ACCESS_ALLOWED : ACCESS_DISALLOWED) + player_access += access_card.GetAccess() /mob/living/basic/bot/proc/generate_speak_list() return null diff --git a/code/modules/mob/living/basic/minebots/minebot.dm b/code/modules/mob/living/basic/minebots/minebot.dm index 41952c1bf2f..212edad7da7 100644 --- a/code/modules/mob/living/basic/minebots/minebot.dm +++ b/code/modules/mob/living/basic/minebots/minebot.dm @@ -276,4 +276,4 @@ if(isnull(required_access)) var/datum/id_trim/access_card = SSid_access.trim_singletons_by_path[/datum/id_trim/job/shaft_miner] required_access = access_card.access - AddElement(/datum/element/mob_access, required_access) + AddComponent(/datum/component/simple_access, required_access) diff --git a/code/modules/mob/living/basic/pets/dog/corgi.dm b/code/modules/mob/living/basic/pets/dog/corgi.dm index 7e23791d853..b41ce94d0ac 100644 --- a/code/modules/mob/living/basic/pets/dog/corgi.dm +++ b/code/modules/mob/living/basic/pets/dog/corgi.dm @@ -35,7 +35,7 @@ update_appearance() AddElement(/datum/element/strippable, length(strippable_inventory_slots) ? create_strippable_list(strippable_inventory_slots) : GLOB.strippable_corgi_items) AddElement(/datum/element/swabable, CELL_LINE_TABLE_CORGI, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5) - RegisterSignal(src, COMSIG_MOB_TRIED_ACCESS, PROC_REF(on_tried_access)) + RegisterSignal(src, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) RegisterSignals(src, list(COMSIG_BASICMOB_LOOK_ALIVE, COMSIG_BASICMOB_LOOK_DEAD), PROC_REF(on_appearance_change)) if(can_breed) add_breeding_component() @@ -267,10 +267,10 @@ var/datum/dog_fashion/equipped_back_fashion_item = new inventory_back.dog_fashion(src) equipped_back_fashion_item.apply(src) -///Handler for COMSIG_MOB_TRIED_ACCESS -/mob/living/basic/pet/dog/corgi/proc/on_tried_access(mob/accessor, obj/locked_thing) +///Handler for COMSIG_MOB_RETRIEVE_ACCESS +/mob/living/basic/pet/dog/corgi/proc/retrieve_access(mob/accessor, list/player_access) SIGNAL_HANDLER - return locked_thing?.check_access(access_card) ? ACCESS_ALLOWED : ACCESS_DISALLOWED + player_access += access_card.GetAccess() ///Handles updating any existing overlays for the corgi (such as fashion items) when it changes how it appears, as in, dead or alive. /mob/living/basic/pet/dog/corgi/proc/on_appearance_change() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 4adc765d3a9..c3afec02b7a 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -640,11 +640,9 @@ /** * Returns the access list for this mob */ -/mob/living/proc/get_access() as /list +/mob/living/get_access() var/list/access_list = list() - SEND_SIGNAL(src, COMSIG_MOB_RETRIEVE_SIMPLE_ACCESS, access_list) - var/obj/item/card/id/id = get_idcard() - access_list += id?.GetAccess() + SEND_SIGNAL(src, COMSIG_MOB_RETRIEVE_ACCESS, access_list) return access_list /mob/living/proc/get_id_in_hand() diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 1462345ff21..a1b576bc18a 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -114,6 +114,9 @@ /// Action we use to say voice lines out loud, also we just pass anything we try to say through here just in case it plays a voice line var/datum/action/cooldown/bot_announcement/pa_system + ///Innate access uses an internal ID card. + var/obj/item/card/id/access_card = null + /mob/living/simple_animal/bot/proc/get_mode() if(client) //Player bots do not have modes, thus the override. Also an easy way for PDA users/AI to know when a bot is a player. return paicard ? "pAI Controlled" : "Autonomous" @@ -351,6 +354,8 @@ . += span_notice("[p_They()] has a pAI device installed.") if(!(bot_cover_flags & BOT_COVER_MAINTS_OPEN)) . += span_info("You can use a hemostat to remove it.") + if(access_card) + . += "There appears to be [icon2html(access_card, user)] \a [access_card] pinned to [p_them()]." /mob/living/simple_animal/bot/adjustHealth(amount, updating_health = TRUE, forced = FALSE) if(amount > 0 && prob(10)) @@ -1216,3 +1221,7 @@ Pass a positive integer as an argument to override a bot's default speed. // we just get hit, there's no complexity for hitting an arm (if it exists) or anything. // we also need to return an empty string as otherwise it would falsely say that we get hit in the chest or something strange like that (bots don't have "chests") return "" + +//Will always check hands first, because access_card is internal to the mob and can't be removed or swapped. +/mob/living/simple_animal/bot/get_idcard(hand_first) + return (..() || access_card) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index e92563748c2..c3bf4d072f3 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -113,9 +113,6 @@ ///Sorry, no spider+corgi buttbabies. var/animal_species - ///Simple_animal access. - ///Innate access uses an internal ID card. - var/obj/item/card/id/access_card = null ///If the mob can be spawned with a gold slime core. HOSTILE_SPAWN are spawned with plasma, FRIENDLY_SPAWN are spawned with blood. var/gold_core_spawnable = NO_SPAWN @@ -217,7 +214,6 @@ adjust_stamina_loss(-stamina_recovery * seconds_per_tick, FALSE, TRUE) /mob/living/simple_animal/Destroy() - QDEL_NULL(access_card) GLOB.simple_animals[AIStatus] -= src SSnpcpool.currentrun -= src @@ -230,8 +226,6 @@ . += span_deadsay("Upon closer examination, [p_they()] appear[p_s()] to be asleep.") else . += span_deadsay("Upon closer examination, [p_they()] appear[p_s()] to be dead.") - if(access_card) - . += "There appears to be [icon2html(access_card, user)] \a [access_card] pinned to [p_them()]." /mob/living/simple_animal/update_stat() if(HAS_TRAIT(src, TRAIT_GODMODE)) @@ -477,10 +471,6 @@ return return ..() -//Will always check hands first, because access_card is internal to the mob and can't be removed or swapped. -/mob/living/simple_animal/get_idcard(hand_first) - return (..() || access_card) - /mob/living/simple_animal/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE, ignore_animation = TRUE) . = ..() update_held_items() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 00d80357717..bf52b0a9b1b 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1741,3 +1741,9 @@ continue var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[trait]] datahud.show_to(src) + +/** + * Returns the access list for this mob, most mobs don't have any access. + */ +/mob/proc/get_access() as /list + return list() diff --git a/code/modules/modular_computers/file_system/programs/budgetordering.dm b/code/modules/modular_computers/file_system/programs/budgetordering.dm index 1d3a1f40389..7aa035ffd0d 100644 --- a/code/modules/modular_computers/file_system/programs/budgetordering.dm +++ b/code/modules/modular_computers/file_system/programs/budgetordering.dm @@ -48,10 +48,9 @@ //Aquire access from the inserted ID card. if(!length(access)) - var/obj/item/card/id/D = computer?.stored_id?.GetID() - if(!D) + access = computer?.GetAccess() + if(!length(access)) return FALSE - access = D.GetAccess() if(paccess_to_check in access) return TRUE diff --git a/code/modules/pai/pai.dm b/code/modules/pai/pai.dm index b921408feba..f570e2e8e5e 100644 --- a/code/modules/pai/pai.dm +++ b/code/modules/pai/pai.dm @@ -221,6 +221,7 @@ RegisterSignal(src, COMSIG_LIVING_CULT_SACRIFICED, PROC_REF(on_cult_sacrificed)) RegisterSignals(src, list(COMSIG_LIVING_ADJUST_BRUTE_DAMAGE, COMSIG_LIVING_ADJUST_BURN_DAMAGE), PROC_REF(on_shell_damaged)) RegisterSignal(src, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, PROC_REF(on_shell_weakened)) + RegisterSignal(src, COMSIG_MOB_TRIED_ACCESS, PROC_REF(on_tried_access)) /mob/living/silicon/pai/proc/toggle_leash() if(isnull(card)) @@ -488,3 +489,8 @@ /mob/living/silicon/pai/get_access() return list() + +///Called when a pAI tries opening something that requires access. +/mob/living/silicon/pai/proc/on_tried_access(datum/source, obj/door_attempt, list/player_access) + SIGNAL_HANDLER + return ACCESS_DISALLOWED diff --git a/code/modules/vehicles/mecha/mecha_helpers.dm b/code/modules/vehicles/mecha/mecha_helpers.dm index 03084c56957..61101a8f122 100644 --- a/code/modules/vehicles/mecha/mecha_helpers.dm +++ b/code/modules/vehicles/mecha/mecha_helpers.dm @@ -29,3 +29,8 @@ if(istype(I, /obj/item/mecha_parts/mecha_equipment/weapon/ballistic)) var/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/gun = I gun.projectiles_cache = gun.projectiles_cache_max + +///Called when the mecha with an MMI in it tries opening a door. +/obj/vehicle/sealed/mecha/proc/retrieve_access(datum/source, list/player_access) + SIGNAL_HANDLER + player_access += accesses diff --git a/code/modules/vehicles/mecha/mecha_mob_interaction.dm b/code/modules/vehicles/mecha/mecha_mob_interaction.dm index 57250ecb437..296352dc8c4 100644 --- a/code/modules/vehicles/mecha/mecha_mob_interaction.dm +++ b/code/modules/vehicles/mecha/mecha_mob_interaction.dm @@ -103,6 +103,7 @@ brain_mob.reset_perspective(src) brain_mob.remote_control = src brain_mob.update_mouse_pointer() + RegisterSignal(brain_mob, COMSIG_MOB_RETRIEVE_ACCESS, PROC_REF(retrieve_access)) setDir(SOUTH) log_message("[brain_obj] moved in as pilot.", LOG_MECHA) if(!internal_damage) @@ -111,7 +112,6 @@ brain_mob.log_message("was put into [src] by [key_name(user)]", LOG_GAME, log_globally = FALSE) return TRUE - /obj/vehicle/sealed/mecha/mob_exit(mob/M, silent = FALSE, randomstep = FALSE, forced = FALSE) // FIXME: this code is really bad (shocker). Needs a refactor var/atom/movable/mob_container @@ -120,6 +120,7 @@ mob_container = M else if(isbrain(M)) var/mob/living/brain/brain = M + UnregisterSignal(brain, COMSIG_MOB_RETRIEVE_ACCESS) mob_container = brain.container else if(isAI(M)) var/mob/living/silicon/ai/AI = M diff --git a/code/modules/wiremod/shell/airlock.dm b/code/modules/wiremod/shell/airlock.dm index 165949529c4..f77e3175d80 100644 --- a/code/modules/wiremod/shell/airlock.dm +++ b/code/modules/wiremod/shell/airlock.dm @@ -31,7 +31,7 @@ return FALSE /obj/machinery/door/airlock/shell/allowed(mob/user) - if(SEND_SIGNAL(src, COMSIG_AIRLOCK_SHELL_ALLOWED, user) & COMPONENT_OBJ_ALLOW) + if(SEND_SIGNAL(src, COMSIG_AIRLOCK_SHELL_ALLOWED, user) & ACCESS_ALLOWED) return TRUE return isAdminGhostAI(user) @@ -157,14 +157,12 @@ if(istype(shell, /obj/machinery/door/airlock)) attached_airlock = shell RegisterSignals(shell, list( - COMSIG_OBJ_ALLOWED, COMSIG_AIRLOCK_SHELL_ALLOWED, ), PROC_REF(handle_allowed)) /obj/item/circuit_component/airlock_access_event/unregister_shell(atom/movable/shell) attached_airlock = null UnregisterSignal(shell, list( - COMSIG_OBJ_ALLOWED, COMSIG_AIRLOCK_SHELL_ALLOWED )) return ..() @@ -197,6 +195,6 @@ return if(result["should_open"]) - return COMPONENT_OBJ_ALLOW + return ACCESS_ALLOWED else - return COMPONENT_OBJ_DISALLOW + return ACCESS_DISALLOWED diff --git a/tgstation.dme b/tgstation.dme index 17ae864a8ad..1d241718ce8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1610,7 +1610,6 @@ #include "code\datums\elements\loomable.dm" #include "code\datums\elements\lube_walking.dm" #include "code\datums\elements\mirage_border.dm" -#include "code\datums\elements\mob_access.dm" #include "code\datums\elements\mob_grabber.dm" #include "code\datums\elements\mob_killed_tally.dm" #include "code\datums\elements\move_force_on_death.dm"