From 451890b85b49e17a0019d107db4a31a48cdd3518 Mon Sep 17 00:00:00 2001 From: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Date: Sun, 24 Mar 2024 20:45:01 -0400 Subject: [PATCH] Fix admin verb to set unspawned ballisic ammo count (#26411) Don't crash if an invalid value is given. --- .../Systems/AdminVerbSystem.Tools.cs | 16 ++++++++++++++-- .../Ranged/Systems/SharedGunSystem.Ballistic.cs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs index c68336deab..9d66338c8b 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs @@ -718,9 +718,21 @@ public sealed partial class AdminVerbSystem Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Fun/caps.rsi"), "mag-6"), Act = () => { - _quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (max {ballisticAmmo.Capacity}):", (int amount) => + _quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (standard {ballisticAmmo.Capacity}):", (string amount) => { - ballisticAmmo.UnspawnedCount = amount; + if (!int.TryParse(amount, out var result)) + return; + + if (result > 0) + { + ballisticAmmo.UnspawnedCount = result; + } + else + { + ballisticAmmo.UnspawnedCount = 0; + } + + _gun.UpdateBallisticAppearance(args.Target, ballisticAmmo); }); }, Impact = LogImpact.Medium, diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index 261243fea3..11cfc88470 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -260,7 +260,7 @@ public abstract partial class SharedGunSystem args.Capacity = component.Capacity; } - private void UpdateBallisticAppearance(EntityUid uid, BallisticAmmoProviderComponent component) + public void UpdateBallisticAppearance(EntityUid uid, BallisticAmmoProviderComponent component) { if (!Timing.IsFirstTimePredicted || !TryComp(uid, out var appearance)) return;