fix: Don't crash the world if a stealable artifact fails to construct (#789)
This commit is contained in:
parent
fd440f29ce
commit
b6641c4853
1 changed files with 20 additions and 9 deletions
|
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Logging;
|
||||
using Server.Utilities;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class StealableArtifactsSpawner : Item
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(StealableArtifactsSpawner));
|
||||
|
||||
private static Type[] m_TypesOfEntries;
|
||||
private StealableInstance[] m_Artifacts;
|
||||
|
||||
|
|
@ -342,17 +345,25 @@ namespace Server.Items
|
|||
|
||||
public Item CreateInstance()
|
||||
{
|
||||
var item = Type.CreateInstance<Item>();
|
||||
|
||||
if (Hue > 0)
|
||||
try
|
||||
{
|
||||
item.Hue = Hue;
|
||||
var item = Type.CreateInstance<Item>();
|
||||
|
||||
if (Hue > 0)
|
||||
{
|
||||
item.Hue = Hue;
|
||||
}
|
||||
|
||||
item.Movable = false;
|
||||
item.MoveToWorld(Location, Map);
|
||||
|
||||
return item;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Warning(e, $"Failed to construct stealable artifact: {Type.FullName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
item.Movable = false;
|
||||
item.MoveToWorld(Location, Map);
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue