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:
parent
69ff5f3940
commit
0f89870793
2 changed files with 2 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue