mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-23 21:12:24 +01:00
Generalizing establish_db_connection() and setup_database_connection()
Both procs are now generalized, and accept a DBConnection object as an argument. Due to this generalization, all instances of `establish_db_connection()` must be renamed to `establish_db_connection(dbcon)`. Also added variable `failed_connections` to the definition of DBConnection.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
if (!ckey || !address || !computer_id || !ban_id)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (!dbcon.IsConnected())
|
||||
error("Ban database connection failure while attempting to mirror. Key passed for mirror handling: [ckey].")
|
||||
|
||||
@@ -4,7 +4,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration =
|
||||
|
||||
if(!check_rights(R_MOD,0) && !check_rights(R_BAN)) return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
@@ -122,7 +122,7 @@ datum/admins/proc/DB_ban_unban(var/ckey, var/bantype, var/job = "")
|
||||
if(job)
|
||||
sql += " AND job = '[job]'"
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
@@ -217,7 +217,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id)
|
||||
|
||||
var/sql = "SELECT ckey FROM ss13_ban WHERE id = [id]"
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
@@ -269,7 +269,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id)
|
||||
|
||||
if(!check_rights(R_BAN)) return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "\red Failed to establish database connection"
|
||||
return
|
||||
|
||||
@@ -34,7 +34,7 @@ world/IsBanned(key,address,computer_id)
|
||||
|
||||
var/ckeytext = ckey(key)
|
||||
|
||||
if(!establish_db_connection())
|
||||
if(!establish_db_connection(dbcon))
|
||||
error("Ban database connection failure. Key [ckeytext] not checked")
|
||||
log_misc("Ban database connection failure. Key [ckeytext] not checked")
|
||||
return
|
||||
|
||||
@@ -102,7 +102,7 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
|
||||
else
|
||||
//The current admin system uses SQL
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
error("Failed to connect to database in load_admins(). Reverting to legacy system.")
|
||||
log_misc("Failed to connect to database in load_admins(). Reverting to legacy system.")
|
||||
|
||||
@@ -65,7 +65,7 @@ DEBUG
|
||||
jobban_keylist=list()
|
||||
log_admin("jobban_keylist was empty")
|
||||
else
|
||||
if(!establish_db_connection())
|
||||
if(!establish_db_connection(dbcon))
|
||||
error("Database connection failed. Reverting to the legacy ban system.")
|
||||
log_misc("Database connection failed. Reverting to the legacy ban system.")
|
||||
config.ban_legacy_system = 1
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
usr << "\red You do not have permission to do this!"
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "\red Failed to establish database connection"
|
||||
@@ -104,7 +104,7 @@
|
||||
usr << "\red You do not have permission to do this!"
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "\red Failed to establish database connection"
|
||||
return
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
else
|
||||
query_details[":a_ckey"] = user.ckey
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
alert("SQL connection failed while trying to add a note!")
|
||||
return
|
||||
@@ -36,7 +36,7 @@
|
||||
if (!note_id || !note_edit)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
error("SQL connection failed while attempting to delete a note!")
|
||||
return
|
||||
@@ -93,7 +93,7 @@
|
||||
player_ckey = ckey(player_ckey)
|
||||
admin_ckey = ckey(admin_ckey)
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
error("SQL connection failed while attempting to view a player's notes!")
|
||||
return
|
||||
@@ -187,7 +187,7 @@
|
||||
if (!ckey)
|
||||
return "No ckey given!"
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (!dbcon.IsConnected())
|
||||
return "Unable to establish database connection! Aborting!"
|
||||
@@ -231,7 +231,7 @@
|
||||
note_list >> note_keys
|
||||
|
||||
msg_scopes("Establishing DB connection!")
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
msg_scopes("No DB connection!")
|
||||
return
|
||||
|
||||
@@ -29,7 +29,7 @@ var/inactive_keys = "None<br>"
|
||||
if(checked_for_inactives)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
if (!warned_ckey || !istext(warned_ckey))
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
usr << "<font color='red'>Error: warn(): Database Connection failed, reverting to legacy systems.</font>"
|
||||
usr.client.warn_legacy(warned_ckey)
|
||||
@@ -110,7 +110,7 @@
|
||||
var/dcolor = "#ffaaaa" //dark colour, severity = 1
|
||||
var/ecolor = "#e3e3e3" //gray colour, expired = 1
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
alert("Connection to the SQL database lost. Aborting. Please alert an Administrator or a member of staff.")
|
||||
return
|
||||
@@ -172,7 +172,7 @@
|
||||
if (!warning_id)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
alert("Connection to SQL database failed while attempting to update your warning's status!")
|
||||
return
|
||||
@@ -191,7 +191,7 @@
|
||||
var/count = 0
|
||||
var/count_expire = 0
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
var/dcolor = "#ffdddd" //dark colour, severity = 1
|
||||
var/ecolor = "#e3e3e3" //gray colour, expired = 1
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if (!dbcon.IsConnected())
|
||||
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
|
||||
return
|
||||
@@ -342,7 +342,7 @@
|
||||
if(!warning_id || !warning_edit)
|
||||
return
|
||||
|
||||
establish_db_connection()
|
||||
establish_db_connection(dbcon)
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user