diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index c3d664ab1d4..d155f856210 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -114,6 +114,7 @@ var/list/admin_verbs_debug = list( /client/proc/restart_controller, /client/proc/enable_debug_verbs, /client/proc/callproc, + /client/proc/callproc_datum, /client/proc/SDQL2_query ) var/list/admin_verbs_possess = list( @@ -175,6 +176,7 @@ var/list/admin_verbs_hideable = list( /client/proc/restart_controller, /client/proc/cmd_admin_list_open_jobs, /client/proc/callproc, + /client/proc/callproc_datum, /client/proc/Debug2, /client/proc/reload_admins, /client/proc/cmd_debug_make_powernets, diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index f6a8d2ef349..aa3997c4eb5 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -34,8 +34,6 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that spawn(0) var/target = null var/targetselected = 0 - var/lst[] // List reference - lst = new/list() // Make the list var/returnval = null var/class = null @@ -64,53 +62,9 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null if(!procname) return - var/argnum = input("Number of arguments","Number:",0) as num|null - if(!argnum && (argnum!=0)) return - - lst.len = argnum // Expand to right length - //TODO: make a list to store whether each argument was initialised as null. - //Reason: So we can abort the proccall if say, one of our arguments was a mob which no longer exists - //this will protect us from a fair few errors ~Carn - - var/i - for(i=1, i[procname] returned: [returnval ? returnval : "null"]" feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! +/client/proc/callproc_datum(var/atom/A as null|area|mob|obj|turf) + set category = "Debug" + set name = "Atom ProcCall" + + if(!check_rights(R_DEBUG)) + return + + if(!istype(A)) + return + + var/procname = input("Proc name, eg: fake_blood","Proc:", null) as text|null + if(!procname) + return + + var/list/lst = get_callproc_args() + if(!lst) + return + + if(!A || A.gc_destroyed) + usr << "Error: callproc_datum(): owner of proc no longer exists." + return + if(!hascall(A,procname)) + usr << "Error: callproc_datum(): target has no such call [procname]." + return + log_admin("[key_name(src)] called [A]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") + + spawn() + var/returnval = call(A,procname)(arglist(lst)) // Pass the lst as an argument list to the proc + usr << "[procname] returned: [returnval ? returnval : "null"]" + + feedback_add_details("admin_verb","DPC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + +/client/proc/get_callproc_args() + var/argnum = input("Number of arguments","Number:",0) as num|null + if(!argnum && (argnum!=0)) return + + var/list/lst = list() + //TODO: make a list to store whether each argument was initialised as null. + //Reason: So we can abort the proccall if say, one of our arguments was a mob which no longer exists + //this will protect us from a fair few errors ~Carn + + while(argnum--) + // Make a list with each index containing one variable, to be given to the proc + var/class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL") + switch(class) + if("CANCEL") + return null + + if("text") + lst += input("Enter new text:","Text",null) as text + + if("num") + lst += input("Enter new number:","Num",0) as num + + if("type") + lst += input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf) + + if("reference") + lst += input("Select reference:","Reference",src) as mob|obj|turf|area in world + + if("mob reference") + lst += input("Select reference:","Reference",usr) as mob in world + + if("file") + lst += input("Pick file:","File") as file + + if("icon") + lst += input("Pick icon:","Icon") as icon + + if("client") + var/list/keys = list() + for(var/mob/M in world) + keys += M.client + lst += input("Please, select a player!", "Selection", null, null) as null|anything in keys + + if("mob's area") + var/mob/temp = input("Select mob", "Selection", usr) as mob in world + lst += temp.loc + return lst + + /client/proc/Cell() set category = "Debug" set name = "Air Status in Location"