Skip to content

Commit

Permalink
Fix admin verb to set unspawned ballisic ammo count (#26411)
Browse files Browse the repository at this point in the history
Don't crash if an invalid value is given.
  • Loading branch information
IProduceWidgets authored Mar 25, 2024
1 parent 3197262 commit 451890b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,21 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private void OnBallisticAmmoCount(EntityUid uid, BallisticAmmoProviderComponent
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;
Expand Down

0 comments on commit 451890b

Please sign in to comment.