Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes crash in Join as Freed Mob if some had been deleted #4678

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ GLOBAL_LIST_INIT(frozen_items, list(SQUAD_MARINE_1 = list(), SQUAD_MARINE_2 = li

//Lifted from Unity stasis.dm and refactored. ~Zuhayr
/obj/structure/machinery/cryopod/process()
if(occupant && !(WEAKREF(occupant) in GLOB.freed_mob_list)) //ignore freed mobs
if(occupant && !(occupant in GLOB.freed_mob_list)) //ignore freed mobs
//if occupant ghosted, time till despawn is severely shorter
if(!occupant.key && time_till_despawn == 10 MINUTES)
time_till_despawn -= 8 MINUTES
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/freeforghosts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if(mind || client)
ghostize(FALSE)

GLOB.freed_mob_list |= WEAKREF(src)
GLOB.freed_mob_list |= src

if(!notify)
return
Expand Down
16 changes: 6 additions & 10 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1012,13 +1012,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return

var/list/mobs_by_role = list() // the list the mobs are assigned to first, for sorting purposes
for(var/datum/weakref/ref as anything in GLOB.freed_mob_list)
var/mob/living/resolved_mob = ref.resolve()
var/role_name = resolved_mob.get_role_name()
for(var/mob/freed_mob as anything in GLOB.freed_mob_list)
var/role_name = freed_mob.get_role_name()
if(!role_name)
role_name = "No Role"
LAZYINITLIST(mobs_by_role[role_name])
mobs_by_role[role_name] += resolved_mob
mobs_by_role[role_name] += freed_mob

var/list/freed_mob_choices = list() // the list we'll be choosing from
for(var/role in mobs_by_role)
Expand All @@ -1034,18 +1033,15 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
handle_joining_as_freed_mob(L)

/mob/dead/proc/handle_joining_as_freed_mob(mob/living/freed_mob)
if(!freed_mob || !(WEAKREF(freed_mob) in GLOB.freed_mob_list))
return

if(!istype(freed_mob))
if(!istype(freed_mob) || !(freed_mob in GLOB.freed_mob_list))
return

if(QDELETED(freed_mob) || freed_mob.client)
GLOB.freed_mob_list -= WEAKREF(freed_mob)
GLOB.freed_mob_list -= freed_mob
to_chat(src, SPAN_WARNING("Something went wrong."))
return

GLOB.freed_mob_list -= WEAKREF(freed_mob)
GLOB.freed_mob_list -= freed_mob
mind.transfer_to(freed_mob, TRUE)

/mob/dead/verb/join_as_hellhound()
Expand Down