Skip to content

Commit

Permalink
Makes some code tidy (ParadiseSS13#27391)
Browse files Browse the repository at this point in the history
* erguertbngio3eunf3o2we4if

* woop de doo
  • Loading branch information
Contrabang authored Nov 19, 2024
1 parent 105a2fa commit 1cda30a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
12 changes: 4 additions & 8 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,15 @@
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()

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))
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions code/game/gamemodes/objective_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
8 changes: 4 additions & 4 deletions code/modules/antagonists/_common/antag_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/traitor/datum_traitor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1cda30a

Please sign in to comment.