diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2.dm b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
index 8a51495f541..1c5876db7b6 100644
--- a/code/modules/admin/verbs/SDQL2/SDQL_2.dm
+++ b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
@@ -1,7 +1,7 @@
// Code taken from /bay/station.
/client/proc/SDQL2_query(query_text as message)
- set category = "Admin"
+ set category = "Debug"
if(!check_rights(R_DEBUG)) //Shouldn't happen... but just to be safe.
message_admins("\red ERROR: Non-admin [usr.key] attempted to execute a SDQL query!")
log_admin("Non-admin [usr.key] attempted to execute a SDQL query!")
@@ -63,6 +63,19 @@
message_admins("[usr] executed SDQL query: \"[query_text]\".")
switch(query_tree[1])
+ if("call")
+ var/list/call_list = query_tree["call"]
+ var/list/args_list = query_tree["args"]
+
+ for(var/datum/d in objs)
+ for(var/v in call_list)
+ // To stop any procs which sleep from executing slowly.
+ if(d)
+ if(hascall(d, v))
+ // Replace _ with a space because BYOND doesn't like it in call, hascall loves it though! (Really I can't believe this myself)
+ var/sanitized_v = replacetext(v, "_", " ")
+ spawn() call(d, sanitized_v)(arglist(args_list)) // Spawn in case the function sleeps.
+
if("delete")
for(var/datum/d in objs)
del d
@@ -70,20 +83,21 @@
if("select")
var/text = ""
for(var/datum/t in objs)
+ text += "\ref[t]"
if(istype(t, /atom))
var/atom/a = t
if(a.x)
- text += "\ref[t]: [t] at ([a.x], [a.y], [a.z])
"
+ text += ": [t] at ([a.x], [a.y], [a.z])
"
else if(a.loc && a.loc.x)
- text += "\ref[t]: [t] in [a.loc] at ([a.loc.x], [a.loc.y], [a.loc.z])
"
+ text += ": [t] in [a.loc] at ([a.loc.x], [a.loc.y], [a.loc.z])
"
else
- text += "\ref[t]: [t]
"
+ text += ": [t]
"
else
- text += "\ref[t]: [t]
"
+ text += ": [t]
"
usr << browse(text, "window=SDQL-result")
@@ -129,22 +143,22 @@
for(var/item in query_tree)
if(istype(item, /list))
- world << "[spaces]("
+ usr << "[spaces]("
SDQL_testout(item, indent + 1)
- world << "[spaces])"
+ usr << "[spaces])"
else
- world << "[spaces][item]"
+ usr << "[spaces][item]"
if(!isnum(item) && query_tree[item])
if(istype(query_tree[item], /list))
- world << "[spaces] ("
+ usr << "[spaces] ("
SDQL_testout(query_tree[item], indent + 2)
- world << "[spaces] )"
+ usr << "[spaces] )"
else
- world << "[spaces] [query_tree[item]]"
+ usr << "[spaces] [query_tree[item]]"
@@ -422,5 +436,4 @@
if(word != "")
query_list += word
-
return query_list
\ No newline at end of file
diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
index d1d30b33b5e..8aac5b930e9 100644
--- a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
+++ b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
@@ -216,10 +216,12 @@
//call_query: 'CALL' call_function ['ON' select_list [('FROM' | 'IN') from_list] ['WHERE' bool_expression]]
call_query(i, list/node)
var/list/func = list()
- i = call_function(i + 1, func)
+ var/list/arguments = list()
+ i = call_function(i + 1, func, arguments)
node += "call"
node["call"] = func
+ node["args"] = arguments
if(tokenl(i) != "on")
return i
@@ -404,11 +406,22 @@
//call_function: ['(' [arguments] ')']
- call_function(i, list/node)
-
- parse_error("Sorry, function calls aren't available yet")
-
- return i
+ call_function(i, list/node, list/arguments)
+ if(length(tokenl(i)))
+ node += token(i++)
+ if(token(i) != "(")
+ parse_error("Expected ( but found '[token(i)]'")
+ else if(token(i + 1) != ")")
+ do
+ i = expression(i + 1, arguments)
+ if(token(i) == ",")
+ continue
+ while(token(i) && token(i) != ")")
+ else
+ i++
+ else
+ parse_error("Expected a function but found nothing")
+ return i + 1
//select_function: count_function
diff --git a/code/modules/admin/verbs/mapping.dm b/code/modules/admin/verbs/mapping.dm
index 8ac539f6c79..1f57e890332 100644
--- a/code/modules/admin/verbs/mapping.dm
+++ b/code/modules/admin/verbs/mapping.dm
@@ -147,6 +147,7 @@ var/intercom_range_display_status = 0
src.verbs += /client/proc/disable_movement
src.verbs += /client/proc/print_pointers
src.verbs += /client/proc/count_movable_instances
+ src.verbs += /client/proc/SDQL2_query
//src.verbs += /client/proc/cmd_admin_rejuvenate
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!