mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 04:26:03 +01:00
Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs. Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines. Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing. Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc. (Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
This commit is contained in:
@@ -203,7 +203,7 @@
|
||||
/client/proc/SDQL2_query(query_text as message)
|
||||
set category = "Debug"
|
||||
if(!check_rights(R_DEBUG)) //Shouldn't happen... but just to be safe.
|
||||
message_admins("<span class='danger'>ERROR: Non-admin [key_name(usr)] attempted to execute a SDQL query!</span>")
|
||||
message_admins(span_danger("ERROR: Non-admin [key_name(usr)] attempted to execute a SDQL query!"))
|
||||
log_admin("Non-admin [key_name(usr)] attempted to execute a SDQL query!")
|
||||
return FALSE
|
||||
var/list/results = world.SDQL2_query(query_text, key_name_admin(usr), "[key_name(usr)]")
|
||||
@@ -248,7 +248,7 @@
|
||||
running += query
|
||||
var/msg = "Starting query #[query.id] - [query.get_query_text()]."
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='admin'>[msg]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_admin("[msg]"), confidential = TRUE)
|
||||
log_admin(msg)
|
||||
query.ARun()
|
||||
else //Start all
|
||||
@@ -256,7 +256,7 @@
|
||||
running += query
|
||||
var/msg = "Starting query #[query.id] - [query.get_query_text()]."
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='admin'>[msg]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_admin("[msg]"), confidential = TRUE)
|
||||
log_admin(msg)
|
||||
query.ARun()
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
finished = FALSE
|
||||
if(query.state == SDQL2_STATE_ERROR)
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='admin'>SDQL query [query.get_query_text()] errored. It will NOT be automatically garbage collected. Please remove manually.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_admin("SDQL query [query.get_query_text()] errored. It will NOT be automatically garbage collected. Please remove manually."), confidential = TRUE)
|
||||
running -= query
|
||||
else
|
||||
if(query.finished)
|
||||
@@ -294,19 +294,19 @@
|
||||
running += next_query
|
||||
var/msg = "Starting query #[next_query.id] - [next_query.get_query_text()]."
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='admin'>[msg]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_admin("[msg]"), confidential = TRUE)
|
||||
log_admin(msg)
|
||||
next_query.ARun()
|
||||
else
|
||||
if(usr)
|
||||
to_chat(usr, "<span class='admin'>SDQL query [query.get_query_text()] was halted. It will NOT be automatically garbage collected. Please remove manually.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_admin("SDQL query [query.get_query_text()] was halted. It will NOT be automatically garbage collected. Please remove manually."), confidential = TRUE)
|
||||
running -= query
|
||||
while(!finished)
|
||||
|
||||
var/end_time_total = REALTIMEOFDAY - start_time_total
|
||||
return list("<span class='admin'>SDQL query combined results: [query_text]</span>",\
|
||||
"<span class='admin'>SDQL query completed: [objs_all] objects selected by path, and [selectors_used ? objs_eligible : objs_all] objects executed on after WHERE filtering/MAPping if applicable.</span>",\
|
||||
"<span class='admin'>SDQL combined querys took [DisplayTimeText(end_time_total)] to complete.</span>") + combined_refs
|
||||
return list(span_admin("SDQL query combined results: [query_text]"),\
|
||||
span_admin("SDQL query completed: [objs_all] objects selected by path, and [selectors_used ? objs_eligible : objs_all] objects executed on after WHERE filtering/MAPping if applicable."),\
|
||||
span_admin("SDQL combined querys took [DisplayTimeText(end_time_total)] to complete.")) + combined_refs
|
||||
|
||||
GLOBAL_LIST_INIT(sdql2_queries, GLOB.sdql2_queries || list())
|
||||
GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null, "VIEW VARIABLES (all)", null))
|
||||
@@ -860,7 +860,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null
|
||||
if("or", "||")
|
||||
result = (result || val)
|
||||
else
|
||||
to_chat(usr, "<span class='danger'>SDQL2: Unknown op [op]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("SDQL2: Unknown op [op]"), confidential = TRUE)
|
||||
result = null
|
||||
else
|
||||
result = val
|
||||
@@ -970,7 +970,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null
|
||||
querys[querys_pos] = parsed_tree
|
||||
querys_pos++
|
||||
else //There was an error so don't run anything, and tell the user which query has errored.
|
||||
to_chat(usr, "<span class='danger'>Parsing error on [querys_pos]\th query. Nothing was executed.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Parsing error on [querys_pos]\th query. Nothing was executed."), confidential = TRUE)
|
||||
return list()
|
||||
query_tree = list()
|
||||
do_parse = 0
|
||||
@@ -1016,16 +1016,16 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null
|
||||
D = object
|
||||
|
||||
if (object == world && (!long || expression[start + 1] == ".") && !(expression[start] in exclude) && copytext(expression[start], 1, 3) != "SS") //3 == length("SS") + 1
|
||||
to_chat(usr, "<span class='danger'>World variables are not allowed to be accessed. Use global.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("World variables are not allowed to be accessed. Use global."), confidential = TRUE)
|
||||
return null
|
||||
|
||||
else if(expression [start] == "{" && long)
|
||||
if(lowertext(copytext(expression[start + 1], 1, 3)) != "0x") //3 == length("0x") + 1
|
||||
to_chat(usr, "<span class='danger'>Invalid pointer syntax: [expression[start + 1]]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Invalid pointer syntax: [expression[start + 1]]"), confidential = TRUE)
|
||||
return null
|
||||
v = locate("\[[expression[start + 1]]]")
|
||||
if(!v)
|
||||
to_chat(usr, "<span class='danger'>Invalid pointer: [expression[start + 1]]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Invalid pointer: [expression[start + 1]]"), confidential = TRUE)
|
||||
return null
|
||||
start++
|
||||
long = start < expression.len
|
||||
@@ -1088,7 +1088,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null
|
||||
var/list/L = v
|
||||
var/index = query.SDQL_expression(source, expression[start + 2])
|
||||
if(isnum(index) && (!ISINTEGER(index) || L.len < index))
|
||||
to_chat(usr, "<span class='danger'>Invalid list index: [index]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Invalid list index: [index]"), confidential = TRUE)
|
||||
return null
|
||||
return L[index]
|
||||
return v
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
/datum/sdql_parser/proc/parse_error(error_message)
|
||||
error = 1
|
||||
to_chat(usr, "<span class='warning'>SDQL2 Parsing Error: [error_message]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_warning("SDQL2 Parsing Error: [error_message]"), confidential = TRUE)
|
||||
return query.len + 1
|
||||
|
||||
/datum/sdql_parser/proc/parse()
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
var/datum/give_sdql_spell/ui = new(usr, target)
|
||||
ui.ui_interact(usr)
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>SDQL spells are disabled.</span>")
|
||||
to_chat(usr, span_warning("SDQL spells are disabled."))
|
||||
|
||||
|
||||
/datum/give_sdql_spell
|
||||
@@ -306,7 +306,7 @@
|
||||
|
||||
/datum/give_sdql_spell/New(_user, target)
|
||||
if(!CONFIG_GET(flag/sdql_spells))
|
||||
to_chat(_user, "<span class='warning'>SDQL spells are disabled.</span>")
|
||||
to_chat(_user, span_warning("SDQL spells are disabled."))
|
||||
qdel(src)
|
||||
return
|
||||
user = CLIENT_FROM_VAR(_user)
|
||||
@@ -845,4 +845,4 @@
|
||||
target_mob.mind.AddSpell(new_spell)
|
||||
else
|
||||
target_mob.AddSpell(new_spell)
|
||||
to_chat(user, "<span class='danger'>Spells given to mindless mobs will not be transferred in mindswap or cloning!</span>")
|
||||
to_chat(user, span_danger("Spells given to mindless mobs will not be transferred in mindswap or cloning!"))
|
||||
|
||||
Reference in New Issue
Block a user