From 9357555280d8d342994e6e0b93a0413649a88a9c Mon Sep 17 00:00:00 2001 From: dwesterwick Date: Sat, 10 Aug 2024 08:09:26 +0000 Subject: [PATCH] Fix for DogtagPatch NRE when Weapon Name is Null (!154) Added null check for `damageInfo.Weapon.Name` in `DogtagPatch::UpdateDogtagItemWithDeathDetails` because it can be null in rare cases. I see this happen when Zryachiy or his followers kill a bot, and I'm not sure why. This will prevent an exception from being thrown and the bot becoming "broken". Reviewed-on: https://dev.sp-tarkov.com/SPT/Modules/pulls/154 Co-authored-by: dwesterwick Co-committed-by: dwesterwick --- project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs b/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs index fb5a315..39b3959 100644 --- a/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs +++ b/project/SPT.SinglePlayer/Patches/Quests/DogtagPatch.cs @@ -94,7 +94,15 @@ namespace SPT.SinglePlayer.Patches.Quests itemComponent.Status = "Killed by "; itemComponent.KillerAccountId = aggressor.Profile.AccountId; itemComponent.KillerProfileId = aggressor.Profile.Id; - itemComponent.WeaponName = damageInfo.Weapon.Name; + + string weaponName = damageInfo.Weapon?.Name; + if (weaponName == null) + { + Logger.LogWarning($"DogtagPatch error > The weapon used by {itemComponent.KillerName} to kill {itemComponent.Nickname} is null"); + weaponName = "???"; + } + + itemComponent.WeaponName = weaponName; if (__instance.Profile.Info.Experience > 0) {