From f9e5b255f972863fcb833fa977efedafc42924e8 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:30:41 -0600 Subject: [PATCH] Fix antag info panel on body loss, also some sanity (#63976) Losing your body as an antag will correctly remove the antag info panel from the body Gaining a new body as an antag will give the panel to the new body Adds some sanity checks to ensure no one who doesn't need to be seeing the panel can use it Fixes #63303 (Antag Panel lost, upon switching to another Golem body (and considered dead for others)) You can see your objectives after being brain transplanted as an antag --- .../antagonists/_common/antag_datum.dm | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index a8515780094..46d26aa36d7 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -94,6 +94,8 @@ GLOBAL_LIST_EMPTY(antagonists) remove_innate_effects(old_body) if(!soft_antag && old_body && old_body.stat != DEAD && !LAZYLEN(old_body.mind?.antag_datums)) old_body.remove_from_current_living_antags() + info_button.Remove(old_body) + info_button.Grant(new_body) apply_innate_effects(new_body) if(!soft_antag && new_body.stat != DEAD) new_body.add_to_current_living_antags() @@ -141,7 +143,7 @@ GLOBAL_LIST_EMPTY(antagonists) if(!owner.current) CRASH("[src] ran on_gain() on a mind without a mob") if(ui_name)//in the future, this should entirely replace greet. - info_button = new(owner.current, src) + info_button = new(src) info_button.Grant(owner.current) if(!silent) greet() @@ -477,16 +479,27 @@ GLOBAL_LIST_EMPTY(antagonists) /datum/action/antag_info name = "Open Antag Information:" button_icon_state = "round_end" - var/datum/antagonist/antag_datum -/datum/action/antag_info/New(Target, datum/antagonist/antag_datum) +/datum/action/antag_info/New(Target) . = ..() - src.antag_datum = antag_datum - name += " [antag_datum.name]" + name += " [target]" /datum/action/antag_info/Trigger() - if(antag_datum) - antag_datum.ui_interact(owner) + . = ..() + if(!.) + return + + target.ui_interact(owner) /datum/action/antag_info/IsAvailable() + if(!target) + stack_trace("[type] was used without a target antag datum!") + return FALSE + . = ..() + if(!.) + return + if(!owner.mind) + return FALSE + if(!(target in owner.mind.antag_datums)) + return FALSE return TRUE