mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 23:58:07 +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:
@@ -245,7 +245,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/list/error_state = list()
|
||||
var/new_poll = FALSE
|
||||
@@ -309,9 +309,9 @@
|
||||
error_state += "This poll type requires at least one option."
|
||||
if(error_state.len)
|
||||
if(poll.edit_ready)
|
||||
to_chat(usr, "<span class='danger'>Not all edits were applied because the following errors were present:\n[error_state.Join("\n")]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Not all edits were applied because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
|
||||
else
|
||||
to_chat(usr, "<span class='danger'>Poll not [new_poll ? "initialized" : "submitted"] because the following errors were present:\n[error_state.Join("\n")]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Poll not [new_poll ? "initialized" : "submitted"] because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
|
||||
if(new_poll)
|
||||
qdel(poll)
|
||||
return
|
||||
@@ -354,7 +354,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/datum/db_query/query_delete_poll = SSdbcore.NewQuery(
|
||||
"CALL set_poll_deleted(:poll_id)",
|
||||
@@ -383,7 +383,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/new_poll = !poll_id
|
||||
if(poll_type != POLLTYPE_MULTI)
|
||||
@@ -446,7 +446,7 @@
|
||||
*/
|
||||
/datum/poll_question/proc/save_all_options()
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
for(var/o in options)
|
||||
var/datum/poll_option/option = o
|
||||
@@ -460,7 +460,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/table = "poll_vote"
|
||||
if(poll_type == POLLTYPE_TEXT)
|
||||
@@ -474,7 +474,7 @@
|
||||
return
|
||||
qdel(query_clear_poll_votes)
|
||||
poll_votes = 0
|
||||
to_chat(usr, "<span class='danger'>Poll [poll_type == POLLTYPE_TEXT ? "responses" : "votes"] cleared.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Poll [poll_type == POLLTYPE_TEXT ? "responses" : "votes"] cleared."), confidential = TRUE)
|
||||
|
||||
/**
|
||||
* Show the options for creating a poll option or editing its parameters.
|
||||
@@ -543,7 +543,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/list/error_state = list()
|
||||
var/new_option = FALSE
|
||||
@@ -601,10 +601,10 @@
|
||||
option.desc_max = null
|
||||
if(error_state.len)
|
||||
if(new_option)
|
||||
to_chat(usr, "<span class='danger'>Option not added because the following errors were present:\n[error_state.Join("\n")]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Option not added because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
|
||||
qdel(option)
|
||||
else
|
||||
to_chat(usr, "<span class='danger'>Not all edits were applied because the following errors were present:\n[error_state.Join("\n")]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Not all edits were applied because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
|
||||
return
|
||||
if(new_option)
|
||||
poll.options += option
|
||||
@@ -641,7 +641,7 @@
|
||||
if(!check_rights(R_POLL))
|
||||
return
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
|
||||
var/list/values = list("text" = text, "default_percentage_calc" = default_percentage_calc, "pollid" = parent_poll.poll_id, "id" = option_id)
|
||||
@@ -677,7 +677,7 @@
|
||||
. = parent_poll
|
||||
if(option_id)
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/datum/db_query/query_delete_poll_option = SSdbcore.NewQuery(
|
||||
"UPDATE [format_table_name("poll_option")] AS o INNER JOIN [format_table_name("poll_vote")] AS v ON o.id = v.optionid SET o.deleted = 1, v.deleted = 1 WHERE o.id = :option_id",
|
||||
@@ -695,7 +695,7 @@
|
||||
*/
|
||||
/proc/load_poll_data()
|
||||
if(!SSdbcore.Connect())
|
||||
to_chat(usr, "<span class='danger'>Failed to establish database connection.</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Failed to establish database connection."), confidential = TRUE)
|
||||
return
|
||||
var/datum/db_query/query_load_polls = SSdbcore.NewQuery("SELECT id, polltype, starttime, endtime, question, subtitle, adminonly, multiplechoiceoptions, dontshow, allow_revoting, IF(polltype='TEXT',(SELECT COUNT(ckey) FROM [format_table_name("poll_textreply")] AS t WHERE t.pollid = q.id AND deleted = 0), (SELECT COUNT(DISTINCT ckey) FROM [format_table_name("poll_vote")] AS v WHERE v.pollid = q.id AND deleted = 0)), IFNULL((SELECT byond_key FROM [format_table_name("player")] AS p WHERE p.ckey = q.createdby_ckey), createdby_ckey), IF(starttime > NOW(), 1, 0) FROM [format_table_name("poll_question")] AS q WHERE NOW() < endtime AND deleted = 0")
|
||||
if(!query_load_polls.Execute())
|
||||
|
||||
Reference in New Issue
Block a user