From 1cda30a19fbc568729cad4986bf8afee403f295c Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Tue, 19 Nov 2024 05:51:58 -0500 Subject: [PATCH] Makes some code tidy (#27391) * erguertbngio3eunf3o2we4if * woop de doo --- code/datums/mind.dm | 12 ++++-------- code/game/gamemodes/objective_holder.dm | 10 +++++----- code/modules/antagonists/_common/antag_datum.dm | 8 ++++---- code/modules/antagonists/traitor/datum_traitor.dm | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index b2d508beec0..53046c88c5d 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -238,7 +238,7 @@ return FALSE /** - * Gets every objective this mind owns, including all of those from any antag datums they have, and returns them as a list. + * Gets every objective this mind owns, including all of those from any antag datums and teams they have, and returns them as a list. */ /datum/mind/proc/get_all_objectives(include_team = TRUE) var/list/all_objectives = list() @@ -246,11 +246,7 @@ all_objectives += objective_holder.get_objectives() // Get their personal objectives for(var/datum/antagonist/A as anything in antag_datums) - all_objectives += A.objective_holder.get_objectives() // Add all antag datum objectives. - if(include_team) - var/datum/team/team = A.get_team() - if(team) // have to make asure a team exists here, team?. does not work below because it will add the null to the list - all_objectives += team.objective_holder.get_objectives() // Get all of their teams' objectives + all_objectives += A.get_antag_objectives(include_team) // Add all antag datum objectives, and possibly antag team objectives // For custom non-antag role teams if(include_team && LAZYLEN(teams)) @@ -279,9 +275,9 @@ if(!remove_from_everything) return for(var/datum/antagonist/A as anything in antag_datums) - A.objective_holder.remove_objective(O) // Add all antag datum objectives. + A.remove_antag_objective(O) var/datum/team/team = A.get_team() - team?.objective_holder.remove_objective(O) // Get all of their teams' objectives + team?.objective_holder.remove_objective(O) /datum/mind/proc/_memory_edit_header(gamemode, list/alt) . = gamemode diff --git a/code/game/gamemodes/objective_holder.dm b/code/game/gamemodes/objective_holder.dm index 4cbeb50d1d5..c3d7b455487 100644 --- a/code/game/gamemodes/objective_holder.dm +++ b/code/game/gamemodes/objective_holder.dm @@ -4,15 +4,15 @@ /datum/objective_holder /// Our list of current objectives - var/list/datum/objective/objectives = list() + VAR_PRIVATE/list/datum/objective/objectives = list() /// Who do we belong to [mind, antagonist, team] - var/datum/objective_owner + VAR_PRIVATE/datum/objective_owner /// A list of strings which contain [targets][/datum/objective/var/target] of the antagonist's objectives. Used to prevent duplicate objectives. - var/list/assigned_targets = list() + VAR_PRIVATE/list/assigned_targets = list() /// A callback invoked when a new objective is added. This is required because sometimes objectives are added directly without going through objective_owner. Not currently used. - var/datum/callback/on_add_callback + VAR_PRIVATE/datum/callback/on_add_callback /// A callback invoked when a new objective is added. This is required because sometimes objectives are removed directly without going through objective_owner (EX: replace_objective(), clear()). Not currently used. - var/datum/callback/on_remove_callback + VAR_PRIVATE/datum/callback/on_remove_callback /datum/objective_holder/New(new_owner) . = ..() diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index eae1ba66320..497bb2bb802 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -22,7 +22,7 @@ GLOBAL_LIST_EMPTY(antagonists) /// Should we replace the role-banned player with a ghost? var/replace_banned = TRUE /// List of objectives connected to this datum. - var/datum/objective_holder/objective_holder + VAR_PRIVATE/datum/objective_holder/objective_holder /// Antagonist datum specific information that appears in the player's notes. Information stored here will be removed when the datum is removed from the player. var/antag_memory /// The special role that will be applied to the owner's `special_role` var. i.e. `SPECIAL_ROLE_TRAITOR`, `SPECIAL_ROLE_VAMPIRE`. @@ -283,22 +283,22 @@ GLOBAL_LIST_EMPTY(antagonists) */ /datum/antagonist/proc/has_antag_objectives(include_team = TRUE) . = FALSE - if(include_team) + . |= objective_holder.has_objectives() + if(!. && include_team) var/datum/team/team = get_team() if(istype(team)) . |= team.objective_holder.has_objectives() - . |= objective_holder.has_objectives() /** * Get all of this antagonist's objectives, including from the team. */ /datum/antagonist/proc/get_antag_objectives(include_team = TRUE) . = list() + . |= objective_holder.get_objectives() if(include_team) var/datum/team/team = get_team() if(istype(team)) . |= team.objective_holder.get_objectives() - . |= objective_holder.get_objectives() /** * Proc called when the datum is given to a mind. diff --git a/code/modules/antagonists/traitor/datum_traitor.dm b/code/modules/antagonists/traitor/datum_traitor.dm index d392e6fe5f6..71c9c97ca6c 100644 --- a/code/modules/antagonists/traitor/datum_traitor.dm +++ b/code/modules/antagonists/traitor/datum_traitor.dm @@ -274,7 +274,7 @@ RESTRICT_TYPE(/datum/antagonist/traitor) return "[GLOB.current_date_string], [station_time_timestamp()]\n[station_name()], [get_area_name(owner.current, TRUE)]\nBEGIN_MISSION" /datum/antagonist/traitor/proc/reveal_delayed_objectives() - for(var/datum/objective/delayed/delayed_obj in objective_holder.objectives) + for(var/datum/objective/delayed/delayed_obj in get_antag_objectives(FALSE)) delayed_obj.reveal_objective() if(!owner?.current)