Skip to content

Commit

Permalink
[MIRROR] Admin Forced Mob Rename and Preference Update (#2099)
Browse files Browse the repository at this point in the history
* Admin Forced Mob Rename and Preference Update (#82715)

* Admin Forced Mob Rename and Preference Update

---------

Co-authored-by: Zephyr <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Apr 20, 2024
1 parent d61b324 commit 7f8b2c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@

// /mob/living
#define VV_HK_GIVE_SPEECH_IMPEDIMENT "impede_speech"
#define VV_HK_ADMIN_RENAME "admin_rename"
#define VV_HK_ADD_MOOD "addmood"
#define VV_HK_REMOVE_MOOD "removemood"
#define VV_HK_GIVE_HALLUCINATION "give_hallucination"
Expand Down
24 changes: 24 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
VV_DROPDOWN_OPTION(VV_HK_GIVE_HALLUCINATION, "Give Hallucination")
VV_DROPDOWN_OPTION(VV_HK_GIVE_DELUSION_HALLUCINATION, "Give Delusion Hallucination")
VV_DROPDOWN_OPTION(VV_HK_GIVE_GUARDIAN_SPIRIT, "Give Guardian Spirit")
VV_DROPDOWN_OPTION(VV_HK_ADMIN_RENAME, "Force Change Name")

/mob/living/vv_do_topic(list/href_list)
. = ..()
Expand Down Expand Up @@ -2046,6 +2047,29 @@ GLOBAL_LIST_EMPTY(fire_appearances)
return
admin_give_guardian(usr)

if(href_list[VV_HK_ADMIN_RENAME])
if(!check_rights(R_ADMIN))
return

var/old_name = real_name
var/new_name = sanitize_name(tgui_input_text(usr, "Enter the new name.", "Admin Rename", real_name))
if(!new_name || new_name == real_name)
return

fully_replace_character_name(real_name, new_name)
var/replace_preferences = !isnull(client) && (tgui_alert(usr, "Would you like to update the client's preference with the new name?", "Pref Overwrite", list("Yes", "No")) == "Yes")
if(replace_preferences)
client.prefs.write_preference(GLOB.preference_entries[/datum/preference/name/real_name], new_name)

log_admin("forced rename", list(
"admin" = key_name(usr),
"player" = key_name(src),
"old_name" = old_name,
"new_name" = new_name,
"updated_prefs" = replace_preferences,
))
message_admins("[key_name_admin(usr)] has forcibly changed the real name of [key_name(src)] from '[old_name]' to '[real_name]'[(replace_preferences ? " and their preferences" : "")]")

/mob/living/proc/move_to_error_room()
var/obj/effect/landmark/error/error_landmark = locate(/obj/effect/landmark/error) in GLOB.landmarks_list
if(error_landmark)
Expand Down

0 comments on commit 7f8b2c8

Please sign in to comment.