Fix admin verb to set unspawned ballisic ammo count (#26411)

Don't crash if an invalid value is given.

(cherry picked from commit 451890b85b)
This commit is contained in:
IProduceWidgets
2024-03-27 18:35:09 +01:00
committed by NullWanderer
parent e9030104c0
commit 242d6dd30e
2 changed files with 15 additions and 3 deletions
@@ -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,
@@ -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;