Merge pull request #9302 from deathride58/jobcodesanitychecks

fixes roundstart runtimes by job_preferences index checks be explicit key checks instead, plus some extra sanity checks
This commit is contained in:
kevinz000
2019-09-17 22:00:59 -07:00
committed by GitHub
4 changed files with 18 additions and 18 deletions
+7 -7
View File
@@ -1039,7 +1039,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/available_in_days = job.available_in_days(user.client)
HTML += "<font color=red>[rank]</font></td><td><font color=red> \[IN [(available_in_days)] DAYS\]</font></td></tr>"
continue
if((job_preferences[SSjob.overflow_role] == JP_LOW) && (rank != SSjob.overflow_role) && !jobban_isbanned(user, SSjob.overflow_role))
if((job_preferences["[SSjob.overflow_role]"] == JP_LOW) && (rank != SSjob.overflow_role) && !jobban_isbanned(user, SSjob.overflow_role))
HTML += "<font color=orange>[rank]</font></td><td></td></tr>"
continue
if((rank in GLOB.command_positions) || (rank == "AI"))//Bold head jobs
@@ -1054,7 +1054,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/prefUpperLevel = -1 // level to assign on left click
var/prefLowerLevel = -1 // level to assign on right click
switch(job_preferences[job.title])
switch(job_preferences["[job.title]"])
if(JP_HIGH)
prefLevelLabel = "High"
prefLevelColor = "slateblue"
@@ -1079,7 +1079,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
HTML += "<a class='white' href='?_src_=prefs;preference=job;task=setJobLevel;level=[prefUpperLevel];text=[rank]' oncontextmenu='javascript:return setJobPrefRedirect([prefLowerLevel], \"[rank]\");'>"
if(rank == SSjob.overflow_role)//Overflow is special
if(job_preferences[SSjob.overflow_role] == JP_LOW)
if(job_preferences["[SSjob.overflow_role]"] == JP_LOW)
HTML += "<font color=green>Yes</font>"
else
HTML += "<font color=red>No</font>"
@@ -1115,11 +1115,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if (level == JP_HIGH) // to high
//Set all other high to medium
for(var/j in job_preferences)
if(job_preferences[j] == JP_HIGH)
job_preferences[j] = JP_MEDIUM
if(job_preferences["[j]"] == JP_HIGH)
job_preferences["[j]"] = JP_MEDIUM
//technically break here
job_preferences[job.title] = level
job_preferences["[job.title]"] = level
return TRUE
/datum/preferences/proc/UpdateJobPreference(mob/user, role, desiredLvl)
@@ -1147,7 +1147,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
jpval = JP_HIGH
if(role == SSjob.overflow_role)
if(job_preferences[job.title] == JP_LOW)
if(job_preferences["[job.title]"] == JP_LOW)
jpval = null
else
jpval = JP_LOW
+2 -2
View File
@@ -105,7 +105,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
else if(job_engsec_low & fval)
new_value = JP_LOW
if(new_value)
job_preferences[initial(J.title)] = new_value
job_preferences["[initial(J.title)]"] = new_value
else if(current_version < 23) // we are fixing a gamebreaking bug.
job_preferences = list() //It loaded null from nonexistant savefile field.
@@ -489,7 +489,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
joblessrole = sanitize_integer(joblessrole, 1, 3, initial(joblessrole))
//Validate job prefs
for(var/j in job_preferences)
if(job_preferences[j] != JP_LOW && job_preferences[j] != JP_MEDIUM && job_preferences[j] != JP_HIGH)
if(job_preferences["[j]"] != JP_LOW && job_preferences["[j]"] != JP_MEDIUM && job_preferences["[j]"] != JP_HIGH)
job_preferences -= j
all_quirks = SANITIZE_LIST(all_quirks)