0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 01:30:45 -05:00

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: SPT/Modules#154
Co-authored-by: dwesterwick <dwesterwick@yahoo.com>
Co-committed-by: dwesterwick <dwesterwick@yahoo.com>
This commit is contained in:
dwesterwick 2024-08-10 08:09:26 +00:00 committed by chomp
parent 2faf204d77
commit 9357555280

View File

@ -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)
{