From 603bf4624c434803cdacb6913c2c9f63383932e8 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 17 Jan 2016 20:12:51 +0000 Subject: [PATCH 1/5] callproc now outputs the contents of returned lists instead of /list While it's useful to know when a /list has been returned, it's infinitely more useful to see that list's contents --- code/modules/admin/verbs/debug.dm | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 1e99c5a4ea0..89db9d52ca7 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -92,8 +92,9 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that log_admin("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") message_admins("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") returnval = call(procname)(arglist(lst)) // Pass the lst as an argument list to the proc - - usr << "[procname] returned: [returnval ? returnval : "null"]" + . = get_callproc_returnval(returnval) + if(.) + usr << . 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(A as null|area|mob|obj|turf) @@ -122,7 +123,9 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that feedback_add_details("admin_verb","DPC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! var/returnval = call(A,procname)(arglist(lst)) // Pass the lst as an argument list to the proc - usr << "[procname] returned: [returnval ? returnval : "null"]" + . = get_callproc_returnval(returnval) + if(.) + usr << . @@ -183,6 +186,23 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return lst +/client/proc/get_callproc_returnval(returnval) + . = "" + if(islist(returnval)) + var/list/returnedlist = returnval + . = "" + if(returnedlist.len) + . += "[procname] returned a list:" + for(var/elem in returnedlist) + . += "[elem]" + else + . = "[procname] returned an empty list" + . += "" + + else + . = "[procname] returned: [returnval ? returnval : "null"]" + + /client/proc/Cell() set category = "Debug" set name = "Air Status in Location" From 65a60d438ca9a1f4bc59b4feba12f657c9fb167e Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 17 Jan 2016 20:18:09 +0000 Subject: [PATCH 2/5] Adds the ability for get_callproc_returnval() to spot assoc lists --- code/modules/admin/verbs/debug.dm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 89db9d52ca7..8f709ed97a2 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -192,9 +192,16 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that var/list/returnedlist = returnval . = "" if(returnedlist.len) - . += "[procname] returned a list:" - for(var/elem in returnedlist) - . += "[elem]" + var/assoc_check = returnedlist[1] + if(istext(assoc_check) && (returnedlist[assoc_check] != null)) + . += "[procname] returned an associative list:" + for(var/key in returnedlist) + . += "[key] = [returnedlist[key]]" + + else + . += "[procname] returned a list:" + for(var/elem in returnedlist) + . += "[elem]" else . = "[procname] returned an empty list" . += "" From def68f134c2d68c626f4e1ddeb2e3923a6e9af88 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 17 Jan 2016 20:20:35 +0000 Subject: [PATCH 3/5] Missed an argument. --- code/modules/admin/verbs/debug.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 8f709ed97a2..790dadefba9 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -92,7 +92,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that log_admin("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") message_admins("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") returnval = call(procname)(arglist(lst)) // Pass the lst as an argument list to the proc - . = get_callproc_returnval(returnval) + . = get_callproc_returnval(returnval, procname) if(.) usr << . feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! @@ -123,7 +123,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that feedback_add_details("admin_verb","DPC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! var/returnval = call(A,procname)(arglist(lst)) // Pass the lst as an argument list to the proc - . = get_callproc_returnval(returnval) + . = get_callproc_returnval(returnval,procname) if(.) usr << . @@ -186,7 +186,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return lst -/client/proc/get_callproc_returnval(returnval) +/client/proc/get_callproc_returnval(returnval,procname) . = "" if(islist(returnval)) var/list/returnedlist = returnval From 83ef5bc47e218f1598865422f80b6dca8e09adf6 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Mon, 18 Jan 2016 01:08:18 +0000 Subject: [PATCH 4/5] newline formatting --- code/modules/admin/verbs/debug.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 790dadefba9..ea2ef2f8fa0 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -196,12 +196,12 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that if(istext(assoc_check) && (returnedlist[assoc_check] != null)) . += "[procname] returned an associative list:" for(var/key in returnedlist) - . += "[key] = [returnedlist[key]]" + . += "[key] = [returnedlist[key]]\n" else . += "[procname] returned a list:" for(var/elem in returnedlist) - . += "[elem]" + . += "[elem]\n" else . = "[procname] returned an empty list" . += "" From cb647aa7301b79b8af1c822414a962b52fd19343 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Mon, 18 Jan 2016 01:30:34 +0000 Subject: [PATCH 5/5] swaps position of newline character, Never produce PRs on a lack of sleep. --- code/modules/admin/verbs/debug.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index ea2ef2f8fa0..cbd90baafab 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -196,12 +196,12 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that if(istext(assoc_check) && (returnedlist[assoc_check] != null)) . += "[procname] returned an associative list:" for(var/key in returnedlist) - . += "[key] = [returnedlist[key]]\n" + . += "\n[key] = [returnedlist[key]]" else . += "[procname] returned a list:" for(var/elem in returnedlist) - . += "[elem]\n" + . += "\n[elem]" else . = "[procname] returned an empty list" . += ""