AndroidQuazar / VanillaExpandedFramework

Vanilla Expanded Framework for RimWorld
Other
36 stars 18 forks source link

Fix NRE when Pawn_EquipmentTracker::TryDropEquipment is skipped #29

Closed nikolads closed 2 years ago

nikolads commented 2 years ago

When a harpy from [SYR] Harpies is downed, trying to rescue it causes a null reference exception (which prevents it from being rescued).

The issue is that the Harpies mod patches Pawn_EquipmentTracker::TryDropEquipment. If the equipment is its lightning weapon the original method is skipped. https://github.com/Syrchalis/Harpy/blob/5b2942830b3b81054f2bf4a118e2cd3a33445728/Source/HarmonyPatches.cs#L386-L399

When the original method is skipped the output variable out ThingWithComps resultingEq is left uninitialized. Then the postfix patch in VFECore TryDropEquipment_Patch is called with resultingEq = null.

legodude17 commented 2 years ago

Question: does the range extension work on the lightning weapon?

nikolads commented 2 years ago

Sorry, but I don't know. I don't know anything about the inner workings of either mod. I just saw the exception in the log and managed to track it to this function. And I thought it is better to fix it on the VFE side.

The lightning weapon is a natural/builtin ranged weapon of harpies. Normally they cannot wield other weapons, so it is not supposed to be dropped ever.

Taranchuk commented 2 years ago

The check is added now