From ad0d270d580c76b9ac08add4f07a8f3b8a1ec2ef Mon Sep 17 00:00:00 2001 From: skoglol <33292112+kriskog@users.noreply.github.com> Date: Mon, 18 Nov 2019 18:59:47 +0100 Subject: [PATCH] Cleans up observer mind on control transfer, ghosting, DNR, suicide (#47826) * Fixes admin ghost drag * Covers more cases * And assume control --- code/modules/admin/admin.dm | 22 ++++++++++++++-------- code/modules/admin/verbs/debug.dm | 3 +-- code/modules/client/verbs/suicide.dm | 1 + code/modules/mob/dead/observer/observer.dm | 13 +++++++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index bb02b24bd2f..c7d2bbba6d7 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -906,16 +906,16 @@ qdel(C) return kicked_client_names -//returns 1 to let the dragdrop code know we are trapping this event -//returns 0 if we don't plan to trap the event +//returns TRUE to let the dragdrop code know we are trapping this event +//returns FALSE if we don't plan to trap the event /datum/admins/proc/cmd_ghost_drag(mob/dead/observer/frommob, mob/tomob) //this is the exact two check rights checks required to edit a ckey with vv. if (!check_rights(R_VAREDIT,0) || !check_rights(R_SPAWN|R_DEBUG,0)) - return 0 + return FALSE if (!frommob.ckey) - return 0 + return FALSE var/question = "" if (tomob.ckey) @@ -924,12 +924,18 @@ var/ask = alert(question, "Place ghost in control of mob?", "Yes", "No") if (ask != "Yes") - return 1 + return TRUE if (!frommob || !tomob) //make sure the mobs don't go away while we waited for a response - return 1 + return TRUE - tomob.ghostize(0) + // Disassociates observer mind from the body mind + if(tomob.client) + tomob.ghostize(FALSE) + else + for(var/mob/dead/observer/ghost in GLOB.dead_mob_list) + if(tomob.mind == ghost.mind) + ghost.mind = null message_admins("[key_name_admin(usr)] has put [frommob.key] in control of [tomob.name].") log_admin("[key_name(usr)] stuffed [frommob.key] into [tomob.name].") @@ -938,7 +944,7 @@ tomob.ckey = frommob.ckey qdel(frommob) - return 1 + return TRUE /client/proc/adminGreet(logout) if(SSticker.HasRoundStarted()) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 91b85d8e4ca..8cd8165f5ad 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -235,8 +235,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that if(alert("This mob is being controlled by [M.key]. Are you sure you wish to assume control of it? [M.key] will be made a ghost.",,"Yes","No") != "Yes") return else - var/mob/dead/observer/ghost = new/mob/dead/observer(M,1) - ghost.ckey = M.ckey + M.ghostize(FALSE) message_admins("[key_name_admin(usr)] assumed direct control of [M].") log_admin("[key_name(usr)] assumed direct control of [M].") var/mob/adminmob = src.mob diff --git a/code/modules/client/verbs/suicide.dm b/code/modules/client/verbs/suicide.dm index c3189178cc8..58b11cddfbc 100644 --- a/code/modules/client/verbs/suicide.dm +++ b/code/modules/client/verbs/suicide.dm @@ -104,6 +104,7 @@ adjustOxyLoss(max(200 - getToxLoss() - getFireLoss() - getBruteLoss() - getOxyLoss(), 0)) death(FALSE) + ghostize(FALSE) // Disallows reentering body and disassociates mind /mob/living/brain/verb/suicide() set hidden = 1 diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index bdfc9610b4f..af437112637 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -261,7 +261,7 @@ Transfer_mind is there to check if mob is being deleted/not going to have a body Works together with spawning an observer, noted above. */ -/mob/proc/ghostize(can_reenter_corpse = 1) +/mob/proc/ghostize(can_reenter_corpse = TRUE) if(key) if(!cmptext(copytext(key,1,2),"@")) // Skip aghosts. stop_sound_channel(CHANNEL_HEARTBEAT) //Stop heartbeat sounds because You Are A Ghost Now @@ -269,6 +269,8 @@ Works together with spawning an observer, noted above. SStgui.on_transfer(src, ghost) // Transfer NanoUIs. ghost.can_reenter_corpse = can_reenter_corpse ghost.key = key + if(!can_reenter_corpse) // Disassociates observer mind from the body mind + ghost.mind = null return ghost /* @@ -282,12 +284,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp if(stat != DEAD) succumb() if(stat == DEAD) - ghostize(1) + ghostize(TRUE) else var/response = alert(src, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?","Ghost","Stay in body") if(response != "Ghost") return //didn't want to ghost after-all - ghostize(0) //0 parameter is so we can never re-enter our body, "Charlie, you can never come baaaack~" :3 + ghostize(FALSE) // FALSE parameter is so we can never re-enter our body, "Charlie, you can never come baaaack~" :3 /mob/camera/verb/ghost() set category = "OOC" @@ -297,7 +299,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp var/response = alert(src, "Are you -sure- you want to ghost?\n(You are alive. If you ghost whilst still alive you may not play again this round! You can't change your mind so choose wisely!!)","Are you sure you want to ghost?","Ghost","Stay in body") if(response != "Ghost") return - ghostize(0) + ghostize(FALSE) /mob/dead/observer/Move(NewLoc, direct) if(updatedir) @@ -353,6 +355,9 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp return can_reenter_corpse = FALSE + // Disassociates observer mind from the body mind + mind = null + to_chat(src, "You can no longer be brought back into your body.") return TRUE