From 0f89870793ee38969a2b3b7406f83a7046ef4740 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:10:03 -0700 Subject: [PATCH] fix: ranged weapon crafting falls back to the recipe resource (#2719) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `BaseRanged.OnCraft` passed the raw resource type to `ApplyWoodBonuses`, which can be null; `CraftResources.GetFromType` threw on the null key and crashed the server. Every other `OnCraft` override already falls back to `craftItem.Resources[0].ItemType` — `BaseRanged` now does the same. `GetFromType` also returns `CraftResource.None` for a null type, matching its documented contract for unregistered types, so other callers can't hit the same throw. --- Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs | 2 +- Projects/UOContent/Misc/ResourceInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs index 4fd786809..a47a43543 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs @@ -206,7 +206,7 @@ namespace Server.Items var result = base.OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, craftItem, resHue); if (Core.ML) { - ApplyWoodBonuses(typeRes); + ApplyWoodBonuses(typeRes ?? craftItem.Resources[0].ItemType); } return result; diff --git a/Projects/UOContent/Misc/ResourceInfo.cs b/Projects/UOContent/Misc/ResourceInfo.cs index 521216d58..dae8b4836 100644 --- a/Projects/UOContent/Misc/ResourceInfo.cs +++ b/Projects/UOContent/Misc/ResourceInfo.cs @@ -736,7 +736,7 @@ namespace Server.Items /// public static CraftResource GetFromType(Type resourceType) { - if (m_TypeTable == null) + if (resourceType == null || m_TypeTable == null) { return CraftResource.None; }