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)
@@ -313,7 +313,7 @@ GLOBAL_LIST_EMPTY(roundstart_races)
C.canbearoused = FALSE
else
if(C.client)
C.canbearoused = C.client.prefs.arousable
C.canbearoused = C.client?.prefs?.arousable
if(ishuman(C))
var/mob/living/carbon/human/H = C
if(NOGENITALS in H.dna.species.species_traits)
@@ -21,7 +21,7 @@
if(ishuman(C))
var/mob/living/carbon/human/H = C
if(!H.dna.features["moth_wings"])
H.dna.features["moth_wings"] = "[(H.client && H.client.prefs && LAZYLEN(H.client.prefs.features) && H.client.prefs.features["moth_wings"]) ? H.client.prefs.features["moth_wings"] : "Plain"]"
H.dna.features["moth_wings"] = "[(H.client && H.client.prefs && LAZYLEN(H.client?.prefs?.features) && H.client?.prefs?.features["moth_wings"]) ? H.client?.prefs?.features["moth_wings"] : "Plain"]"
handle_mutant_bodyparts(H)
/datum/species/moth/random_name(gender,unique,lastname)
@@ -25,7 +25,7 @@
log_whisper("[src.name]/[src.key] : [message]")
if (src.client)
if (src.client.prefs.muted & MUTE_IC)
if (src.client?.prefs?.muted & MUTE_IC)
to_chat(src, "<span class='danger'>You cannot whisper (muted).</span>")
return
@@ -54,7 +54,7 @@
var/list/listening_dead = list()
for(var/mob/M in GLOB.player_list)
if(M.stat == DEAD && M.client && ((M.client.prefs.chat_toggles & CHAT_GHOSTWHISPER) || (get_dist(M, src) <= 7)))
if(M.stat == DEAD && M.client && ((M.client?.prefs?.chat_toggles & CHAT_GHOSTWHISPER) || (get_dist(M, src) <= 7)))
listening_dead |= M
var/list/listening = get_hearers_in_view(1, src)
+1 -1
View File
@@ -410,7 +410,7 @@
return FALSE
else if(QDELETED(user))
return FALSE
else if(user.client && user.client.prefs.muted & MUTE_IC)
else if(user.client && user.client?.prefs?.muted & MUTE_IC)
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)
+1 -1
View File
@@ -1105,7 +1105,7 @@
if(client)
client.move_delay = world.time + movement_delay()
lying_prev = lying
if(canmove && !intentionalresting && iscarbon(src) && client && client.prefs && client.prefs.autostand)//CIT CHANGE - adds autostanding as a preference
if(canmove && !intentionalresting && iscarbon(src) && client && client.prefs && client?.prefs?.autostand)//CIT CHANGE - adds autostanding as a preference
addtimer(CALLBACK(src, .proc/resist_a_rest, TRUE), 0) //CIT CHANGE - ditto
return canmove
+5 -5
View File
@@ -249,7 +249,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
deaf_message = "<span class='notice'>You can't hear yourself!</span>"
deaf_type = 2 // Since you should be able to hear yourself without looking
// Create map text prior to modifying message for goonchat
if (client?.prefs.chat_on_map && stat != UNCONSCIOUS && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear())
if (client?.prefs.chat_on_map && stat != UNCONSCIOUS && (client?.prefs?.see_chat_non_mob || ismob(speaker)) && can_hear())
create_chat_message(speaker, message_language, raw_message, spans, message_mode)
if (client?.prefs.radiosounds && stat != UNCONSCIOUS && can_hear() && radio_freq)
playsound_local(src,'sound/voice/radio.ogg', 30, 0)
@@ -281,9 +281,9 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
if(!M.client || !client) //client is so that ghosts don't have to listen to mice
continue
if(get_dist(M, source) > 7 || M.z != z) //they're out of range of normal hearing
if(eavesdropping_modes[message_mode] && !(M.client.prefs.chat_toggles & CHAT_GHOSTWHISPER)) //they're whispering and we have hearing whispers at any range off
if(eavesdropping_modes[message_mode] && !(M.client?.prefs?.chat_toggles & CHAT_GHOSTWHISPER)) //they're whispering and we have hearing whispers at any range off
continue
if(!(M.client.prefs.chat_toggles & CHAT_GHOSTEARS)) //they're talking normally and we have hearing at any range off
if(!(M.client?.prefs?.chat_toggles & CHAT_GHOSTEARS)) //they're talking normally and we have hearing at any range off
continue
listening |= M
the_dead[M] = TRUE
@@ -306,7 +306,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
//speech bubble
var/list/speech_bubble_recipients = list()
for(var/mob/M in listening)
if(M.client && !M.client.prefs.chat_on_map)
if(M.client && !M.client?.prefs?.chat_on_map)
speech_bubble_recipients.Add(M.client)
var/image/I = image('icons/mob/talk.dmi', src, "[bubble_type][say_test(message)]", FLY_LAYER)
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
@@ -321,7 +321,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
/mob/living/proc/can_speak_basic(message, ignore_spam = FALSE) //Check BEFORE handling of xeno and ling channels
if(client)
if(client.prefs.muted & MUTE_IC)
if(client?.prefs?.muted & MUTE_IC)
to_chat(src, "<span class='danger'>You cannot speak in IC (muted).</span>")
return 0
if(!ignore_spam && client.handle_spam_prevention(message,MUTE_IC))
+1 -1
View File
@@ -830,7 +830,7 @@
jobpart = "Unknown"
var/rendered = "<i><span class='game say'>[start]<span class='name'>[hrefpart][namepart] ([jobpart])</a> </span><span class='message'>[treated_message]</span></span></i>"
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)
show_message(rendered, MSG_AUDIBLE)
+1 -1
View File
@@ -151,7 +151,7 @@
if(!only_listener)
// Play voice for all mobs in the z level
for(var/mob/M in GLOB.player_list)
if(M.client && M.can_hear() && (M.client.prefs.toggles & SOUND_ANNOUNCEMENTS))
if(M.client && M.can_hear() && (M.client?.prefs?.toggles & SOUND_ANNOUNCEMENTS))
var/turf/T = get_turf(M)
if(T.z == z_level)
SEND_SOUND(M, voice)
+1 -1
View File
@@ -13,7 +13,7 @@
create_mob_hud()
if(hud_used)
hud_used.show_hud(hud_used.hud_version)
hud_used.update_ui_style(ui_style2icon(client.prefs.UI_style))
hud_used.update_ui_style(ui_style2icon(client?.prefs?.UI_style))
next_move = 1
+5 -5
View File
@@ -488,11 +488,11 @@ mob/visible_message(message, self_message, blind_message, vision_distance = DEFA
if(!ckey)
return
SEND_SIGNAL(new_mob, COMSIG_MOB_PRE_PLAYER_CHANGE, new_mob, src)
if (client && client.prefs && client.prefs.auto_ooc)
if (client.prefs.chat_toggles & CHAT_OOC && isliving(new_mob))
client.prefs.chat_toggles ^= CHAT_OOC
if (!(client.prefs.chat_toggles & CHAT_OOC) && isdead(new_mob))
client.prefs.chat_toggles ^= CHAT_OOC
if (client && client.prefs && client?.prefs?.auto_ooc)
if (client?.prefs?.chat_toggles & CHAT_OOC && isliving(new_mob))
client?.prefs?.chat_toggles ^= CHAT_OOC
if (!(client?.prefs?.chat_toggles & CHAT_OOC) && isdead(new_mob))
client?.prefs?.chat_toggles ^= CHAT_OOC
new_mob.ckey = ckey
new_mob.client?.init_verbs()
if(send_signal)
+2 -2
View File
@@ -401,8 +401,8 @@ It's fairly easy to fix if dealing with single letters but not so much with comp
if(source)
var/obj/screen/alert/notify_action/A = O.throw_alert("[REF(source)]_notify_action", /obj/screen/alert/notify_action)
if(A)
if(O.client.prefs && O.client.prefs.UI_style)
A.icon = ui_style2icon(O.client.prefs.UI_style)
if(O.client.prefs && O.client?.prefs?.UI_style)
A.icon = ui_style2icon(O.client?.prefs?.UI_style)
A.desc = message
A.action = action
A.target = source
+1 -1
View File
@@ -90,7 +90,7 @@
if (src.client)
if(src.client.prefs.muted & MUTE_DEADCHAT)
if(src.client?.prefs?.muted & MUTE_DEADCHAT)
to_chat(src, "<span class='danger'>You cannot talk in deadchat (muted).</span>")
return
+3 -3
View File
@@ -36,7 +36,7 @@ proc/get_top_level_mob(var/mob/S)
if(jobban_isbanned(user, "emote"))
to_chat(user, "You cannot send subtle emotes (banned).")
return FALSE
else if(user.client && user.client.prefs.muted & MUTE_IC)
else if(user.client && user.client?.prefs?.muted & MUTE_IC)
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)
@@ -69,7 +69,7 @@ proc/get_top_level_mob(var/mob/S)
if(!M.client || isnewplayer(M))
continue
var/T = get_turf(src)
if(M.stat == DEAD && M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTSIGHT) && !(M in viewers(T, null)))
if(M.stat == DEAD && M.client && (M.client?.prefs?.chat_toggles & CHAT_GHOSTSIGHT) && !(M in viewers(T, null)))
M.show_message(message)
if(emote_type == EMOTE_AUDIBLE)
@@ -100,7 +100,7 @@ proc/get_top_level_mob(var/mob/S)
if(jobban_isbanned(user, "emote"))
to_chat(user, "You cannot send subtle emotes (banned).")
return FALSE
else if(user.client && user.client.prefs.muted & MUTE_IC)
else if(user.client && user.client?.prefs?.muted & MUTE_IC)
to_chat(user, "You cannot send IC messages (muted).")
return FALSE
else if(!params)