Fix antag datum runtimes when they deleted their own owners and make other silent errors now runtime. (#53721)

heretic_monster antag datums nulled their own owner before calling code that relied on them having an owner to function. This has been fixed. Antag datum subtypes should not be modifying their own owners. Leave that to the parent code.

This could lead to situations where a mind has null antag datums sitting around in its list of antag_datums. This has also probably been fixed.

There are various checks dotted throughout the code to check if antag datums have owners. Most would either return early, continue in a for loop or silently skip over it. Antag datums should never be without an owner. These have all been removed.

When an ownerless antag datum is detected, it should not die silently. It should die loudly and proudly, declaring that something, somewhere went wrong and that there is a willing and necessary martyr to the cause of addressing WHY something runtimes instead of just having it silently skipped over.
This commit is contained in:
Timberpoes
2020-09-23 03:22:30 -03:00
committed by GitHub
parent 68ce669136
commit 86287eea88
8 changed files with 51 additions and 25 deletions
@@ -30,7 +30,9 @@ GLOBAL_LIST_EMPTY(antagonists)
/datum/antagonist/Destroy()
GLOB.antagonists -= src
if(owner)
if(!owner)
stack_trace("Destroy()ing antagonist datum when it has no owner.")
else
LAZYREMOVE(owner.antag_datums, src)
owner = null
return ..()
@@ -133,14 +135,16 @@ GLOBAL_LIST_EMPTY(antagonists)
///Called by the remove_antag_datum() and remove_all_antag_datums() mind procs for the antag datum to handle its own removal and deletion.
/datum/antagonist/proc/on_removal()
SHOULD_CALL_PARENT(TRUE)
if(!owner)
CRASH("Antag datum with no owner.")
remove_innate_effects()
clear_antag_moodies()
if(owner)
LAZYREMOVE(owner.antag_datums, src)
if(!LAZYLEN(owner.antag_datums))
owner.current.remove_from_current_living_antags()
if(!silent && owner.current)
farewell()
LAZYREMOVE(owner.antag_datums, src)
if(!LAZYLEN(owner.antag_datums))
owner.current.remove_from_current_living_antags()
if(!silent && owner.current)
farewell()
var/datum/team/team = get_team()
if(team)
team.remove_member(owner)
@@ -171,7 +175,7 @@ GLOBAL_LIST_EMPTY(antagonists)
var/list/report = list()
if(!owner)
CRASH("antagonist datum without owner")
CRASH("Antagonist datum without owner")
report += printplayer(owner)
@@ -19,9 +19,9 @@
to_chat(owner, "<span class='boldannounce'>You became an Eldritch Horror!</span>")
/datum/antagonist/heretic_monster/on_removal()
if(owner)
to_chat(owner, "<span class='boldannounce'>Your master is no longer [master.owner.current.real_name]</span>")
owner = null
if(master)
to_chat(master, "<span class='boldannounce'>Your master is no longer [master.owner.current.real_name]</span>")
master = null
return ..()
/datum/antagonist/heretic_monster/proc/set_owner(datum/antagonist/_master)
@@ -77,6 +77,7 @@
var/list/fugitives_captured = list()
for(var/datum/antagonist/fugitive/A in GLOB.antagonists)
if(!A.owner)
stack_trace("Antagonist datum without owner in GLOB.antagonists: [A]")
continue
fugitives_counted += A
if(A.owner.current.stat == DEAD)
@@ -51,6 +51,7 @@
if(!new_team)
for(var/datum/antagonist/monkey/H in GLOB.antagonists)
if(!H.owner)
stack_trace("Antagonist datum without owner in GLOB.antagonists: [H]")
continue
if(H.monkey_team)
monkey_team = H.monkey_team
@@ -112,6 +112,7 @@
if(!always_new_team)
for(var/datum/antagonist/nukeop/N in GLOB.antagonists)
if(!N.owner)
stack_trace("Antagonist datum without owner in GLOB.antagonists: [N]")
continue
if(N.nuke_team)
nuke_team = N.nuke_team
@@ -18,6 +18,7 @@
if(!new_team)
for(var/datum/antagonist/pirate/P in GLOB.antagonists)
if(!P.owner)
stack_trace("Antagonist datum without owner in GLOB.antagonists: [P]")
continue
if(P.crew)
crew = P.crew
@@ -15,29 +15,39 @@
/datum/antagonist/traitor/internal_affairs/proc/give_pinpointer()
if(owner && owner.current)
if(!owner)
CRASH("Antag datum with no owner.")
if(owner.current)
owner.current.apply_status_effect(/datum/status_effect/agent_pinpointer)
/datum/antagonist/traitor/internal_affairs/apply_innate_effects()
.=..() //in case the base is used in future
if(owner && owner.current)
. = ..()
if(!owner)
CRASH("Antag datum with no owner.")
if(owner.current)
give_pinpointer(owner.current)
/datum/antagonist/traitor/internal_affairs/remove_innate_effects()
.=..()
if(owner && owner.current)
. = ..()
if(!owner)
CRASH("Antag datum with no owner.")
if(owner.current)
owner.current.remove_status_effect(/datum/status_effect/agent_pinpointer)
/datum/antagonist/traitor/internal_affairs/on_gain()
START_PROCESSING(SSprocessing, src)
.=..()
. = ..()
/datum/antagonist/traitor/internal_affairs/on_removal()
STOP_PROCESSING(SSprocessing,src)
.=..()
. = ..()
/datum/antagonist/traitor/internal_affairs/process()
iaa_process()
/datum/status_effect/agent_pinpointer
id = "agent_pinpointer"
duration = -1
@@ -101,7 +111,9 @@
return (istype(O, /datum/objective/assassinate/internal)||istype(O, /datum/objective/destroy/internal))
/datum/antagonist/traitor/proc/replace_escape_objective()
if(!owner || !objectives.len)
if(!owner)
CRASH("Antag datum with no owner.")
if(!objectives.len)
return
for (var/objective_ in objectives)
if(!(istype(objective_, /datum/objective/escape)||istype(objective_, /datum/objective/survive)))
@@ -113,7 +125,9 @@
add_objective(martyr_objective)
/datum/antagonist/traitor/proc/reinstate_escape_objective()
if(!owner||!objectives.len)
if(!owner)
CRASH("Antag datum with no owner.")
if(!objectives.len)
return
for (var/objective_ in objectives)
if(!istype(objective_, /datum/objective/martyr))
@@ -174,7 +188,9 @@
replace_escape_objective(owner)
/datum/antagonist/traitor/internal_affairs/proc/iaa_process()
if(owner&&owner.current&&owner.current.stat!=DEAD)
if(!owner)
CRASH("Antag datum with no owner.")
if(owner.current && owner.current.stat != DEAD)
for(var/objective_ in objectives)
if(!is_internal_objective(objective_))
continue
+5 -3
View File
@@ -54,7 +54,9 @@
add_antag_hud(antag_hud_type, antag_hud_name, owner.current)
/datum/antagonist/wizard/proc/send_to_lair()
if(!owner || !owner.current)
if(!owner)
CRASH("Antag datum with no owner.")
if(!owner.current)
return
if(!GLOB.wizardstart.len)
SSjob.SendToLateJoin(owner.current)
@@ -114,7 +116,7 @@
/datum/antagonist/wizard/proc/equip_wizard()
if(!owner)
return
CRASH("Antag datum with no owner.")
var/mob/living/carbon/human/H = owner.current
if(!istype(H))
return
@@ -191,7 +193,7 @@
/datum/antagonist/wizard/apprentice/equip_wizard()
. = ..()
if(!owner)
return
CRASH("Antag datum with no owner.")
var/mob/living/carbon/human/H = owner.current
if(!istype(H))
return