antag_datums GC fixes (#18321)

This commit is contained in:
SteelSlayer
2022-07-13 18:22:25 -05:00
committed by GitHub
parent b0c73f77ff
commit f9b2a2b67e
2 changed files with 4 additions and 19 deletions
+4 -17
View File
@@ -76,12 +76,7 @@
/datum/mind/Destroy()
SSticker.minds -= src
if(islist(antag_datums))
for(var/i in antag_datums)
var/datum/antagonist/antag_datum = i
if(antag_datum.delete_on_mind_deletion)
qdel(i)
antag_datums = null
QDEL_LIST(antag_datums)
current = null
return ..()
@@ -1483,8 +1478,6 @@
* * datum/team/team - the antag team that the src mind should join, if any
*/
/datum/mind/proc/add_antag_datum(datum_type_or_instance, datum/team/team = null)
if(!datum_type_or_instance)
return
var/datum/antagonist/A
if(!ispath(datum_type_or_instance))
A = datum_type_or_instance
@@ -1512,18 +1505,15 @@
* * datum_type - an antag datum typepath
*/
/datum/mind/proc/remove_antag_datum(datum_type)
if(!datum_type)
return
var/datum/antagonist/A = has_antag_datum(datum_type)
LAZYREMOVE(antag_datums, A)
qdel(A)
/**
* Removes all antag datums from the src mind.
*/
/datum/mind/proc/remove_all_antag_datums() //For the Lazy amongst us.
for(var/a in antag_datums)
var/datum/antagonist/A = a
qdel(A)
QDEL_LIST(antag_datums)
/**
* Returns an antag datum instance if the src mind has the specified `datum_type`. Returns `null` otherwise.
@@ -1533,10 +1523,7 @@
* * check_subtypes - TRUE if this proc will consider subtypes of `datum_type` as valid. FALSE if only the exact same type should be considered.
*/
/datum/mind/proc/has_antag_datum(datum_type, check_subtypes = TRUE)
if(!datum_type)
return
for(var/a in antag_datums)
var/datum/antagonist/A = a
for(var/datum/antagonist/A as anything in antag_datums)
if(check_subtypes && istype(A, datum_type))
return A
else if(A.type == datum_type)
@@ -13,8 +13,6 @@ GLOBAL_LIST_EMPTY(antagonists)
var/silent = FALSE
/// List of other antag datum types that this type can't coexist with.
var/list/antag_datum_blacklist
/// Should this datum be deleted when the owner's mind is deleted.
var/delete_on_mind_deletion = TRUE
/// Used to determine if the player jobbanned from this role. Things like `SPECIAL_ROLE_TRAITOR` should go here to determine the role.
var/job_rank
/// Should we replace the role-banned player with a ghost?