Cap ChemMaster label length (#12260)

* Cap ChemMaster label length

* Reroll for green checkmark
This commit is contained in:
0x6273
2022-10-28 19:43:59 +02:00
committed by GitHub
parent 3078e359c0
commit a2e6ab2d07
3 changed files with 12 additions and 0 deletions

View File

@@ -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"));
}

View File

@@ -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;

View File

@@ -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]