From f6d4aae74af79f40a7f5b5ea9d9d9098ad9bbca1 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Tue, 14 Apr 2015 16:21:40 -0700 Subject: [PATCH 1/2] Allow admins to drag-drop ghosts into mobs This allows administrators to drag their mouse from a ghost to a type of /mob/living, which will then prompt them if they wish to put that ghost in control of the mob, and obviously, that is exactly what happens if you select yes. --- code/modules/admin/admin.dm | 32 ++++++++++++++++++++++ code/modules/mob/dead/observer/observer.dm | 8 ++++++ 2 files changed, 40 insertions(+) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index dee6c2afaaf..3ca884da7bd 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -987,3 +987,35 @@ proc/formatLocation(var/location) proc/formatPlayerPanel(var/mob/U,var/text="PP") return "[text]" + +/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 + + //same as assume-direct-control perm requirements. + if (!check_rights(R_VAREDIT,0) || !check_rights(R_ADMIN|R_DEBUG,0)) + return 0 + + if (!frommob.ckey) + return 0 + + var/question = "" + if (tomob.ckey) + question = "This mob already has a user ([tomob.key]) in control of it! " + question += "Are you sure you want to place [frommob.name]([frommob.key]) in control of [tomob.name]?" + + var/ask = alert(question, "Place ghost in control of mob?", "Yes", "No") + if (ask != "Yes") + return 1 + + if(tomob.client) //no need to ghostize if there is no client + tomob.ghostize(0) + + message_admins("[key_name_admin(usr)] has put [frommob.ckey] in control of [tomob.name].") + log_admin("[key_name(usr)] stuffed [frommob.ckey] into [tomob.name].") + feedback_add_details("admin_verb","CGD") + + tomob.ckey = frommob.ckey + qdel(frommob) + + return 1 \ No newline at end of file diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 7ae495373e3..b5a67bd61dd 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -487,6 +487,14 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp src << browse(dat, "window=manifest;size=370x420;can_close=1") +//this is called when a ghost is drag clicked to something. +/mob/dead/observer/MouseDrop(atom/over) + if (isobserver(usr) && usr.client && usr.client.holder && isliving(over)) + if (usr.client.holder.cmd_ghost_drag(src,over)) + return + + return ..() + //BEGIN TELEPORT HREF CODE /mob/dead/observer/Topic(href, href_list) if(usr != src) From b7377185d9021aa1e4357b7b2aefa74d319ceea7 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Wed, 15 Apr 2015 07:11:34 -0700 Subject: [PATCH 2/2] 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