From d2e43812453e534b800bc044e15e086173b9cd27 Mon Sep 17 00:00:00 2001 From: fira Date: Sat, 14 Oct 2023 18:45:24 +0100 Subject: [PATCH] Fixes Xeno Name preference requring a reconnect to apply (#4660) # About the pull request See #4436 for an indepth description of the issue - basically Xeno name is cached on client and updating preferences won't update it without a reconnect (and the lobby screen even baits you thinking it does by displaying pref not client's) # Explain why it's good for the game Less confusion Fixes #4436 # Testing Photographs and Procedure Basic testing performed in the form of: Changing Xeno Name Launching game, observing Spawning a Xeno and possessing it And observing which xeno name is present. # Changelog :cl: fix: Xeno Name preference does not require a reconnection to apply anymore. It still won't change your current Xenomorph's name however. /:cl: --- code/modules/client/client_procs.dm | 18 +++++++++++------- code/modules/client/preferences.dm | 4 ++++ code/modules/mob/new_player/new_player.dm | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 3cfb08b8dac0..82540d6cbf5e 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -330,13 +330,8 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( prefs.last_ip = address //these are gonna be used for banning prefs.last_id = computer_id //these are gonna be used for banning fps = prefs.fps - xeno_prefix = prefs.xeno_prefix - xeno_postfix = prefs.xeno_postfix - xeno_name_ban = prefs.xeno_name_ban - if(!xeno_prefix || xeno_name_ban) - xeno_prefix = "XX" - if(!xeno_postfix || xeno_name_ban) - xeno_postfix = "" + + load_xeno_name() human_name_ban = prefs.human_name_ban @@ -790,3 +785,12 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( if(admin_holder) admin_holder.particle_test = new /datum/particle_editor(in_atom) admin_holder.particle_test.tgui_interact(mob) + +/client/proc/load_xeno_name() + xeno_prefix = prefs.xeno_prefix + xeno_postfix = prefs.xeno_postfix + xeno_name_ban = prefs.xeno_name_ban + if(!xeno_prefix || xeno_name_ban) + xeno_prefix = "XX" + if(!xeno_postfix || xeno_name_ban) + xeno_postfix = "" diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 554ba28e417f..8ca177ddf66c 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1409,6 +1409,7 @@ var/const/MAX_SAVE_SLOTS = 10 if(length(new_xeno_prefix)==0) xeno_prefix = "XX" + owner.load_xeno_name() else var/all_ok = TRUE for(var/i=1, i<=length(new_xeno_prefix), i++) @@ -1420,6 +1421,7 @@ var/const/MAX_SAVE_SLOTS = 10 all_ok = FALSE //everything else - won't if(all_ok) xeno_prefix = new_xeno_prefix + owner.load_xeno_name() else to_chat(user, "Invalid Xeno Prefix. Your Prefix can contain either single letter or two letters.") @@ -1444,6 +1446,7 @@ var/const/MAX_SAVE_SLOTS = 10 return else if(length(new_xeno_postfix)==0) xeno_postfix = "" + owner.load_xeno_name() else var/all_ok = TRUE var/first_char = TRUE @@ -1469,6 +1472,7 @@ var/const/MAX_SAVE_SLOTS = 10 first_char = FALSE if(all_ok) xeno_postfix = new_xeno_postfix + owner.load_xeno_name() else to_chat(user, "Invalid Xeno Postfix. Your Postfix can contain single letter and an optional digit after it.") diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 5da499dabc52..dda2487c24d9 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -34,8 +34,8 @@ return var/tempnumber = rand(1, 999) - var/postfix_text = (client.prefs && client.prefs.xeno_postfix) ? ("-"+client.prefs.xeno_postfix) : "" - var/prefix_text = (client.prefs && client.prefs.xeno_prefix) ? client.prefs.xeno_prefix : "XX" + var/postfix_text = (client.xeno_postfix) ? ("-"+client.xeno_postfix) : "" + var/prefix_text = (client.xeno_prefix) ? client.xeno_prefix : "XX" var/xeno_text = "[prefix_text]-[tempnumber][postfix_text]" var/round_start = !SSticker || !SSticker.mode || SSticker.current_state <= GAME_STATE_PREGAME