Files
Bubberstation/code/modules/admin/verbs/reestablish_db_connection.dm
Watermelon914 375a20e49b 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)
2021-06-14 13:03:53 -07:00

31 lines
1.6 KiB
Plaintext

/client/proc/reestablish_db_connection()
set category = "Server"
set name = "Reestablish DB Connection"
if (!CONFIG_GET(flag/sql_enabled))
to_chat(usr, span_adminnotice("The Database is not enabled!"), confidential = TRUE)
return
if (SSdbcore.IsConnected())
if (!check_rights(R_DEBUG,0))
tgui_alert(usr,"The database is already connected! (Only those with +debug can force a reconnection)", "The database is already connected!")
return
var/reconnect = tgui_alert(usr,"The database is already connected! If you *KNOW* that this is incorrect, you can force a reconnection", "The database is already connected!", list("Force Reconnect", "Cancel"))
if (reconnect != "Force Reconnect")
return
SSdbcore.Disconnect()
log_admin("[key_name(usr)] has forced the database to disconnect")
message_admins("[key_name_admin(usr)] has <b>forced</b> the database to disconnect!")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Force Reestablished Database Connection") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
log_admin("[key_name(usr)] is attempting to re-establish the DB Connection")
message_admins("[key_name_admin(usr)] is attempting to re-establish the DB Connection")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Reestablished Database Connection") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
SSdbcore.failed_connections = 0
if(!SSdbcore.Connect())
message_admins("Database connection failed: " + SSdbcore.ErrorMsg())
else
message_admins("Database connection re-established")