fix: ranged weapon crafting falls back to the recipe resource (#2719)

`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.
This commit is contained in:
Kamron Batman 2026-10-18 18:10:03 -07:00 • committed by GitHub
parent 69ff5f3940
commit 0f89870793
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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;

View file

@ -736,7 +736,7 @@ namespace Server.Items
/// </summary>
public static CraftResource GetFromType(Type resourceType)
{
if (m_TypeTable == null)
if (resourceType == null || m_TypeTable == null)
{
return CraftResource.None;
}