]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
HumanoidCharacterProfile and IdCardConsoleComponent constants moved to cvar. Sync...
authorāda <ss.adasts@gmail.com>
Sat, 17 May 2025 05:27:39 +0000 (00:27 -0500)
committerGitHub <noreply@github.com>
Sat, 17 May 2025 05:27:39 +0000 (15:27 +1000)
* commit

* mark TODOs

* compiles

* cleanup

* cleanup

* oops

* changed my mind

* requested changes

* genpop fix

17 files changed:
Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs
Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs
Content.Client/Pinpointer/UI/NavMapBeaconWindow.xaml.cs
Content.Client/Security/Ui/GenpopLockerMenu.xaml.cs
Content.Client/Silicons/Borgs/BorgMenu.xaml.cs
Content.Server/Mind/Commands/RenameCommand.cs
Content.Server/Silicons/Borgs/BorgSystem.Ui.cs
Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Server/VoiceMask/VoiceMaskSystem.cs
Content.Shared/Access/Components/IdCardConsoleComponent.cs
Content.Shared/Access/Systems/SharedIdCardSystem.cs
Content.Shared/CCVar/CCVars.Ic.cs
Content.Shared/Preferences/HumanoidCharacterProfile.cs
Content.Shared/Preferences/Loadouts/RoleLoadout.cs
Content.Shared/Security/Systems/SharedGenpopSystem.cs

index a321b4121e58eae37f7ba953726942fdf7a81d81..f3a37f054e55e8731b683a3f60460e54e08353b1 100644 (file)
@@ -1,8 +1,10 @@
 using Content.Shared.Access;
 using Content.Shared.Access.Components;
 using Content.Shared.Access.Systems;
+using Content.Shared.CCVar;
 using Content.Shared.Containers.ItemSlots;
 using Content.Shared.CrewManifest;
+using Robust.Shared.Configuration;
 using Robust.Shared.Prototypes;
 using static Content.Shared.Access.Components.IdCardConsoleComponent;
 
@@ -11,13 +13,21 @@ namespace Content.Client.Access.UI
     public sealed class IdCardConsoleBoundUserInterface : BoundUserInterface
     {
         [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+        [Dependency] private readonly IConfigurationManager _cfgManager = default!;
         private readonly SharedIdCardConsoleSystem _idCardConsoleSystem = default!;
 
         private IdCardConsoleWindow? _window;
 
+        // CCVar.
+        private int _maxNameLength;
+        private int _maxIdJobLength;
+
         public IdCardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
         {
             _idCardConsoleSystem = EntMan.System<SharedIdCardConsoleSystem>();
+
+            _maxNameLength =_cfgManager.GetCVar(CCVars.MaxNameLength);
+            _maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
         }
 
         protected override void Open()
@@ -66,11 +76,11 @@ namespace Content.Client.Access.UI
 
         public void SubmitData(string newFullName, string newJobTitle, List<ProtoId<AccessLevelPrototype>> newAccessList, string newJobPrototype)
         {
-            if (newFullName.Length > MaxFullNameLength)
-                newFullName = newFullName[..MaxFullNameLength];
+            if (newFullName.Length > _maxNameLength)
+                newFullName = newFullName[.._maxNameLength];
 
-            if (newJobTitle.Length > MaxJobTitleLength)
-                newJobTitle = newJobTitle[..MaxJobTitleLength];
+            if (newJobTitle.Length > _maxIdJobLength)
+                newJobTitle = newJobTitle[.._maxIdJobLength];
 
             SendMessage(new WriteToTargetIdMessage(
                 newFullName,
index c133e0b107a802311c0f4e458dd2ca98a0767b99..48ae1b0ced5c1669699b0abb761df25d352b1cb4 100644 (file)
@@ -1,11 +1,13 @@
 using System.Linq;
 using Content.Shared.Access;
 using Content.Shared.Access.Systems;
+using Content.Shared.CCVar;
 using Content.Shared.Roles;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.CustomControls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
 using Robust.Shared.Prototypes;
 using static Content.Shared.Access.Components.IdCardConsoleComponent;
 
@@ -14,12 +16,17 @@ namespace Content.Client.Access.UI
     [GenerateTypedNameReferences]
     public sealed partial class IdCardConsoleWindow : DefaultWindow
     {
+        [Dependency] private readonly IConfigurationManager _cfgManager = default!;
         [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
         [Dependency] private readonly ILogManager _logManager = default!;
         private readonly ISawmill _logMill = default!;
 
         private readonly IdCardConsoleBoundUserInterface _owner;
 
+        // CCVar.
+        private int _maxNameLength;
+        private int _maxIdJobLength;
+
         private AccessLevelControl _accessButtons = new();
         private readonly List<string> _jobPrototypeIds = new();
 
@@ -39,7 +46,11 @@ namespace Content.Client.Access.UI
 
             _owner = owner;
 
+            _maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
+            _maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
+
             FullNameLineEdit.OnTextEntered += _ => SubmitData();
+            FullNameLineEdit.IsValid = s => s.Length <= _maxNameLength;
             FullNameLineEdit.OnTextChanged += _ =>
             {
                 FullNameSaveButton.Disabled = FullNameSaveButton.Text == _lastFullName;
@@ -47,6 +58,7 @@ namespace Content.Client.Access.UI
             FullNameSaveButton.OnPressed += _ => SubmitData();
 
             JobTitleLineEdit.OnTextEntered += _ => SubmitData();
+            JobTitleLineEdit.IsValid = s => s.Length <= _maxIdJobLength;
             JobTitleLineEdit.OnTextChanged += _ =>
             {
                 JobTitleSaveButton.Disabled = JobTitleLineEdit.Text == _lastJobTitle;
index 135bd58d78cdad12e41b1d0e7300ebf22e9daf6a..aa18751db018e185b04d6c6bc8c5971a911ad32c 100644 (file)
@@ -53,6 +53,10 @@ namespace Content.Client.Lobby.UI
 
         private readonly SpriteSystem _sprite;
 
+        // CCvar.
+        private int _maxNameLength;
+        private bool _allowFlavorText;
+
         private FlavorText.FlavorText? _flavorText;
         private TextEdit? _flavorTextEdit;
 
@@ -131,6 +135,10 @@ namespace Content.Client.Lobby.UI
             _requirements = requirements;
             _controller = UserInterfaceManager.GetUIController<LobbyUIController>();
             _sprite = _entManager.System<SpriteSystem>();
+
+            _maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
+            _allowFlavorText = _cfgManager.GetCVar(CCVars.FlavorText);
+
             ImportButton.OnPressed += args =>
             {
                 ImportProfile();
@@ -166,6 +174,7 @@ namespace Content.Client.Lobby.UI
             #region Name
 
             NameEdit.OnTextChanged += args => { SetName(args.Text); };
+            NameEdit.IsValid = args => args.Length <= _maxNameLength;
             NameRandomize.OnPressed += args => RandomizeName();
             RandomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
             WarningLabel.SetMarkup($"[color=red]{Loc.GetString("humanoid-profile-editor-naming-rules-warning")}[/color]");
@@ -451,7 +460,7 @@ namespace Content.Client.Lobby.UI
         /// </summary>
         public void RefreshFlavorText()
         {
-            if (_cfgManager.GetCVar(CCVars.FlavorText))
+            if (_allowFlavorText)
             {
                 if (_flavorText != null)
                     return;
index 48b5289efc93ca2e34d9cdd21983f81138d7108b..68e1ecbeaeefdb8c22b8ffc8440634db35a4fefe 100644 (file)
@@ -1,11 +1,13 @@
 using System.Numerics;
 using Content.Client.UserInterface.Controls;
+using Content.Shared.CCVar;
 using Content.Shared.Dataset;
 using Content.Shared.Preferences;
 using Content.Shared.Preferences.Loadouts;
 using Content.Shared.Random.Helpers;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
@@ -23,12 +25,18 @@ public sealed partial class LoadoutWindow : FancyWindow
 
     public HumanoidCharacterProfile Profile;
 
+    // CCvar.
+    private int _maxLoadoutNameLength;
+
     public LoadoutWindow(HumanoidCharacterProfile profile, RoleLoadout loadout, RoleLoadoutPrototype proto, ICommonSession session, IDependencyCollection collection)
     {
         RobustXamlLoader.Load(this);
         Profile = profile;
         var protoManager = collection.Resolve<IPrototypeManager>();
-        RoleNameEdit.IsValid = text => text.Length <= HumanoidCharacterProfile.MaxLoadoutNameLength;
+        var configManager = collection.Resolve<IConfigurationManager>();
+
+        _maxLoadoutNameLength = configManager.GetCVar(CCVars.MaxLoadoutNameLength);
+        RoleNameEdit.IsValid = text => text.Length <= _maxLoadoutNameLength;
 
         // Hide if we can't edit the name.
         if (!proto.CanCustomizeName)
@@ -45,7 +53,7 @@ public sealed partial class LoadoutWindow : FancyWindow
 
             RoleNameEdit.ToolTip = Loc.GetString(
                 "loadout-name-edit-tooltip",
-                ("max", HumanoidCharacterProfile.MaxLoadoutNameLength));
+                ("max", _maxLoadoutNameLength));
             RoleNameEdit.Text = name ?? string.Empty;
             RoleNameEdit.OnTextChanged += args => OnNameChanged?.Invoke(args.Text);
         }
index b77f1af0472d3dc1e598aecd9ec827db07a6c453..291270f05a446d93132e099a7b3cbecd411b3a09 100644 (file)
@@ -1,19 +1,25 @@
 using Content.Client.UserInterface.Controls;
+using Content.Shared.CCVar;
 using Content.Shared.Pinpointer;
 using Content.Shared.Preferences;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
 
 namespace Content.Client.Pinpointer.UI;
 
 [GenerateTypedNameReferences]
 public sealed partial class NavMapBeaconWindow : FancyWindow
 {
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     private string? _defaultLabel;
     private bool _defaultEnabled;
     private Color _defaultColor;
 
+    // CCVar.
+    private int _maxNameLength;
+
     public event Action<string?, bool, Color>? OnApplyButtonPressed;
 
     public NavMapBeaconWindow()
@@ -21,6 +27,7 @@ public sealed partial class NavMapBeaconWindow : FancyWindow
         RobustXamlLoader.Load(this);
         IoCManager.InjectDependencies(this);
 
+        _maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
 
         VisibleButton.OnPressed += args => UpdateVisibleButton(args.Button.Pressed);
         LabelLineEdit.OnTextChanged += OnTextChanged;
@@ -53,8 +60,8 @@ public sealed partial class NavMapBeaconWindow : FancyWindow
 
     private void OnTextChanged(LineEdit.LineEditEventArgs obj)
     {
-        if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength)
-            obj.Control.Text = obj.Text.Substring(0, HumanoidCharacterProfile.MaxNameLength);
+        if (obj.Text.Length > _maxNameLength)
+            obj.Control.Text = obj.Text.Substring(0, _maxNameLength);
 
         TryEnableApplyButton();
     }
index 575b2f50dfa3f5abaaefd649b0aee40556c7b717..70081211d27202bbce0f9397a629f8c5a7424142 100644 (file)
@@ -1,21 +1,30 @@
 using Content.Client.Message;
 using Content.Client.UserInterface.Controls;
 using Content.Shared.Access.Components;
+using Content.Shared.CCVar;
 using Content.Shared.Security.Components;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
 
 namespace Content.Client.Security.Ui;
 
 [GenerateTypedNameReferences]
 public sealed partial class GenpopLockerMenu : FancyWindow
 {
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
+
     public event Action<string, float, string>? OnConfigurationComplete;
 
+    // CCVar.
+    private int _maxIdJobLength;
+
     public GenpopLockerMenu(EntityUid owner, IEntityManager entMan)
     {
         RobustXamlLoader.Load(this);
 
+        _maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
+
         Title = entMan.GetComponent<MetaDataComponent>(owner).EntityName;
 
         NameLabel.SetMarkup(Loc.GetString("genpop-locker-ui-label-name"));
@@ -25,7 +34,7 @@ public sealed partial class GenpopLockerMenu : FancyWindow
         SentenceEdit.Text = "5";
         CrimeEdit.Text = Loc.GetString("genpop-prisoner-id-crime-default");
 
-        NameEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= IdCardConsoleComponent.MaxFullNameLength;
+        NameEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= _maxIdJobLength;
         SentenceEdit.IsValid = val => float.TryParse(val, out var f) && f >= 0;
         CrimeEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= GenpopLockerComponent.MaxCrimeLength;
 
index 007a0cc5cbe9f90b0ef1aca39c33e05ec97caea7..b9e07adef0ba01d0554c9481021d05c21624ca6b 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Client.Stylesheets;
 using Content.Client.UserInterface.Controls;
+using Content.Shared.CCVar;
 using Content.Shared.NameIdentifier;
 using Content.Shared.NameModifier.EntitySystems;
 using Content.Shared.Preferences;
@@ -8,6 +9,7 @@ using Content.Shared.Silicons.Borgs.Components;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
 using Robust.Shared.Timing;
 
 namespace Content.Client.Silicons.Borgs;
@@ -15,6 +17,7 @@ namespace Content.Client.Silicons.Borgs;
 [GenerateTypedNameReferences]
 public sealed partial class BorgMenu : FancyWindow
 {
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     [Dependency] private readonly IEntityManager _entity = default!;
     private readonly NameModifierSystem _nameModifier;
 
@@ -27,6 +30,9 @@ public sealed partial class BorgMenu : FancyWindow
     private string _lastValidName;
     private List<EntityUid> _modules = new();
 
+    // CCVar.
+    private int _maxNameLength;
+
     public EntityUid Entity;
 
     public BorgMenu()
@@ -36,6 +42,8 @@ public sealed partial class BorgMenu : FancyWindow
 
         _nameModifier = _entity.System<NameModifierSystem>();
 
+        _maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
+
         _lastValidName = NameLineEdit.Text;
 
         EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke();
@@ -153,9 +161,9 @@ public sealed partial class BorgMenu : FancyWindow
             return;
         }
 
-        if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength)
+        if (obj.Text.Length > _maxNameLength)
         {
-            obj.Control.Text = obj.Text.Substring(0, HumanoidCharacterProfile.MaxNameLength);
+            obj.Control.Text = obj.Text.Substring(0, _maxNameLength);
         }
 
         _lastValidName = obj.Control.Text;
@@ -169,7 +177,7 @@ public sealed partial class BorgMenu : FancyWindow
 
     private void OnNameFocusExit(LineEdit.LineEditEventArgs obj)
     {
-        if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength ||
+        if (obj.Text.Length > _maxNameLength ||
             obj.Text.Length == 0 ||
             string.IsNullOrWhiteSpace(obj.Text) ||
             string.IsNullOrEmpty(obj.Text))
index f283fe5d19cededfcd7f182155ea95179aed7547..b0059ab4256c20c783ef641d53b6d98be9569e1e 100644 (file)
@@ -2,7 +2,9 @@ using System.Diagnostics.CodeAnalysis;
 using Content.Server.Administration;
 using Content.Shared.Access.Components;
 using Content.Shared.Administration;
+using Content.Shared.CCVar;
 using Robust.Server.Player;
+using Robust.Shared.Configuration;
 using Robust.Shared.Console;
 
 namespace Content.Server.Mind.Commands;
@@ -10,6 +12,7 @@ namespace Content.Server.Mind.Commands;
 [AdminCommand(AdminFlags.VarEdit)]
 public sealed class RenameCommand : LocalizedEntityCommands
 {
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     [Dependency] private readonly IEntityManager _entManager = default!;
     [Dependency] private readonly IPlayerManager _playerManager = default!;
     [Dependency] private readonly MetaDataSystem _metaSystem = default!;
@@ -25,7 +28,7 @@ public sealed class RenameCommand : LocalizedEntityCommands
         }
 
         var name = args[1];
-        if (name.Length > IdCardConsoleComponent.MaxFullNameLength)
+        if (name.Length > _cfgManager.GetCVar(CCVars.MaxNameLength))
         {
             shell.WriteLine(Loc.GetString("cmd-rename-too-long"));
             return;
index 191b2264211d65232182b11ac5021d807208f11d..58cd7135af9221d7cf2dfdb0ce1f34e53f9c9248 100644 (file)
@@ -1,17 +1,22 @@
 using System.Linq;
 using Content.Shared.UserInterface;
+using Content.Shared.CCVar;
 using Content.Shared.Database;
 using Content.Shared.NameIdentifier;
 using Content.Shared.PowerCell.Components;
 using Content.Shared.Preferences;
 using Content.Shared.Silicons.Borgs;
 using Content.Shared.Silicons.Borgs.Components;
+using Robust.Shared.Configuration;
 
 namespace Content.Server.Silicons.Borgs;
 
 /// <inheritdoc/>
 public sealed partial class BorgSystem
 {
+    // CCvar.
+    private int _maxNameLength;
+
     public void InitializeUI()
     {
         SubscribeLocalEvent<BorgChassisComponent, BeforeActivatableUIOpenEvent>(OnBeforeBorgUiOpen);
@@ -19,6 +24,8 @@ public sealed partial class BorgSystem
         SubscribeLocalEvent<BorgChassisComponent, BorgEjectBatteryBuiMessage>(OnEjectBatteryBuiMessage);
         SubscribeLocalEvent<BorgChassisComponent, BorgSetNameBuiMessage>(OnSetNameBuiMessage);
         SubscribeLocalEvent<BorgChassisComponent, BorgRemoveModuleBuiMessage>(OnRemoveModuleBuiMessage);
+
+        Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
     }
 
     private void OnBeforeBorgUiOpen(EntityUid uid, BorgChassisComponent component, BeforeActivatableUIOpenEvent args)
@@ -46,7 +53,7 @@ public sealed partial class BorgSystem
 
     private void OnSetNameBuiMessage(EntityUid uid, BorgChassisComponent component, BorgSetNameBuiMessage args)
     {
-        if (args.Name.Length > HumanoidCharacterProfile.MaxNameLength ||
+        if (args.Name.Length > _maxNameLength ||
             args.Name.Length == 0 ||
             string.IsNullOrWhiteSpace(args.Name) ||
             string.IsNullOrEmpty(args.Name))
index e9d8a08c6f8df781fe7f16932feb3a5cadd19db3..65154601ddf10df2f5821847f4d68a7a3d2f581e 100644 (file)
@@ -27,6 +27,7 @@ using Content.Shared.Throwing;
 using Content.Shared.Whitelist;
 using Content.Shared.Wires;
 using Robust.Server.GameObjects;
+using Robust.Shared.Configuration;
 using Robust.Shared.Containers;
 using Robust.Shared.Player;
 using Robust.Shared.Random;
@@ -41,6 +42,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
 {
     [Dependency] private readonly IAdminLogManager _adminLog = default!;
     [Dependency] private readonly IBanManager _banManager = default!;
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly ActionsSystem _actions = default!;
index 47ea98d2ccfbda0abd0a74c108fb8ba49f00179c..cd85ff242847ce18009bd13ea688de4b0fb5bfc0 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.Actions;
 using Content.Shared.Administration.Logs;
+using Content.Shared.CCVar;
 using Content.Shared.Chat;
 using Content.Shared.Clothing;
 using Content.Shared.Database;
@@ -8,6 +9,7 @@ using Content.Shared.Popups;
 using Content.Shared.Preferences;
 using Content.Shared.Speech;
 using Content.Shared.VoiceMask;
+using Robust.Shared.Configuration;
 using Robust.Shared.Prototypes;
 
 namespace Content.Server.VoiceMask;
@@ -16,10 +18,14 @@ public sealed partial class VoiceMaskSystem : EntitySystem
 {
     [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
     [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
     [Dependency] private readonly IPrototypeManager _proto = default!;
     [Dependency] private readonly SharedActionsSystem _actions = default!;
 
+    // CCVar.
+    private int _maxNameLength;
+
     public override void Initialize()
     {
         base.Initialize();
@@ -28,6 +34,8 @@ public sealed partial class VoiceMaskSystem : EntitySystem
         SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeVerbMessage>(OnChangeVerb);
         SubscribeLocalEvent<VoiceMaskComponent, ClothingGotEquippedEvent>(OnEquip);
         SubscribeLocalEvent<VoiceMaskSetNameEvent>(OpenUI);
+
+        Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
     }
 
     private void OnTransformSpeakerName(Entity<VoiceMaskComponent> entity, ref InventoryRelayedEvent<TransformSpeakerNameEvent> args)
@@ -52,7 +60,7 @@ public sealed partial class VoiceMaskSystem : EntitySystem
 
     private void OnChangeName(Entity<VoiceMaskComponent> entity, ref VoiceMaskChangeNameMessage message)
     {
-        if (message.Name.Length > HumanoidCharacterProfile.MaxNameLength || message.Name.Length <= 0)
+        if (message.Name.Length > _maxNameLength || message.Name.Length <= 0)
         {
             _popupSystem.PopupEntity(Loc.GetString("voice-mask-popup-failure"), entity, message.Actor, PopupType.SmallCaution);
             return;
index 4f1c27fb4d368509e373ea0c4152529ff50ee3e9..8d54024f72a0bda4f72379ce9c0ef94e888db046 100644 (file)
@@ -10,9 +10,6 @@ namespace Content.Shared.Access.Components;
 [Access(typeof(SharedIdCardConsoleSystem))]
 public sealed partial class IdCardConsoleComponent : Component
 {
-    public const int MaxFullNameLength = 30;
-    public const int MaxJobTitleLength = 30;
-
     public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId";
     public static string TargetIdCardSlotId = "IdCardConsole-targetId";
 
index 69d77fe9ecdd3e65bf6fd40010abb1025789b8c9..a2f59a5a34b2b4d269eac6ce32f83018bb6cac30 100644 (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
         {
index b835a8f20e9b1dbab3bbb7fa87989f661137a99a..5f8d108a22123791d803c943323098564826538e 100644 (file)
@@ -11,11 +11,35 @@ public sealed partial class CCVars
         CVarDef.Create("ic.restricted_names", true, CVar.SERVER | CVar.REPLICATED);
 
     /// <summary>
-    ///     Allows flavor text (character descriptions)
+    ///     Sets the maximum IC name length.
+    /// </summary>
+    public static readonly CVarDef<int> MaxNameLength =
+        CVarDef.Create("ic.name_length", 32, CVar.SERVER | CVar.REPLICATED);
+
+    /// <summary>
+    ///     Sets the maximum name length for a loadout name (e.g. cyborg name).
+    /// </summary>
+    public static readonly CVarDef<int> MaxLoadoutNameLength =
+        CVarDef.Create("ic.loadout_name_length", 32, CVar.SERVER | CVar.REPLICATED);
+
+    /// <summary>
+    ///     Allows flavor text (character descriptions).
     /// </summary>
     public static readonly CVarDef<bool> FlavorText =
         CVarDef.Create("ic.flavor_text", false, CVar.SERVER | CVar.REPLICATED);
 
+    /// <summary>
+    ///     Sets the maximum length for flavor text (character descriptions).
+    /// </summary>
+    public static readonly CVarDef<int> MaxFlavorTextLength =
+        CVarDef.Create("ic.flavor_text_length", 512, CVar.SERVER | CVar.REPLICATED);
+
+    /// <summary>
+    ///     Sets the maximum character length of a job on an ID.
+    /// </summary>
+    public static readonly CVarDef<int> MaxIdJobLength =
+        CVarDef.Create("ic.id_job_length", 30, CVar.SERVER | CVar.REPLICATED);
+
     /// <summary>
     ///     Adds a period at the end of a sentence if the sentence ends in a letter.
     /// </summary>
index 16064e61ac8d33782413052f6921c3197e853bcd..616b21319405ccfa241b0450eb1019d3b3c31358 100644 (file)
@@ -28,10 +28,6 @@ namespace Content.Shared.Preferences
         private static readonly Regex RestrictedNameRegex = new(@"[^A-Za-z0-9 '\-]");
         private static readonly Regex ICNameCaseRegex = new(@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)");
 
-        public const int MaxNameLength = 32;
-        public const int MaxLoadoutNameLength = 32;
-        public const int MaxDescLength = 512;
-
         /// <summary>
         /// Job preferences for initial spawn.
         /// </summary>
@@ -508,13 +504,14 @@ namespace Content.Shared.Preferences
             };
 
             string name;
+            var maxNameLength = configManager.GetCVar(CCVars.MaxNameLength);
             if (string.IsNullOrEmpty(Name))
             {
                 name = GetName(Species, gender);
             }
-            else if (Name.Length > MaxNameLength)
+            else if (Name.Length > maxNameLength)
             {
-                name = Name[..MaxNameLength];
+                name = Name[..maxNameLength];
             }
             else
             {
@@ -540,9 +537,10 @@ namespace Content.Shared.Preferences
             }
 
             string flavortext;
-            if (FlavorText.Length > MaxDescLength)
+            var maxFlavorTextLength = configManager.GetCVar(CCVars.MaxFlavorTextLength);
+            if (FlavorText.Length > maxFlavorTextLength)
             {
-                flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..MaxDescLength];
+                flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..maxFlavorTextLength];
             }
             else
             {
index 47f2d627843d190c629ce65f2edc3b9e0ed2e062..9b7f4ae05e37671c92fb8f74f132b90d2db7c2b5 100644 (file)
@@ -1,8 +1,10 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
+using Content.Shared.CCVar;
 using Content.Shared.Humanoid.Prototypes;
 using Content.Shared.Random;
 using Robust.Shared.Collections;
+using Robust.Shared.Configuration;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Serialization;
@@ -59,6 +61,7 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
     {
         var groupRemove = new ValueList<string>();
         var protoManager = collection.Resolve<IPrototypeManager>();
+        var configManager = collection.Resolve<IConfigurationManager>();
 
         if (!protoManager.TryIndex(Role, out var roleProto))
         {
@@ -78,10 +81,11 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
         if (EntityName != null)
         {
             var name = EntityName.Trim();
+            var maxNameLength = configManager.GetCVar(CCVars.MaxNameLength);
 
-            if (name.Length > HumanoidCharacterProfile.MaxNameLength)
+            if (name.Length > maxNameLength)
             {
-                EntityName = name[..HumanoidCharacterProfile.MaxNameLength];
+                EntityName = name[..maxNameLength];
             }
 
             if (name.Length == 0)
index 39fc87f66552664c9dcf6bf61f9e0e974a99b1cc..66bf5ca25401392ae6c51f465db3621404c031f5 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.Access.Components;
 using Content.Shared.Access.Systems;
+using Content.Shared.CCVar;
 using Content.Shared.Database;
 using Content.Shared.Examine;
 using Content.Shared.Lock;
@@ -8,12 +9,14 @@ using Content.Shared.Security.Components;
 using Content.Shared.Storage.Components;
 using Content.Shared.Storage.EntitySystems;
 using Content.Shared.Verbs;
+using Robust.Shared.Configuration;
 using Robust.Shared.Timing;
 
 namespace Content.Shared.Security.Systems;
 
 public abstract class SharedGenpopSystem : EntitySystem
 {
+    [Dependency] private readonly IConfigurationManager _cfgManager = default!;
     [Dependency] protected readonly IGameTiming Timing = default!;
     [Dependency] private readonly AccessReaderSystem _accessReader = default!;
     [Dependency] private readonly SharedEntityStorageSystem _entityStorage = default!;
@@ -23,6 +26,8 @@ public abstract class SharedGenpopSystem : EntitySystem
     [Dependency] private readonly SharedPopupSystem _popup = default!;
     [Dependency] private readonly SharedUserInterfaceSystem _userInterface = default!;
 
+    // CCvar.
+    private int _maxIdJobLength;
 
     /// <inheritdoc/>
     public override void Initialize()
@@ -33,12 +38,14 @@ public abstract class SharedGenpopSystem : EntitySystem
         SubscribeLocalEvent<GenpopLockerComponent, LockToggledEvent>(OnLockToggled);
         SubscribeLocalEvent<GenpopLockerComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
         SubscribeLocalEvent<GenpopIdCardComponent, ExaminedEvent>(OnExamine);
+
+        Subs.CVar(_cfgManager, CCVars.MaxIdJobLength, value => _maxIdJobLength = value, true);
     }
 
     private void OnIdConfigured(Entity<GenpopLockerComponent> ent, ref GenpopLockerIdConfiguredMessage args)
     {
         // validation.
-        if (string.IsNullOrWhiteSpace(args.Name) || args.Name.Length > IdCardConsoleComponent.MaxFullNameLength ||
+        if (string.IsNullOrWhiteSpace(args.Name) || args.Name.Length > _maxIdJobLength ||
             args.Sentence < 0 ||
             string.IsNullOrWhiteSpace(args.Crime) || args.Crime.Length > GenpopLockerComponent.MaxCrimeLength)
         {