]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix admin verb to set unspawned ballisic ammo count (#26411)
authorIProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
Mon, 25 Mar 2024 00:45:01 +0000 (20:45 -0400)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2024 00:45:01 +0000 (17:45 -0700)
Don't crash if an invalid value is given.

Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs

index c68336deab88d1bc9557989fe441ef2dd6f8d36b..9d66338c8bf0bb1ac7b939cb86bb8a1ddb6ae061 100644 (file)
@@ -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,
index 261243fea3507984da9d91f9874ec8f3f4b1fdf7..11cfc88470a9199df13adf55d6b4f3435c824cf8 100644 (file)
@@ -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<AppearanceComponent>(uid, out var appearance))
             return;