Merge pull request #8272 from VOREStation/Arokha/moresafe

Add more safety around the hours query
This commit is contained in:
Novacat
2020-06-14 15:24:17 -04:00
committed by GitHub
2 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -53,8 +53,8 @@
var/related_accounts_cid = "(Requires database)" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id
var/account_join_date = "(Requires database)"
var/account_age = "(Requires database)"
var/list/department_hours // VOREStation Edit - Track hours of leave accured for each department.
var/list/play_hours // VOREStation Edit - Tracks total playtime hours for each departments.
var/list/department_hours = list() // VOREStation Edit - Track hours of leave accured for each department.
var/list/play_hours = list() // VOREStation Edit - Tracks total playtime hours for each departments.
preload_rsc = PRELOAD_RSC
+7 -5
View File
@@ -359,14 +359,16 @@
log_admin("Couldn't perform IP check on [key] with [address]")
// VOREStation Edit Start - Department Hours
if(config.time_off)
var/DBQuery/query_hours = dbcon.NewQuery("SELECT department, hours, total_hours FROM vr_player_hours WHERE ckey = '[sql_ckey]'")
query_hours.Execute()
LAZYINITLIST(department_hours)
LAZYINITLIST(play_hours)
var/DBQuery/query_hours = dbcon.NewQuery("SELECT department, hours, total_hours FROM vr_player_hours WHERE ckey = '[sql_ckey]'")
if(query_hours.Execute())
while(query_hours.NextRow())
department_hours[query_hours.item[1]] = text2num(query_hours.item[2])
play_hours[query_hours.item[1]] = text2num(query_hours.item[3])
else
var/error_message = query_hours.ErrorMsg() // Need this out here since the spawn below will split the stack and who knows what'll happen by the time it runs
log_debug("Error loading play hours for [ckey]: [error_message]")
spawn(0)
alert(src, "The query to load your existing playtime failed. Screenshot this, give the screenshot to a developer, and reconnect, otherwise you may lose any recorded play hours (which may limit access to jobs). ERROR: [error_message]", "PROBLEMS!!")
// VOREStation Edit End - Department Hours
if(sql_id)