empty id card name fix (#10860)
This commit is contained in:
@@ -29,9 +29,6 @@ namespace Content.Server.Access.Systems
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, IdCardComponent id, MapInitEvent args)
|
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<MetaDataComponent>(id.Owner).EntityName;
|
|
||||||
UpdateEntityName(uid, id);
|
UpdateEntityName(uid, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,21 +77,32 @@ namespace Content.Server.Access.Systems
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
|
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
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))
|
if (!Resolve(uid, ref id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength)
|
if (!string.IsNullOrWhiteSpace(jobTitle))
|
||||||
jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength];
|
{
|
||||||
|
jobTitle = jobTitle.Trim();
|
||||||
|
|
||||||
|
if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength)
|
||||||
|
jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jobTitle = null;
|
||||||
|
}
|
||||||
|
|
||||||
id.JobTitle = jobTitle;
|
id.JobTitle = jobTitle;
|
||||||
Dirty(id);
|
Dirty(id);
|
||||||
UpdateEntityName(uid, id);
|
UpdateEntityName(uid, id);
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
|
{
|
||||||
_adminLogger.Add(LogType.Identity, LogImpact.Low,
|
_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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,21 +113,31 @@ namespace Content.Server.Access.Systems
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
|
/// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
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))
|
if (!Resolve(uid, ref id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength)
|
if (!string.IsNullOrWhiteSpace(fullName))
|
||||||
fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength];
|
{
|
||||||
|
fullName = fullName.Trim();
|
||||||
|
if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength)
|
||||||
|
fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fullName = null;
|
||||||
|
}
|
||||||
|
|
||||||
id.FullName = fullName;
|
id.FullName = fullName;
|
||||||
Dirty(id);
|
Dirty(id);
|
||||||
UpdateEntityName(uid, id);
|
UpdateEntityName(uid, id);
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
|
{
|
||||||
_adminLogger.Add(LogType.Identity, LogImpact.Low,
|
_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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,17 +153,10 @@ namespace Content.Server.Access.Systems
|
|||||||
if (!Resolve(uid, ref id))
|
if (!Resolve(uid, ref id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(id.FullName) && string.IsNullOrWhiteSpace(id.JobTitle))
|
|
||||||
{
|
|
||||||
EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName = id.OriginalEntityName;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
|
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
|
||||||
|
|
||||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
||||||
("originalOwnerName", id.OriginalEntityName),
|
|
||||||
("jobSuffix", jobSuffix))
|
("jobSuffix", jobSuffix))
|
||||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
||||||
("fullName", id.FullName),
|
("fullName", id.FullName),
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public sealed class IdExaminableSystem : EntitySystem
|
|||||||
|
|
||||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
||||||
("originalOwnerName", id.OriginalEntityName),
|
|
||||||
("jobSuffix", jobSuffix))
|
("jobSuffix", jobSuffix))
|
||||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
||||||
("fullName", id.FullName),
|
("fullName", id.FullName),
|
||||||
|
|||||||
@@ -58,15 +58,6 @@ public sealed class RenameCommand : IConsoleCommand
|
|||||||
{
|
{
|
||||||
if (idCardSystem.TryFindIdCard(entityUid, out var idCard))
|
if (idCardSystem.TryFindIdCard(entityUid, out var idCard))
|
||||||
idCardSystem.TryChangeFullName(idCard.Owner, name, idCard);
|
idCardSystem.TryChangeFullName(idCard.Owner, name, idCard);
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var idCardComponent in entMan.EntityQuery<IdCardComponent>())
|
|
||||||
{
|
|
||||||
if (idCardComponent.OriginalEntityName != oldName)
|
|
||||||
continue;
|
|
||||||
idCardSystem.TryChangeFullName(idCardComponent.Owner, name, idCardComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PDAs
|
// PDAs
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ namespace Content.Shared.Access.Components
|
|||||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))]
|
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))]
|
||||||
public sealed class IdCardComponent : Component
|
public sealed class IdCardComponent : Component
|
||||||
{
|
{
|
||||||
[DataField("originalEntityName")]
|
|
||||||
public string OriginalEntityName = string.Empty;
|
|
||||||
|
|
||||||
[DataField("fullName")]
|
[DataField("fullName")]
|
||||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem),
|
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem),
|
||||||
Other = AccessPermissions.ReadWrite)] // FIXME Friends
|
Other = AccessPermissions.ReadWrite)] // FIXME Friends
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
## IdCardComponent
|
## 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-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-burnt = {$id}'s circuits pop loudly!
|
||||||
id-card-component-microwave-bricked = {$id}'s circuits sizzle!
|
id-card-component-microwave-bricked = {$id}'s circuits sizzle!
|
||||||
|
|||||||
Reference in New Issue
Block a user