mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-11 16:14:08 +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:
@@ -337,7 +337,7 @@
|
||||
if(!check_rights(R_BAN))
|
||||
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/player_key
|
||||
@@ -443,7 +443,7 @@
|
||||
else
|
||||
error_state += "No ban type was selected."
|
||||
if(error_state.len)
|
||||
to_chat(usr, "<span class='danger'>Ban not [edit_id ? "edited" : "created"] because the following errors were present:\n[error_state.Join("\n")]</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("Ban not [edit_id ? "edited" : "created"] because the following errors were present:\n[error_state.Join("\n")]"), confidential = TRUE)
|
||||
return
|
||||
if(edit_id)
|
||||
edit_ban(edit_id, player_key, ip_check, player_ip, cid_check, player_cid, use_last_connection, applies_to_admins, duration, interval, reason, mirror_edit, old_key, old_ip, old_cid, old_applies, page, admin_key, changes)
|
||||
@@ -454,7 +454,7 @@
|
||||
if(!check_rights(R_BAN))
|
||||
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/player_ckey = ckey(player_key)
|
||||
if(player_ckey)
|
||||
@@ -501,7 +501,7 @@
|
||||
if(R_EVERYTHING && !(R_EVERYTHING & rank.can_edit_rights)) //edit rights are a more effective way to check hierarchical rank since many non-headmins have R_PERMISSIONS now
|
||||
max_adminbans = MAX_ADMINBANS_PER_HEADMIN
|
||||
if(adminban_count >= max_adminbans)
|
||||
to_chat(usr, "<span class='danger'>You've already logged [max_adminbans] admin ban(s) or more. Do not abuse this function!</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("You've already logged [max_adminbans] admin ban(s) or more. Do not abuse this function!"), confidential = TRUE)
|
||||
qdel(query_check_adminban_count)
|
||||
return
|
||||
qdel(query_check_adminban_count)
|
||||
@@ -567,7 +567,7 @@
|
||||
var/is_admin = FALSE
|
||||
if(C)
|
||||
build_ban_cache(C)
|
||||
to_chat(C, "<span class='boldannounce'>You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]</span><br><span class='danger'>This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].</span><br><span class='danger'>To appeal this ban go to [appeal_url]</span>", confidential = TRUE)
|
||||
to_chat(C, span_boldannounce("You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]</span><br>[span_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]<br><span class='danger'>To appeal this ban go to [appeal_url]"), confidential = TRUE)
|
||||
if(GLOB.admin_datums[C.ckey] || GLOB.deadmins[C.ckey])
|
||||
is_admin = TRUE
|
||||
if(roles_to_ban[1] == "Server" && (!is_admin || (is_admin && applies_to_admins)))
|
||||
@@ -577,7 +577,7 @@
|
||||
for(var/client/i in GLOB.clients - C)
|
||||
if(i.address == player_ip || i.computer_id == player_cid)
|
||||
build_ban_cache(i)
|
||||
to_chat(i, "<span class='boldannounce'>You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]</span><br><span class='danger'>This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].</span><br><span class='danger'>To appeal this ban go to [appeal_url]</span>", confidential = TRUE)
|
||||
to_chat(i, span_boldannounce("You have been [applies_to_admins ? "admin " : ""]banned by [usr.client.key] from [roles_to_ban[1] == "Server" ? "the server" : " Roles: [roles_to_ban.Join(", ")]"].\nReason: [reason]</span><br>[span_danger("This ban is [isnull(duration) ? "permanent." : "temporary, it will be removed in [time_message]."] The round ID is [GLOB.round_id].")]<br><span class='danger'>To appeal this ban go to [appeal_url]"), confidential = TRUE)
|
||||
if(GLOB.admin_datums[i.ckey] || GLOB.deadmins[i.ckey])
|
||||
is_admin = TRUE
|
||||
if(roles_to_ban[1] == "Server" && (!is_admin || (is_admin && applies_to_admins)))
|
||||
@@ -587,7 +587,7 @@
|
||||
if(!check_rights(R_BAN))
|
||||
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/browser/unban_panel = new(usr, "unbanpanel", "Unbanning Panel", 850, 600)
|
||||
unban_panel.add_stylesheet("unbanpanelcss", 'html/admin/unbanpanel.css')
|
||||
@@ -729,7 +729,7 @@
|
||||
if(!check_rights(R_BAN))
|
||||
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/target = ban_target_string(player_key, player_ip, player_cid)
|
||||
if(tgui_alert(usr, "Please confirm unban of [target] from [role].", "Unban confirmation", list("Yes", "No")) == "No")
|
||||
@@ -754,18 +754,18 @@
|
||||
var/client/C = GLOB.directory[player_key]
|
||||
if(C)
|
||||
build_ban_cache(C)
|
||||
to_chat(C, "<span class='boldannounce'>[usr.client.key] has removed a ban from [role] for your key.</span>", confidential = TRUE)
|
||||
to_chat(C, span_boldannounce("[usr.client.key] has removed a ban from [role] for your key."), confidential = TRUE)
|
||||
for(var/client/i in GLOB.clients - C)
|
||||
if(i.address == player_ip || i.computer_id == player_cid)
|
||||
build_ban_cache(i)
|
||||
to_chat(i, "<span class='boldannounce'>[usr.client.key] has removed a ban from [role] for your IP or CID.</span>", confidential = TRUE)
|
||||
to_chat(i, span_boldannounce("[usr.client.key] has removed a ban from [role] for your IP or CID."), confidential = TRUE)
|
||||
unban_panel(player_key, admin_key, player_ip, player_cid, page)
|
||||
|
||||
/datum/admins/proc/edit_ban(ban_id, player_key, ip_check, player_ip, cid_check, player_cid, use_last_connection, applies_to_admins, duration, interval, reason, mirror_edit, old_key, old_ip, old_cid, old_applies, admin_key, page, list/changes)
|
||||
if(!check_rights(R_BAN))
|
||||
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/player_ckey = ckey(player_key)
|
||||
var/bantime
|
||||
@@ -818,7 +818,7 @@
|
||||
if(R_EVERYTHING && !(R_EVERYTHING & rank.can_edit_rights)) //edit rights are a more effective way to check hierarchical rank since many non-headmins have R_PERMISSIONS now
|
||||
max_adminbans = MAX_ADMINBANS_PER_HEADMIN
|
||||
if(adminban_count >= max_adminbans)
|
||||
to_chat(usr, "<span class='danger'>You've already logged [max_adminbans] admin ban(s) or more. Do not abuse this function!</span>", confidential = TRUE)
|
||||
to_chat(usr, span_danger("You've already logged [max_adminbans] admin ban(s) or more. Do not abuse this function!"), confidential = TRUE)
|
||||
qdel(query_check_adminban_count)
|
||||
return
|
||||
qdel(query_check_adminban_count)
|
||||
@@ -886,18 +886,18 @@
|
||||
var/client/C = GLOB.directory[old_key]
|
||||
if(C)
|
||||
build_ban_cache(C)
|
||||
to_chat(C, "<span class='boldannounce'>[usr.client.key] has edited the [changes_keys_text] of a ban for your key.</span>", confidential = TRUE)
|
||||
to_chat(C, span_boldannounce("[usr.client.key] has edited the [changes_keys_text] of a ban for your key."), confidential = TRUE)
|
||||
for(var/client/i in GLOB.clients - C)
|
||||
if(i.address == old_ip || i.computer_id == old_cid)
|
||||
build_ban_cache(i)
|
||||
to_chat(i, "<span class='boldannounce'>[usr.client.key] has edited the [changes_keys_text] of a ban for your IP or CID.</span>", confidential = TRUE)
|
||||
to_chat(i, span_boldannounce("[usr.client.key] has edited the [changes_keys_text] of a ban for your IP or CID."), confidential = TRUE)
|
||||
unban_panel(player_key, null, null, null, page)
|
||||
|
||||
/datum/admins/proc/ban_log(ban_id)
|
||||
if(!check_rights(R_BAN))
|
||||
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_get_ban_edits = SSdbcore.NewQuery({"
|
||||
SELECT edits FROM [format_table_name("ban")] WHERE id = :ban_id
|
||||
|
||||
Reference in New Issue
Block a user