From a2e6ab2d0702afcf177bf7a791640fddf6f47752 Mon Sep 17 00:00:00 2001 From: 0x6273 <0x40@keemail.me> Date: Fri, 28 Oct 2022 19:43:59 +0200 Subject: [PATCH] Cap ChemMaster label length (#12260) * Cap ChemMaster label length * Reroll for green checkmark --- Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs | 3 +++ .../Chemistry/EntitySystems/ChemMasterSystem.cs | 8 ++++++++ Content.Shared/Chemistry/SharedChemMaster.cs | 1 + 3 files changed, 12 insertions(+) diff --git a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs index 3693faf7a7..f0dc1a2579 100644 --- a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs +++ b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs @@ -79,6 +79,9 @@ namespace Content.Client.Chemistry.UI PillNumber.InitDefaultButtons(); BottleDosage.InitDefaultButtons(); + // Ensure label length is within the character limit. + LabelLineEdit.IsValid = s => s.Length <= SharedChemMaster.LabelMaxLength; + Tabs.SetTabTitle(0, Loc.GetString("chem-master-window-input-tab")); Tabs.SetTabTitle(1, Loc.GetString("chem-master-window-output-tab")); } diff --git a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs index d37da47006..6dde5798a0 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs @@ -186,6 +186,10 @@ namespace Content.Server.Chemistry.EntitySystems if (message.Dosage == 0 || message.Dosage > chemMaster.PillDosageLimit) return; + // Ensure label length is within the character limit. + if (message.Label.Length > SharedChemMaster.LabelMaxLength) + return; + var needed = message.Dosage * message.Number; if (!WithdrawFromBuffer(chemMaster, needed, user, out var withdrawal)) return; @@ -227,6 +231,10 @@ namespace Content.Server.Chemistry.EntitySystems if (message.Dosage == 0 || message.Dosage > solution.AvailableVolume) return; + // Ensure label length is within the character limit. + if (message.Label.Length > SharedChemMaster.LabelMaxLength) + return; + if (!WithdrawFromBuffer(chemMaster, message.Dosage, user, out var withdrawal)) return; diff --git a/Content.Shared/Chemistry/SharedChemMaster.cs b/Content.Shared/Chemistry/SharedChemMaster.cs index 7b4fd6ba73..a97ad05f76 100644 --- a/Content.Shared/Chemistry/SharedChemMaster.cs +++ b/Content.Shared/Chemistry/SharedChemMaster.cs @@ -15,6 +15,7 @@ namespace Content.Shared.Chemistry public const string OutputSlotName = "outputSlot"; public const string PillSolutionName = "food"; public const string BottleSolutionName = "drink"; + public const uint LabelMaxLength = 50; } [Serializable, NetSerializable]