From 8bf22eb50adb8eb45bd09e640e49f7b04f8b6098 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Sun, 4 Oct 2020 12:59:11 -0700
Subject: [PATCH] Update SDQL_2.dm
---
code/modules/admin/verbs/SDQL2/SDQL_2.dm | 96 +++++++++++++++---------
1 file changed, 61 insertions(+), 35 deletions(-)
diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2.dm b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
index 9c9155e9436..6b26ec1b58d 100644
--- a/code/modules/admin/verbs/SDQL2/SDQL_2.dm
+++ b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
@@ -719,47 +719,73 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
obj_count_finished = obj_count_finished.len
state = SDQL2_STATE_SWITCHING
-/datum/SDQL2_query/proc/SDQL_print(object, list/text_list, print_nulls = TRUE)
+
+/**
+ * Recursively prints out an object to text list for SDQL2 output to admins, with VV links and all.
+ * Recursion limit: 50
+ * Limit imposed by callers should be around 10000 objects
+ * Seriously, if you hit those limits, you're doing something wrong.
+ */
+/datum/SDQL2_query/proc/SDQL_print(datum/object, list/text_list, print_nulls = TRUE, recursion = 1, linebreak = TRUE)
+ if(recursion > 50)
+ text_list += "
RECURSION LIMIT REACHED.
"
+ return
if(is_object_datatype(object))
- text_list += "[REF(object)] : [object]"
- if(istype(object, /atom))
- var/atom/A = object
- var/turf/T = A.loc
- var/area/a
- if(istype(T))
- text_list += " at [T] [ADMIN_COORDJMP(T)]"
- a = T.loc
- else
- var/turf/final = get_turf(T) //Recursive, hopefully?
- if(istype(final))
- text_list += " at [final] [ADMIN_COORDJMP(final)]"
- a = final.loc
+ if(!islist(object))
+ text_list += "[object.type] [REF(object)]: [object]"
+ if(istype(object, /atom))
+ if(istype(object, /turf))
+ var/turf/T = object
+ text_list += " [ADMIN_COORDJMP(T)] at [T.loc]"
else
- text_list += " at nonexistant location"
- if(a)
- text_list += " in area [a]"
- if(T.loc != a)
- text_list += " inside [T]"
- text_list += "
"
- else if(islist(object))
- var/list/L = object
- var/first = TRUE
- text_list += "\["
- for (var/x in L)
- if (!first)
- text_list += ", "
- first = FALSE
- SDQL_print(x, text_list)
- if (!isnull(x) && !isnum(x) && L[x] != null)
- text_list += " -> "
- SDQL_print(L[L[x]])
- text_list += "]
"
+ var/atom/A = object
+ var/atom/container = A.loc
+ if(isturf(container))
+ text_list += " in [container] [ADMIN_COORDJMP(container)] at [container.loc]"
+ else if(container)
+ var/turf/T = get_turf(container)
+ var/cref = REF(container)
+ text_list += " in [container]([cref])"
+ if(T)
+ text_list += " on [T] [ADMIN_COORDJMP(T)] at[T.loc]"
+ else
+ text_list += " in nullspace"
+ else // lists are snowflake and get special treatment.
+ text_list += "/list [REF(object)] \[
"
+ var/list/L = object
+ if(length(L))
+ for(var/key in object)
+ if(islist(key))
+ text_list += ""
+ SDQL_print(key, text_list, TRUE, recursion + 1, FALSE)
+ text_list += ""
+ else
+ SDQL_print(key, text_list, TRUE, recursion, FALSE)
+ if(IS_VALID_ASSOC_KEY(key) && !isnull(L[key]))
+ var/value = L[key]
+ text_list += " --> "
+ if(islist(value))
+ text_list += ""
+ SDQL_print(value, text_list, TRUE, recursion + 1, FALSE)
+ text_list += ""
+ else
+ SDQL_print(value, text_list, TRUE, recursion, FALSE)
+ text_list += "
"
+ text_list += "\]"
+ if(linebreak)
+ text_list += "
"
else
if(isnull(object))
if(print_nulls)
- text_list += "NULL
"
+ text_list += "NULL"
+ else if(istext(object))
+ text_list += "\"[object]\""
+ else if(isnum(object) || ispath(object))
+ text_list += "[object]"
else
- text_list += "[object]
"
+ text_list += "UNKNOWN: [object]"
+ if(linebreak)
+ text_list += "
"
/datum/SDQL2_query/CanProcCall()
if(!allow_admin_interact)