fix: Fixes null components in BaseAddon (#2208)
This commit is contained in:
parent
78e2e24fcd
commit
0d2ed60fed
2 changed files with 10 additions and 2 deletions
|
|
@ -104,7 +104,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializableField(0)]
|
[SerializableField(0)]
|
||||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
[SerializedCommandProperty(AccessLevel.GameMaster, readOnly: true)]
|
||||||
public BaseAddon _addon;
|
public BaseAddon _addon;
|
||||||
|
|
||||||
[SerializableField(1)]
|
[SerializableField(1)]
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,8 @@ namespace Server.Items
|
||||||
|
|
||||||
foreach (var c in Components)
|
foreach (var c in Components)
|
||||||
{
|
{
|
||||||
c.Delete();
|
// Component can become null if the Addon property is somehow deleted, then the component itself is deleted.
|
||||||
|
c?.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,5 +284,12 @@ namespace Server.Items
|
||||||
_resource = (CraftResource)reader.ReadEncodedInt();
|
_resource = (CraftResource)reader.ReadEncodedInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AfterDeserialization]
|
||||||
|
private void AfterDeserialization()
|
||||||
|
{
|
||||||
|
// We have had issues in the past, so let's tidy it up.
|
||||||
|
_components?.Tidy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue