Skip to content

Commit

Permalink
Add safety checks in canAssemble() and canDisassemble()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
UndeadZeratul committed Jun 24, 2023
1 parent bed15e2 commit c8db06b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zscript/universalreloader/items/universalReloader.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);

Expand Down

0 comments on commit c8db06b

Please sign in to comment.