diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index d823376b2b..716f16c3dd 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -29,9 +29,6 @@ namespace Content.Server.Access.Systems private void OnMapInit(EntityUid uid, IdCardComponent id, MapInitEvent args) { - // On one hand, these prototypes should default to having the correct name. On the other hand, id cards are - // rarely ever spawned in on their own without an owner, so this is fine. - id.OriginalEntityName ??= EntityManager.GetComponent(id.Owner).EntityName; UpdateEntityName(uid, id); } @@ -80,21 +77,32 @@ namespace Content.Server.Access.Systems /// /// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs. /// - public bool TryChangeJobTitle(EntityUid uid, string jobTitle, IdCardComponent? id = null, EntityUid? player = null) + public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null) { if (!Resolve(uid, ref id)) return false; - if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength) - jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength]; + if (!string.IsNullOrWhiteSpace(jobTitle)) + { + jobTitle = jobTitle.Trim(); + + if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength) + jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength]; + } + else + { + jobTitle = null; + } id.JobTitle = jobTitle; Dirty(id); UpdateEntityName(uid, id); if (player != null) + { _adminLogger.Add(LogType.Identity, LogImpact.Low, - $"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(id.Owner):entity} to {jobTitle} "); + $"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(id.Owner):entity} to {jobTitle} "); + } return true; } @@ -105,21 +113,31 @@ namespace Content.Server.Access.Systems /// /// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs. /// - public bool TryChangeFullName(EntityUid uid, string fullName, IdCardComponent? id = null, EntityUid? player = null) + public bool TryChangeFullName(EntityUid uid, string? fullName, IdCardComponent? id = null, EntityUid? player = null) { if (!Resolve(uid, ref id)) return false; - if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength) - fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength]; + if (!string.IsNullOrWhiteSpace(fullName)) + { + fullName = fullName.Trim(); + if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength) + fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength]; + } + else + { + fullName = null; + } id.FullName = fullName; Dirty(id); UpdateEntityName(uid, id); if (player != null) + { _adminLogger.Add(LogType.Identity, LogImpact.Low, - $"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(id.Owner):entity} to {fullName} "); + $"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(id.Owner):entity} to {fullName} "); + } return true; } @@ -135,17 +153,10 @@ namespace Content.Server.Access.Systems if (!Resolve(uid, ref id)) return; - if (string.IsNullOrWhiteSpace(id.FullName) && string.IsNullOrWhiteSpace(id.JobTitle)) - { - EntityManager.GetComponent(id.Owner).EntityName = id.OriginalEntityName; - return; - } - var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})"; var val = string.IsNullOrWhiteSpace(id.FullName) ? Loc.GetString("access-id-card-component-owner-name-job-title-text", - ("originalOwnerName", id.OriginalEntityName), ("jobSuffix", jobSuffix)) : Loc.GetString("access-id-card-component-owner-full-name-job-title-text", ("fullName", id.FullName), diff --git a/Content.Server/Access/Systems/IdExaminableSystem.cs b/Content.Server/Access/Systems/IdExaminableSystem.cs index 2966624368..2e02b33cec 100644 --- a/Content.Server/Access/Systems/IdExaminableSystem.cs +++ b/Content.Server/Access/Systems/IdExaminableSystem.cs @@ -66,7 +66,6 @@ public sealed class IdExaminableSystem : EntitySystem var val = string.IsNullOrWhiteSpace(id.FullName) ? Loc.GetString("access-id-card-component-owner-name-job-title-text", - ("originalOwnerName", id.OriginalEntityName), ("jobSuffix", jobSuffix)) : Loc.GetString("access-id-card-component-owner-full-name-job-title-text", ("fullName", id.FullName), diff --git a/Content.Server/Mind/Commands/RenameCommand.cs b/Content.Server/Mind/Commands/RenameCommand.cs index 23b20b95f4..b256e1bda8 100644 --- a/Content.Server/Mind/Commands/RenameCommand.cs +++ b/Content.Server/Mind/Commands/RenameCommand.cs @@ -58,15 +58,6 @@ public sealed class RenameCommand : IConsoleCommand { if (idCardSystem.TryFindIdCard(entityUid, out var idCard)) idCardSystem.TryChangeFullName(idCard.Owner, name, idCard); - else - { - foreach (var idCardComponent in entMan.EntityQuery()) - { - if (idCardComponent.OriginalEntityName != oldName) - continue; - idCardSystem.TryChangeFullName(idCardComponent.Owner, name, idCardComponent); - } - } } // PDAs diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index f63504e157..06dc11b091 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -9,9 +9,6 @@ namespace Content.Shared.Access.Components [Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))] public sealed class IdCardComponent : Component { - [DataField("originalEntityName")] - public string OriginalEntityName = string.Empty; - [DataField("fullName")] [Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)] // FIXME Friends diff --git a/Resources/Locale/en-US/access/components/id-card-component.ftl b/Resources/Locale/en-US/access/components/id-card-component.ftl index a07d94e66a..539d755433 100644 --- a/Resources/Locale/en-US/access/components/id-card-component.ftl +++ b/Resources/Locale/en-US/access/components/id-card-component.ftl @@ -1,7 +1,8 @@ ## IdCardComponent -access-id-card-component-owner-name-job-title-text = {$originalOwnerName}{$jobSuffix} +access-id-card-component-owner-name-job-title-text = ID card{$jobSuffix} access-id-card-component-owner-full-name-job-title-text = {$fullName}'s ID card{$jobSuffix} +access-id-card-component-default = ID card id-card-component-microwave-burnt = {$id}'s circuits pop loudly! id-card-component-microwave-bricked = {$id}'s circuits sizzle!