mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 20:15:47 +01:00
[MIRROR] Adds sanity checking to prefs checks, fixing a bug that can cause emotes to stop displaying intermittently [MDB IGNORE] (#23081)
* Adds sanity checking to prefs checks, fixing a bug that can cause emotes to stop displaying intermittently * Update vox_procs.dm --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
@@ -1069,7 +1069,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
void.UpdateGreed(actualview[1],actualview[2])
|
||||
|
||||
/client/proc/AnnouncePR(announcement)
|
||||
if(prefs && prefs.chat_toggles & CHAT_PULLR)
|
||||
if(get_chat_toggles(src) & CHAT_PULLR)
|
||||
to_chat(src, announcement)
|
||||
|
||||
///Redirect proc that makes it easier to call the unlock achievement proc. Achievement type is the typepath to the award, user is the mob getting the award, and value is an optional variable used for leaderboard value increments
|
||||
|
||||
@@ -539,6 +539,49 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
if(GetQuirkBalance() < 0)
|
||||
all_quirks = list()
|
||||
|
||||
/**
|
||||
* Safely read a given preference datum from a given client.
|
||||
*
|
||||
* Reads the given preference datum from the given client, and guards against null client and null prefs.
|
||||
* The client object is fickle and can go null at times, so use this instead of read_preference() if you
|
||||
* want to ensure no runtimes.
|
||||
*
|
||||
* returns client.prefs.read_preference(prefs_to_read) or FALSE if something went wrong.
|
||||
*
|
||||
* Arguments:
|
||||
* * client/prefs_holder - the client to read the pref from
|
||||
* * datum/preference/pref_to_read - the type of preference datum to read.
|
||||
*/
|
||||
/proc/safe_read_pref(client/prefs_holder, datum/preference/pref_to_read)
|
||||
if(!prefs_holder)
|
||||
return FALSE
|
||||
if(prefs_holder && !prefs_holder?.prefs)
|
||||
stack_trace("[prefs_holder?.mob] ([prefs_holder?.ckey]) had null prefs, which shouldn't be possible!")
|
||||
return FALSE
|
||||
|
||||
return prefs_holder?.prefs.read_preference(pref_to_read)
|
||||
|
||||
/**
|
||||
* Get the given client's chat toggle prefs.
|
||||
*
|
||||
* Getter function for prefs.chat_toggles which guards against null client and null prefs.
|
||||
* The client object is fickle and can go null at times, so use this instead of directly accessing the var
|
||||
* if you want to ensure no runtimes.
|
||||
*
|
||||
* returns client.prefs.chat_toggles or FALSE if something went wrong.
|
||||
*
|
||||
* Arguments:
|
||||
* * client/prefs_holder - the client to get the chat_toggles pref from.
|
||||
*/
|
||||
/proc/get_chat_toggles(client/prefs_holder)
|
||||
if(!prefs_holder)
|
||||
return FALSE
|
||||
if(prefs_holder && !prefs_holder?.prefs)
|
||||
stack_trace("[prefs_holder?.mob] ([prefs_holder?.ckey]) had null prefs, which shouldn't be possible!")
|
||||
return FALSE
|
||||
|
||||
return prefs_holder?.prefs.chat_toggles
|
||||
|
||||
/// Sanitizes the preferences, applies the randomization prefs, and then applies the preference to the human mob.
|
||||
/datum/preferences/proc/safe_transfer_prefs_to(mob/living/carbon/human/character, icon_updates = TRUE, is_antag = FALSE)
|
||||
apply_character_randomization_prefs(is_antag)
|
||||
|
||||
@@ -68,7 +68,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
|
||||
message_admins("[key_name_admin(src)] has attempted to advertise in OOC: [msg]")
|
||||
return
|
||||
|
||||
if(!(prefs.chat_toggles & CHAT_OOC))
|
||||
if(!(get_chat_toggles(src) & CHAT_OOC))
|
||||
to_chat(src, span_danger("You have OOC muted."))
|
||||
return
|
||||
|
||||
@@ -90,7 +90,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
|
||||
for(var/client/receiver as anything in GLOB.clients)
|
||||
if(!receiver.prefs) // Client being created or deleted. Despite all, this can be null.
|
||||
continue
|
||||
if(!(receiver.prefs.chat_toggles & CHAT_OOC))
|
||||
if(!(get_chat_toggles(receiver) & CHAT_OOC))
|
||||
continue
|
||||
if(holder?.fakekey in receiver.prefs.ignoring)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user