From 319e45e27b5c1d8772884f525b1f0e56d26b6f9b Mon Sep 17 00:00:00 2001 From: Foxim Date: Thu, 15 May 2025 16:43:25 +0200 Subject: [PATCH] fix: crash when picking up ammo --- .../Components/ShootingComponent.cpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp index 4463987..cb483b1 100644 --- a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp +++ b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp @@ -95,19 +95,16 @@ void UShootingComponent::Reload() bool UShootingComponent::AddAmmo(EAmmoType CheckingAmmo, int AddValue) { - if (IsValid(CurrentGunBase)) - { // Adding ammo only if type is compatible - if (CurrentGunBase->AmmoType == CheckingAmmo) - { - CurrentGunBase->AddAmmo(AddValue); - return true; - } - if (SecondaryGunBase->AmmoType == CheckingAmmo) - { - SecondaryGunBase->AddAmmo(AddValue); - return true; - } + if (CurrentGunBase && CurrentGunBase->AmmoType == CheckingAmmo) + { + CurrentGunBase->AddAmmo(AddValue); + return true; + } + if (SecondaryGunBase && SecondaryGunBase->AmmoType == CheckingAmmo) + { + SecondaryGunBase->AddAmmo(AddValue); + return true; } return false;