Added support for calling procs via SQDL.

Moved the verb category to "Debug".
Added the verb to the "Debug verbs" button.
This commit is contained in:
Giacomand
2014-01-18 18:59:02 +00:00
parent 1aa4cf3648
commit b9011097a4
3 changed files with 45 additions and 18 deletions
+25 -12
View File
@@ -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 += "<A HREF='?_src_=vars;Vars=\ref[t]'>\ref[t]</A>"
if(istype(t, /atom))
var/atom/a = t
if(a.x)
text += "<a href='?src=\ref[t];SDQL_select=\ref[t]'>\ref[t]</a>: [t] at ([a.x], [a.y], [a.z])<br>"
text += ": [t] at ([a.x], [a.y], [a.z])<br>"
else if(a.loc && a.loc.x)
text += "<a href='?src=\ref[t];SDQL_select=\ref[t]'>\ref[t]</a>: [t] in [a.loc] at ([a.loc.x], [a.loc.y], [a.loc.z])<br>"
text += ": [t] in [a.loc] at ([a.loc.x], [a.loc.y], [a.loc.z])<br>"
else
text += "<a href='?src=\ref[t];SDQL_select=\ref[t]'>\ref[t]</a>: [t]<br>"
text += ": [t]<br>"
else
text += "<a href='?src=\ref[t];SDQL_select=\ref[t]'>\ref[t]</a>: [t]<br>"
text += ": [t]<br>"
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
@@ -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: <function name> ['(' [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