Fix runtime errors while running without a connected database (#11473)

This commit is contained in:
Wildkins
2021-03-19 22:08:00 +01:00
committed by GitHub
parent 5e40f9145c
commit a07700f8a6
16 changed files with 47 additions and 96 deletions
+5 -9
View File
@@ -134,8 +134,7 @@ var/list/localhost_addresses = list(
var/request_id = text2num(href_list["linkingrequest"])
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
to_chat(src, "<span class='warning'>Action failed! Database link could not be established!</span>")
return
@@ -483,8 +482,7 @@ var/list/localhost_addresses = list(
// Returns null if no DB connection can be established, or -1 if the requested key was not found in the database
/proc/get_player_age(key)
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
return null
var/DBQuery/query = dbcon.NewQuery("SELECT datediff(Now(),firstseen) as age FROM ss13_player WHERE ckey = :ckey:")
@@ -618,8 +616,7 @@ var/list/localhost_addresses = list(
if (!config.webint_url || !config.sql_enabled)
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return
var/list/requests = list()
@@ -656,8 +653,7 @@ var/list/localhost_addresses = list(
if (!config.webint_url || !config.sql_enabled)
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return
var/DBQuery/select_query = dbcon.NewQuery("SELECT COUNT(*) AS request_count FROM ss13_player_linking WHERE status = 'new' AND player_ckey = :ckey: AND deleted_at IS NULL")
@@ -776,4 +772,4 @@ var/list/localhost_addresses = list(
var/obj/item/rfd/mining/RFDM = I
RFDM.afterattack(over_object, M, proximity, params, FALSE)
CHECK_TICK
CHECK_TICK
+1 -2
View File
@@ -508,8 +508,7 @@ datum/preferences
for(var/ckey in preferences_datums)
var/datum/preferences/D = preferences_datums[ckey]
if(D == src)
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
return open_load_dialog_file(user)
var/DBQuery/query = dbcon.NewQuery("SELECT id, name FROM ss13_characters WHERE ckey = :ckey: AND deleted_at IS NULL ORDER BY id ASC")