From fc0ff8fb313d8dfddf803c19a19bf2629ce89e90 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 28 Feb 2024 03:40:19 +1100 Subject: [PATCH] Fix gun cycling ammo count update (#25635) Doesn't update correctly when cycling. --- .../Systems/SharedGunSystem.ChamberMagazine.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs index dc5dc5b90c..c421c92a9f 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs @@ -112,7 +112,10 @@ public abstract partial class SharedGunSystem } } - CycleCartridge(uid, component, user); + if (!CycleCartridge(uid, component, user)) + { + UpdateAmmoCount(uid); + } if (component.BoltClosed != false) { @@ -202,11 +205,12 @@ public abstract partial class SharedGunSystem /// /// Tries to take ammo from the magazine and insert into the chamber. /// - private void CycleCartridge(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null, AppearanceComponent? appearance = null) + private bool CycleCartridge(EntityUid uid, ChamberMagazineAmmoProviderComponent component, EntityUid? user = null, AppearanceComponent? appearance = null) { // Try to put a new round in if possible. var magEnt = GetMagazineEntity(uid); var chambered = GetChamberEntity(uid); + var result = false; // Similar to what takeammo does though that uses an optimised version where // multiple bullets may be fired in a single tick. @@ -243,7 +247,11 @@ public abstract partial class SharedGunSystem { UpdateAmmoCount(uid); } + + result = true; } + + return result; } /// -- 2.52.0