Skip to content

Commit

Permalink
You can no longer respawn as a character with a name that matches an …
Browse files Browse the repository at this point in the history
…already existing character (#2451)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

title. code stolen from
tgstation/TerraGov-Marine-Corps#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:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
meemofcourse authored Nov 7, 2023
1 parent c8bcaa3 commit 6fe6342
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions code/modules/mob/dead/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<span class='warning'>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))
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6fe6342

Please sign in to comment.