From c8db06bec281abeee37e5f82142b29b91179a787 Mon Sep 17 00:00:00 2001 From: UndeadZeratul Date: Sat, 24 Jun 2023 12:23:52 -0500 Subject: [PATCH] Add safety checks in canAssemble() and canDisassemble() Hopefully this fixes the null pointer issue, since it's technically possible the recipe being passed in is null, which should just return false if that happens. Also added a safety check for the owner of the item being present for assembly mode, since it's doing that in disassembly and because the URL should really only assemble if someone dropped it to begin with. --- zscript/universalreloader/items/universalReloader.zsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zscript/universalreloader/items/universalReloader.zsc b/zscript/universalreloader/items/universalReloader.zsc index 7f14879..f9ee1c0 100644 --- a/zscript/universalreloader/items/universalReloader.zsc +++ b/zscript/universalreloader/items/universalReloader.zsc @@ -128,7 +128,7 @@ class HDUniversalReloader : HDWeapon protected clearscope bool canAssemble(HDRel_Recipe recipe) { - let canCraft = recipe.CanBeAssembled(); + let canCraft = owner && recipe && recipe.CanBeAssembled(); if (canCraft) { @@ -145,7 +145,7 @@ class HDUniversalReloader : HDWeapon protected clearscope bool canDisassemble(HDRel_Recipe recipe) { - let canCraft = owner && owner.countInv(recipe.AmmoClass) > 0; + let canCraft = owner && recipe && owner.countInv(recipe.AmmoClass) > 0; if (hd_debug) console.printf("Can disassemble "..recipe.AmmoClass.GetClassName().."? "..canCraft);