Add null checks to client prefs checks

client.prefs. -> client?.prefs?.
This commit is contained in:
psq95
2023-05-13 23:53:47 +01:00
parent dfeb85bfa4
commit 5840c8ab99
93 changed files with 310 additions and 310 deletions
+2 -2
View File
@@ -37,8 +37,8 @@
postfix = "soon"
to_chat(src, "Please set up your character and select \"Ready\". The game will start [postfix].")
if(client.prefs.path) //Hyper edit: notify of a newer preference version
var/savefile/S = new /savefile(client.prefs.path)
if(client?.prefs?.path) //Hyper edit: notify of a newer preference version
var/savefile/S = new /savefile(client?.prefs?.path)
if(S)
S.cd = "/"
var/slot
+13 -13
View File
@@ -32,7 +32,7 @@
return
/mob/dead/new_player/proc/new_player_panel()
var/output = "<center><p>Welcome, <b>[client ? client.prefs.real_name : "Unknown User"]</b></p>"
var/output = "<center><p>Welcome, <b>[client ? client?.prefs?.real_name : "Unknown User"]</b></p>"
output += "<p><a href='byond://?src=[REF(src)];show_preferences=1'>Setup Character</a></p>"
if(SSticker.current_state <= GAME_STATE_PREGAME)
@@ -93,7 +93,7 @@
relevant_cap = max(hpc, epc)
if(href_list["show_preferences"])
client.prefs.ShowChoices(src)
client?.prefs?.ShowChoices(src)
return 1
if(href_list["ready"])
@@ -122,7 +122,7 @@
LateChoices()
return
// if(client.prefs.real_name in client.pastcharacters) //if character has been spawned before
// if(client?.prefs?.real_name in client.pastcharacters) //if character has been spawned before
// to_chat(usr, "<span class='notice'>You have played that character before this round, please select a new one!</span>")
// return
@@ -183,7 +183,7 @@
if(!ready && href_list["preference"])
if(client)
client.prefs.process_link(src, href_list)
client?.prefs?.process_link(src, href_list)
else if(!href_list["late_join"])
new_player_panel()
@@ -303,7 +303,7 @@
observer.client = client
observer.set_ghost_appearance()
if(observer.client && observer.client.prefs)
observer.real_name = observer.client.prefs.real_name
observer.real_name = observer.client?.prefs?.real_name
observer.name = observer.real_name
observer.client.init_verbs()
observer.update_icon()
@@ -346,11 +346,11 @@
if(jobban_isbanned(src,rank))
return JOB_UNAVAILABLE_BANNED
if(job.whitelist_type) //whitelisting
if(job.whitelist_type == "roleplay" && !client.prefs.roleplayroles)
if(job.whitelist_type == "roleplay" && !client?.prefs?.roleplayroles)
return JOB_UNAVAILABLE_WHITELIST
if(job.whitelist_type == "important" && !client.prefs.importantroles)
if(job.whitelist_type == "important" && !client?.prefs?.importantroles)
return JOB_UNAVAILABLE_WHITELIST
if(job.whitelist_type == "silly" && !client.prefs.sillyroles)
if(job.whitelist_type == "silly" && !client?.prefs?.sillyroles)
return JOB_UNAVAILABLE_WHITELIST
if(QDELETED(src))
return JOB_UNAVAILABLE_GENERIC
@@ -554,8 +554,8 @@
jobline += "<a class='[position_class]' style='display:block;width:170px' href='byond://?src=[REF(src)];SelectedJob=[job.title]'><font color='lime'><b>[job.title] ([job.current_positions])</b></font></a>"
else
jobline += "<a class='[position_class]' style='display:block;width:170px' href='byond://?src=[REF(src)];SelectedJob=[job.title]'>[job.title] ([job.current_positions])</a>"
if(client && client.prefs && client.prefs.alt_titles_preferences[job.title])
jobline += "<br><span style='color:#BBBBBB; font-style: italic;'>(as [client.prefs.alt_titles_preferences[job.title]])</span>"
if(client && client.prefs && client?.prefs?.alt_titles_preferences[job.title])
jobline += "<br><span style='color:#BBBBBB; font-style: italic;'>(as [client?.prefs?.alt_titles_preferences[job.title]])</span>"
dat += jobline
categorizedJobs[jobcat]["jobs"] -= job
@@ -588,9 +588,9 @@
if(QDELETED(src))
return
if(frn)
client.prefs.random_character()
client.prefs.real_name = client.prefs.pref_species.random_name(gender,1)
client.prefs.copy_to(H)
client?.prefs?.random_character()
client?.prefs?.real_name = client?.prefs?.pref_species.random_name(gender,1)
client?.prefs?.copy_to(H)
H.dna.update_dna_identity()
if(mind)
+5 -5
View File
@@ -3,16 +3,16 @@
if(!. || !client)
return FALSE
ghost_accs = client.prefs.ghost_accs
ghost_others = client.prefs.ghost_others
ghost_accs = client?.prefs?.ghost_accs
ghost_others = client?.prefs?.ghost_others
var/preferred_form = null
if(IsAdminGhost(src))
has_unlimited_silicon_privilege = 1
if(client.prefs.unlock_content)
preferred_form = client.prefs.ghost_form
ghost_orbit = client.prefs.ghost_orbit
if(client?.prefs?.unlock_content)
preferred_form = client?.prefs?.ghost_form
ghost_orbit = client?.prefs?.ghost_orbit
var/turf/T = get_turf(src)
if (isturf(T))
+24 -24
View File
@@ -175,8 +175,8 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
/mob/dead/observer/update_icon(new_form)
. = ..()
if(client) //We update our preferences in case they changed right before update_icon was called.
ghost_accs = client.prefs.ghost_accs
ghost_others = client.prefs.ghost_others
ghost_accs = client?.prefs?.ghost_accs
ghost_others = client?.prefs?.ghost_others
if(hair_overlay)
cut_overlay(hair_overlay)
@@ -268,9 +268,9 @@ Works together with spawning an observer, noted above.
var/mob/dead/observer/ghost = new(get_turf(src), src) // Transfer safety to observer spawning proc.
SStgui.on_transfer(src, ghost) // Transfer NanoUIs.
ghost.can_reenter_corpse = can_reenter_corpse
if (client && client.prefs && client.prefs.auto_ooc)
if (!(client.prefs.chat_toggles & CHAT_OOC))
client.prefs.chat_toggles ^= CHAT_OOC
if (client && client.prefs && client?.prefs?.auto_ooc)
if (!(client?.prefs?.chat_toggles & CHAT_OOC))
client?.prefs?.chat_toggles ^= CHAT_OOC
transfer_ckey(ghost, FALSE)
ghost.AddElement(/datum/element/ghost_role_eligibility,penalize) // technically already run earlier, but this adds the penalty
// needs to be done AFTER the ckey transfer, too
@@ -378,8 +378,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(source)
var/obj/screen/alert/A = throw_alert("[REF(source)]_notify_cloning", /obj/screen/alert/notify_cloning)
if(A)
if(client && client.prefs && client.prefs.UI_style)
A.icon = ui_style2icon(client.prefs.UI_style)
if(client && client.prefs && client?.prefs?.UI_style)
A.icon = ui_style2icon(client?.prefs?.UI_style)
A.desc = message
var/old_layer = source.layer
var/old_plane = source.plane
@@ -506,7 +506,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set name = "View Range"
set desc = "Change your view range."
var/max_view = client.prefs.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
var/max_view = client?.prefs?.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
if(client.view == CONFIG_GET(string/default_view))
var/list/views = list()
for(var/i in 7 to max_view)
@@ -520,7 +520,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/verb/add_view_range(input as num)
set name = "Add View Range"
set hidden = TRUE
var/max_view = client.prefs.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
var/max_view = client?.prefs?.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT
if(input)
client.rescale_view(input, 15, (max_view*2)+1)
@@ -573,7 +573,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/update_sight()
if(client)
ghost_others = client.prefs.ghost_others //A quick update just in case this setting was changed right before calling the proc
ghost_others = client?.prefs?.ghost_others //A quick update just in case this setting was changed right before calling the proc
if (!ghostvision)
see_invisible = SEE_INVISIBLE_LIVING
@@ -601,11 +601,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
client.images -= GLOB.ghost_images_default
if(GHOST_OTHERS_SIMPLE)
client.images -= GLOB.ghost_images_simple
lastsetting = client.prefs.ghost_others
lastsetting = client?.prefs?.ghost_others
if(!ghostvision)
return
if(client.prefs.ghost_others != GHOST_OTHERS_THEIR_SETTING)
switch(client.prefs.ghost_others)
if(client?.prefs?.ghost_others != GHOST_OTHERS_THEIR_SETTING)
switch(client?.prefs?.ghost_others)
if(GHOST_OTHERS_DEFAULT_SPRITE)
client.images |= (GLOB.ghost_images_default-ghostimage_default)
if(GHOST_OTHERS_SIMPLE)
@@ -741,23 +741,23 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set_ghost_appearance()
if(client && client.prefs)
deadchat_name = client.prefs.real_name
deadchat_name = client?.prefs?.real_name
/mob/dead/observer/proc/set_ghost_appearance()
if((!client) || (!client.prefs))
return
if(client.prefs.be_random_name)
client.prefs.real_name = random_unique_name(gender)
if(client.prefs.be_random_body)
client.prefs.random_character(gender)
if(client?.prefs?.be_random_name)
client?.prefs?.real_name = random_unique_name(gender)
if(client?.prefs?.be_random_body)
client?.prefs?.random_character(gender)
if(HAIR in client.prefs.pref_species.species_traits)
hair_style = client.prefs.hair_style
hair_color = brighten_color(client.prefs.hair_color)
if(FACEHAIR in client.prefs.pref_species.species_traits)
facial_hair_style = client.prefs.facial_hair_style
facial_hair_color = brighten_color(client.prefs.facial_hair_color)
if(HAIR in client?.prefs?.pref_species.species_traits)
hair_style = client?.prefs?.hair_style
hair_color = brighten_color(client?.prefs?.hair_color)
if(FACEHAIR in client?.prefs?.pref_species.species_traits)
facial_hair_style = client?.prefs?.facial_hair_style
facial_hair_color = brighten_color(client?.prefs?.facial_hair_color)
update_icon()
+1 -1
View File
@@ -34,7 +34,7 @@
to_follow = V.source
var/link = FOLLOW_LINK(src, to_follow)
// Create map text prior to modifying message for goonchat
if (client?.prefs.chat_on_map && (client.prefs.see_chat_non_mob || ismob(speaker)))
if (client?.prefs.chat_on_map && (client?.prefs?.see_chat_non_mob || ismob(speaker)))
create_chat_message(speaker, message_language, raw_message, spans, message_mode)
// Recompose the message, because it's scrambled by default
message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode, FALSE, source)