HumanoidCharacterProfile and IdCardConsoleComponent constants moved to cvar. Sync id card length with character name length (#35407)

* commit

* mark TODOs

* compiles

* cleanup

* cleanup

* oops

* changed my mind

* requested changes

* genpop fix
This commit is contained in:
āda
2025-05-17 00:27:39 -05:00
committed by GitHub
parent 0fed68d240
commit de24413bd5
17 changed files with 158 additions and 35 deletions

View File

@@ -1,6 +1,7 @@
using System.Globalization;
using Content.Shared.Access.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
@@ -8,6 +9,7 @@ using Content.Shared.Inventory;
using Content.Shared.PDA;
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
@@ -15,6 +17,7 @@ namespace Content.Shared.Access.Systems;
public abstract class SharedIdCardSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedAccessSystem _access = default!;
@@ -22,6 +25,10 @@ public abstract class SharedIdCardSystem : EntitySystem
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
// CCVar.
private int _maxNameLength;
private int _maxIdJobLength;
public override void Initialize()
{
base.Initialize();
@@ -29,6 +36,9 @@ public abstract class SharedIdCardSystem : EntitySystem
SubscribeLocalEvent<IdCardComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<TryGetIdentityShortInfoEvent>(OnTryGetIdentityShortInfo);
SubscribeLocalEvent<EntityRenamedEvent>(OnRename);
Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
Subs.CVar(_cfgManager, CCVars.MaxIdJobLength, value => _maxIdJobLength = value, true);
}
private void OnRename(ref EntityRenamedEvent ev)
@@ -131,8 +141,8 @@ public abstract class SharedIdCardSystem : EntitySystem
{
jobTitle = jobTitle.Trim();
if (jobTitle.Length > IdCardConsoleComponent.MaxJobTitleLength)
jobTitle = jobTitle[..IdCardConsoleComponent.MaxJobTitleLength];
if (jobTitle.Length > _maxIdJobLength)
jobTitle = jobTitle[.._maxIdJobLength];
}
else
{
@@ -209,8 +219,8 @@ public abstract class SharedIdCardSystem : EntitySystem
if (!string.IsNullOrWhiteSpace(fullName))
{
fullName = fullName.Trim();
if (fullName.Length > IdCardConsoleComponent.MaxFullNameLength)
fullName = fullName[..IdCardConsoleComponent.MaxFullNameLength];
if (fullName.Length > _maxNameLength)
fullName = fullName[.._maxNameLength];
}
else
{