diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 18896c829a..db1bfcba46 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -1083,6 +1083,12 @@ namespace Content.Shared.CCVar public static readonly CVarDef ChatPunctuation = CVarDef.Create("ic.punctuation", false, CVar.SERVER); + /// + /// Enables automatically forcing IC name rules. Uppercases the first letter of the first and last words of the name + /// + public static readonly CVarDef ICNameCase = + CVarDef.Create("ic.name_case", true, CVar.SERVER | CVar.REPLICATED); + /* * Salvage */ diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index 97b8369ee5..da69dfe749 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Globalization; using System.Text.RegularExpressions; using Content.Shared.CCVar; using Content.Shared.CharacterAppearance; @@ -328,11 +329,20 @@ namespace Content.Shared.Preferences name = name.Trim(); - if (IoCManager.Resolve().GetCVar(CCVars.RestrictedNames)) + var configManager = IoCManager.Resolve(); + if (configManager.GetCVar(CCVars.RestrictedNames)) { name = Regex.Replace(name, @"[^A-Z,a-z,0-9, -]", string.Empty); } + if (configManager.GetCVar(CCVars.ICNameCase)) + { + // This regex replaces the first character of the first and last words of the name with their uppercase version + name = Regex.Replace(name, + @"^(?\w)|\b(?\w)(?=\w*$)", + m => m.Groups["word"].Value.ToUpper()); + } + if (string.IsNullOrEmpty(name)) { name = Sex.GetName(Species);