From 6fe6342952f52c5194d1b74e73bd18e05cd71c8f Mon Sep 17 00:00:00 2001 From: meem <75212565+meemofcourse@users.noreply.github.com> Date: Tue, 7 Nov 2023 00:15:49 -0300 Subject: [PATCH] You can no longer respawn as a character with a name that matches an already existing character (#2451) ## About The Pull Request title. code stolen from https://github.com/tgstation/TerraGov-Marine-Corps/pull/3243 ## Why It's Good For The Game It gets very tiring to moderate new players doing same character respawn. if it's ever needed, admins can just rename a player ## Changelog :cl: add: You can no longer late-join as a character with a repeated name /:cl: --- code/_globalvars/lists/mobs.dm | 2 ++ code/modules/mob/dead/new_player/new_player.dm | 8 ++++++++ code/modules/mob/mob.dm | 16 ++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/code/_globalvars/lists/mobs.dm b/code/_globalvars/lists/mobs.dm index 0c28353395d44..fb00d8bdf283a 100644 --- a/code/_globalvars/lists/mobs.dm +++ b/code/_globalvars/lists/mobs.dm @@ -35,6 +35,8 @@ GLOBAL_LIST_EMPTY(aiEyes) ///underages who have been reported to security for trying to buy things they shouldn't, so they can't spam GLOBAL_LIST_EMPTY(narcd_underages) +GLOBAL_LIST_EMPTY(real_names_joined) + GLOBAL_LIST_EMPTY(language_datum_instances) GLOBAL_LIST_EMPTY(all_languages) diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index 6f37de4c4c77f..d7865c9d22766 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -291,6 +291,12 @@ if(auth_check) return + if(!client.prefs.randomise[RANDOM_NAME]) // do they have random names enabled + var/name = client.prefs.real_name + if(GLOB.real_names_joined.Find(name)) // is there someone who spawned with the same name + to_chat(usr, "Someone has spawned with this name already.") + return FALSE + var/error = IsJobUnavailable(job, ship, check_playtime) if(error != JOB_AVAILABLE) alert(src, get_job_unavailable_error_message(error, job)) @@ -398,6 +404,7 @@ close_spawn_windows() var/mob/living/carbon/human/H = new(loc) + GLOB.joined_player_list += ckey var/frn = CONFIG_GET(flag/force_random_names) var/admin_anon_names = SSticker.anonymousnames @@ -418,6 +425,7 @@ is_antag = TRUE client.prefs.copy_to(H, antagonist = is_antag) + update_names_joined_list(H.real_name) H.dna.update_dna_identity() if(mind) if(transfer_after) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 44aa701a466d2..6e60af7ed244a 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1095,6 +1095,14 @@ return LAZYLEN(match_list) return FALSE +/mob/proc/update_joined_player_list(newname, oldname) + if(newname == oldname) + return + if(oldname) + GLOB.joined_player_list -= oldname + if(newname) + GLOB.joined_player_list[newname] = TRUE + /** * Fully update the name of a mob @@ -1110,6 +1118,9 @@ log_played_names(ckey,newname) + if(GLOB.joined_player_list[oldname]) + update_joined_player_list(newname, oldname) + real_name = newname name = newname if(mind) @@ -1195,6 +1206,11 @@ if(client.mouse_override_icon) client.mouse_pointer_icon = client.mouse_override_icon +/mob/proc/update_names_joined_list(new_name, old_name) + if(old_name) + GLOB.real_names_joined -= old_name + if(new_name) + GLOB.real_names_joined[new_name] = TRUE ///This mob is abile to read books /mob/proc/is_literate()