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
@@ -1,6 +1,6 @@
/datum/controller/subsystem/ticker/proc/generate_crew_objectives()
for(var/datum/mind/crewMind in SSticker.minds)
if(prob(5) && !issilicon(crewMind.current) && !jobban_isbanned(crewMind, "Syndicate") && GLOB.miscreants_allowed && ROLE_MISCREANT in crewMind.current.client.prefs.be_special)
if(prob(5) && !issilicon(crewMind.current) && !jobban_isbanned(crewMind, "Syndicate") && GLOB.miscreants_allowed && ROLE_MISCREANT in crewMind.current.client?.prefs?.be_special)
generate_miscreant_objectives(crewMind)
else
if(CONFIG_GET(flag/allow_crew_objectives))
@@ -7,7 +7,7 @@
return
if(!crewMind.assigned_role)
return
if(!(ROLE_MISCREANT in crewMind.current.client.prefs.be_special))
if(!(ROLE_MISCREANT in crewMind.current.client?.prefs?.be_special))
return
if(jobban_isbanned(crewMind, "Syndicate"))
return
@@ -2,10 +2,10 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggleeatingnoise)()
set name = "Toggle Eating Noises"
set category = "Preferences"
set desc = "Hear Eating noises"
usr.client.prefs.cit_toggles ^= EATING_NOISES
usr.client.prefs.save_preferences()
usr.client?.prefs?.cit_toggles ^= EATING_NOISES
usr.client?.prefs?.save_preferences()
usr.stop_sound_channel(CHANNEL_PRED)
to_chat(usr, "You will [(usr.client.prefs.cit_toggles & EATING_NOISES) ? "now" : "no longer"] hear eating noises.")
to_chat(usr, "You will [(usr.client?.prefs?.cit_toggles & EATING_NOISES) ? "now" : "no longer"] hear eating noises.")
/datum/verbs/menu/Settings/Sound/toggleeatingnoise/Get_checked(client/C)
return C.prefs.cit_toggles & EATING_NOISES
@@ -13,10 +13,10 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggledigestionnoise)()
set name = "Toggle Digestion Noises"
set category = "Preferences"
set desc = "Hear digestive noises"
usr.client.prefs.cit_toggles ^= DIGESTION_NOISES
usr.client.prefs.save_preferences()
usr.client?.prefs?.cit_toggles ^= DIGESTION_NOISES
usr.client?.prefs?.save_preferences()
usr.stop_sound_channel(CHANNEL_DIGEST)
to_chat(usr, "You will [(usr.client.prefs.cit_toggles & DIGESTION_NOISES) ? "now" : "no longer"] hear digestion noises.")
to_chat(usr, "You will [(usr.client?.prefs?.cit_toggles & DIGESTION_NOISES) ? "now" : "no longer"] hear digestion noises.")
/datum/verbs/menu/Settings/Sound/toggledigestionnoise/Get_checked(client/C)
return C.prefs.cit_toggles & DIGESTION_NOISES
@@ -24,10 +24,10 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggleburpingnoise)()
set name = "Toggle Burping Noises"
set category = "Preferences"
set desc = "Hear Burping noises"
usr.client.prefs.cit_toggles ^= BURPING_NOISES
usr.client.prefs.save_preferences()
usr.client?.prefs?.cit_toggles ^= BURPING_NOISES
usr.client?.prefs?.save_preferences()
usr.stop_sound_channel(CHANNEL_BURP)
to_chat(usr, "You will [(usr.client.prefs.cit_toggles & BURPING_NOISES) ? "now" : "no longer"] hear burping noises.")
to_chat(usr, "You will [(usr.client?.prefs?.cit_toggles & BURPING_NOISES) ? "now" : "no longer"] hear burping noises.")
/datum/verbs/menu/Settings/Sound/toggleburpingnoise/Get_checked(client/C)
return C.prefs.cit_toggles & BURPING_NOISES
@@ -35,10 +35,10 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, togglefartingnoise)()
set name = "Toggle Farting Noises"
set category = "Preferences"
set desc = "Hear Farting noises"
usr.client.prefs.cit_toggles ^= FARTING_NOISES
usr.client.prefs.save_preferences()
usr.client?.prefs?.cit_toggles ^= FARTING_NOISES
usr.client?.prefs?.save_preferences()
usr.stop_sound_channel(CHANNEL_FART)
to_chat(usr, "You will [(usr.client.prefs.cit_toggles & FARTING_NOISES) ? "now" : "no longer"] hear farting noises.")
to_chat(usr, "You will [(usr.client?.prefs?.cit_toggles & FARTING_NOISES) ? "now" : "no longer"] hear farting noises.")
/datum/verbs/menu/Settings/Sound/togglefartingnoise/Get_checked(client/C)
return C.prefs.cit_toggles & FARTING_NOISES
@@ -46,12 +46,12 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, togglehoundsleeper)()
set name = "Toggle Voracious Hound Sleepers"
set category = "Preferences"
set desc = "Toggles Voracious MediHound Sleepers"
usr.client.prefs.cit_toggles ^= MEDIHOUND_SLEEPER
usr.client.prefs.save_preferences()
if(usr.client.prefs.cit_toggles & MEDIHOUND_SLEEPER)
usr.client?.prefs?.cit_toggles ^= MEDIHOUND_SLEEPER
usr.client?.prefs?.save_preferences()
if(usr.client?.prefs?.cit_toggles & MEDIHOUND_SLEEPER)
to_chat(usr, "You have opted in for voracious medihound sleepers.")
else
to_chat(usr, "Medihound sleepers will no longer be voracious when you're involved.")
SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Toggle MediHound Sleeper", "[usr.client.prefs.cit_toggles & MEDIHOUND_SLEEPER ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Toggle MediHound Sleeper", "[usr.client?.prefs?.cit_toggles & MEDIHOUND_SLEEPER ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/datum/verbs/menu/Settings/Sound/togglehoundsleeper/Get_checked(client/C)
return C.prefs.cit_toggles & MEDIHOUND_SLEEPER
@@ -51,7 +51,7 @@
set name = "Rest"
set category = "IC"
if(client && client.prefs && client.prefs.autostand)
if(client && client.prefs && client?.prefs?.autostand)
intentionalresting = !intentionalresting
to_chat(src, "<span class='notice'>You are now attempting to [intentionalresting ? "[!resting ? "lay down and ": ""]stay down" : "[resting ? "get up and ": ""]stay up"].</span>")
if(intentionalresting && !resting)
@@ -132,4 +132,4 @@
/mob/living/proc/update_hud_sprint_bar()
if(hud_used && hud_used.sprint_buffer)
hud_used.sprint_buffer.update_to_mob(src)
*/
*/
@@ -174,7 +174,7 @@
var/turf/source = get_turf(owner)
var/sound/eating = sound(GLOB.vore_sounds[vore_sound])
for(var/mob/living/M in get_hearers_in_view(3, source))
if(M.client && M.client.prefs.cit_toggles & EATING_NOISES)
if(M.client && M.client?.prefs?.cit_toggles & EATING_NOISES)
M.playsound_local(source, vore_sound, 50, 1, S = eating)
recent_sound = (world.time + 20 SECONDS)
@@ -214,7 +214,7 @@
var/turf/source = get_turf(owner)
var/sound/releasement = sound(GLOB.release_sounds[release_sound])
for(var/mob/living/M in get_hearers_in_view(2, source))
if(M.client && (M.client.prefs.cit_toggles & EATING_NOISES))
if(M.client && (M.client?.prefs?.cit_toggles & EATING_NOISES))
M.playsound_local(source, release_sound, 50, 1, S = releasement)
//Clean up our own business
@@ -242,7 +242,7 @@
var/turf/source = get_turf(owner)
var/sound/releasement = sound(GLOB.release_sounds[release_sound])
for(var/mob/living/H in get_hearers_in_view(2, source))
if(H.client && (H.client.prefs.cit_toggles & EATING_NOISES))
if(H.client && (H.client?.prefs?.cit_toggles & EATING_NOISES))
H.playsound_local(source, release_sound, 50, 1, S = releasement)
if(istype(M,/mob/living))
@@ -323,7 +323,7 @@
var/turf/source = get_turf(owner)
var/sound/eating = sound(GLOB.vore_sounds[vore_sound])
for(var/mob/living/M in get_hearers_in_view(3, source))
if(M.client && M.client.prefs.cit_toggles & EATING_NOISES)
if(M.client && M.client?.prefs?.cit_toggles & EATING_NOISES)
M.playsound_local(source, vore_sound, 50, 1, S = eating)
owner.updateVRPanel()
@@ -535,17 +535,17 @@
if(is_wet)
for(var/mob/living/M in get_hearers_in_view(3, source))
if(M.client && M.client.prefs.cit_toggles & EATING_NOISES)
if(M.client && M.client?.prefs?.cit_toggles & EATING_NOISES)
M.playsound_local(source, "struggle_sound", 50, 1, S = struggle_snuggle)
else
for(var/mob/living/M in get_hearers_in_view(3, source))
if(M.client && M.client.prefs.cit_toggles & EATING_NOISES)
if(M.client && M.client?.prefs?.cit_toggles & EATING_NOISES)
M.playsound_local(source, "rustle", 50, 1, S = struggle_rustle)
var/list/watching = hearers(3, owner)
for(var/mob/living/M in watching)
if(M.client && (M.client.prefs.cit_toggles & EATING_NOISES)) //Might as well censor the normies here too.
if(M.client && (M.client?.prefs?.cit_toggles & EATING_NOISES)) //Might as well censor the normies here too.
M.show_message(struggle_outer_message, MSG_VISUAL) // visible
to_chat(R,struggle_user_message)
@@ -35,7 +35,7 @@
if(!M.client)
continue
M.stop_sound_channel(CHANNEL_PREYLOOP) // sanity just in case
if(M.client.prefs.cit_toggles & DIGESTION_NOISES)
if(M.client?.prefs?.cit_toggles & DIGESTION_NOISES)
var/sound/preyloop = sound('sound/vore/prey/loop.ogg', repeat = TRUE)
M.playsound_local(get_turf(src),preyloop, 80,0, channel = CHANNEL_PREYLOOP)
M.next_preyloop = (world.time + 52 SECONDS)
@@ -73,7 +73,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -121,7 +121,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -156,7 +156,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -180,7 +180,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -200,7 +200,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -242,7 +242,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -275,7 +275,7 @@
if((world.time - NORMIE_HEARCHECK) > last_hearcheck)
LAZYCLEARLIST(hearing_mobs)
for(var/mob/living/H in get_hearers_in_view(3, source))
if(!H.client || !(H.client.prefs.cit_toggles & DIGESTION_NOISES))
if(!H.client || !(H.client?.prefs?.cit_toggles & DIGESTION_NOISES))
continue
LAZYADD(hearing_mobs, H)
last_hearcheck = world.time
@@ -85,10 +85,10 @@ GLOBAL_LIST_EMPTY(vore_preferences_datums)
/datum/vore_preferences/proc/load_vore()
if(!client || !client_ckey)
return 0 //No client, how can we save?
if(!client.prefs || !client.prefs.default_slot)
if(!client.prefs || !client?.prefs?.default_slot)
return 0 //Need to know what character to load!
slot = client.prefs.default_slot
slot = client?.prefs?.default_slot
load_path(client_ckey,slot)