From b7377185d9021aa1e4357b7b2aefa74d319ceea7 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Wed, 15 Apr 2015 07:11:34 -0700 Subject: [PATCH] Admin Ghostdrop sanity checks Applies tgstation/-tg-station@2227b7a to admin.dm and observer.dm Basically, this adds sanity checks, just to prevent runtimes in the odd case that something happens. For instance, if one of the mobs suddenly gets deleted, this will prevent it from runtiming. Sanity checks. --- code/modules/admin/admin.dm | 6 ++++++ code/modules/mob/dead/observer/observer.dm | 1 + 2 files changed, 7 insertions(+) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 3ca884da7bd..a108dd54287 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -988,6 +988,8 @@ proc/formatLocation(var/location) proc/formatPlayerPanel(var/mob/U,var/text="PP") return "[text]" +//returns 1 to let the dragdrop code know we are trapping this event +//returns 0 if we don't plan to trap the event /datum/admins/proc/cmd_ghost_drag(var/mob/dead/observer/frommob, var/mob/living/tomob) if(!istype(frommob)) return //extra sanity check to make sure only observers are shoved into things @@ -999,6 +1001,7 @@ proc/formatPlayerPanel(var/mob/U,var/text="PP") if (!frommob.ckey) return 0 + var/question = "" if (tomob.ckey) question = "This mob already has a user ([tomob.key]) in control of it! " @@ -1008,6 +1011,9 @@ proc/formatPlayerPanel(var/mob/U,var/text="PP") if (ask != "Yes") return 1 + if(!frommob || !tomob) //make sure the mobs don't go away while we waited for a response + return 1 + if(tomob.client) //no need to ghostize if there is no client tomob.ghostize(0) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index b5a67bd61dd..22af8b0bedc 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -489,6 +489,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp //this is called when a ghost is drag clicked to something. /mob/dead/observer/MouseDrop(atom/over) + if(!usr || !over) return if (isobserver(usr) && usr.client && usr.client.holder && isliving(over)) if (usr.client.holder.cmd_ghost_drag(src,over)) return