From b8a0032f618d763ca6aeb87e45ad320ff5ba0371 Mon Sep 17 00:00:00 2001 From: "Rastaf.zero" Date: Sun, 17 Mar 2013 17:49:35 +0400 Subject: [PATCH] Improvements to debug verbs del-all and spawn. Long paths are shortened, del-all got filter like spawn had. Long lists of paths are cached. --- code/modules/admin/admin.dm | 10 ++-- code/modules/admin/verbs/debug.dm | 83 ++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 13 deletions(-) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 78ba08dec9a..eedc78f47e9 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -714,12 +714,9 @@ var/global/floorIsLava = 0 if(!check_rights(R_SPAWN)) return - var/list/types = typesof(/atom) - var/list/matches = new() - - for(var/path in types) - if(findtext("[path]", object)) - matches += path + var/list/matches = get_fancy_list_of_types() + if (!isnull(object) && object!="") + matches = filter_fancy_list(matches, object) if(matches.len==0) return @@ -731,6 +728,7 @@ var/global/floorIsLava = 0 chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches if(!chosen) return + chosen = matches[chosen] new chosen(usr.loc) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 9bc0a051c76..f23a048683a 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -338,21 +338,90 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that src << "Made [M] a cultist." */ +var/list/TYPES_SHORTCUTS = list( + /obj/effect/decal/cleanable = "CLEANABLE", + /obj/item/device/radio/headset = "HEADSET", + /obj/item/clothing/head/helmet/space = "SPESSHELMET", + /obj/item/weapon/book/manual = "MANUAL", + /obj/item/weapon/reagent_containers/food/drinks = "DRINK", //longest paths comes first + /obj/item/weapon/reagent_containers/food = "FOOD", + /obj/item/weapon/reagent_containers = "REAGENT_CONTAINERS", + /obj/machinery/atmospherics = "ATMOS", + /obj/machinery/portable_atmospherics = "PORT_ATMOS", + /obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack = "MECHA_MISSILE_RACK", + /obj/item/mecha_parts/mecha_equipment = "MECHA_EQUIP", +) + +var/global/list/g_fancy_list_of_types = null +/proc/get_fancy_list_of_types() + if (isnull(g_fancy_list_of_types)) //init + var/list/temp = sortList(typesof(/atom) - typesof(/area) - /atom - /atom/movable) + g_fancy_list_of_types = new(temp.len) + for(var/type in temp) + var/typename = "[type]" + for (var/tn in TYPES_SHORTCUTS) + if (copytext(typename,1, length("[tn]/")+1)=="[tn]/" /*findtextEx(typename,"[tn]/",1,2)*/ ) + typename = TYPES_SHORTCUTS[tn]+copytext(typename,length("[tn]/")) + break + g_fancy_list_of_types[typename] = type + return g_fancy_list_of_types + +var/global/list/g_fancy_list_of_safe_types = null +/proc/get_fancy_list_of_safe_types() + if (isnull(g_fancy_list_of_safe_types)) //init + var/blocked = list( + /turf, + /obj, + /mob, + /mob/living, + /mob/living/carbon, + /mob/living/carbon/human, + /mob/dead, + /mob/dead/observer, + /mob/living/silicon, + /mob/living/silicon/robot, + /mob/living/silicon/ai + ) + var/list/source = get_fancy_list_of_types() + g_fancy_list_of_safe_types = new + for(var/typename in source) + var/type = source[typename] + if(!(type in blocked)) + g_fancy_list_of_safe_types[typename] = type + return g_fancy_list_of_safe_types + +/proc/filter_fancy_list(list/L, filter as text) + var/list/matches = new + for(var/key in L) + var/value = L[key] + if(findtext("[key]", filter) || findtext("[value]", filter)) + matches[key] = value + return matches + //TODO: merge the vievars version into this or something maybe mayhaps -/client/proc/cmd_debug_del_all() +/client/proc/cmd_debug_del_all(var/object as text) set category = "Debug" set name = "Del-All" - // to prevent REALLY stupid deletions - var/blocked = list(/obj, /mob, /mob/living, /mob/living/carbon, /mob/living/carbon/human, /mob/dead, /mob/dead/observer, /mob/living/silicon, /mob/living/silicon/robot, /mob/living/silicon/ai) - var/hsbitem = input(usr, "Choose an object to delete.", "Delete:") as null|anything in typesof(/obj) + typesof(/mob) - blocked + // usng "safe" to prevent REALLY stupid deletions + var/list/matches = get_fancy_list_of_safe_types() + if (!isnull(object) && object!="") + matches = filter_fancy_list(matches, object) + + if(matches.len==0) + return + var/hsbitem = input(usr, "Choose an object to delete.", "Delete:") as null|anything in matches if(hsbitem) + hsbitem = matches[hsbitem] + var/counter = 0 for(var/atom/O in world) if(istype(O, hsbitem)) + counter++ del(O) - log_admin("[key_name(src)] has deleted all instances of [hsbitem].") - message_admins("[key_name_admin(src)] has deleted all instances of [hsbitem].", 0) - feedback_add_details("admin_verb","DELA") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + log_admin("[key_name(src)] has deleted all ([counter]) instances of [hsbitem].") + message_admins("[key_name_admin(src)] has deleted all ([counter]) instances of [hsbitem].", 0) + feedback_add_details("admin_verb","DELA") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + /client/proc/cmd_debug_make_powernets() set category = "Debug"