fix: Fixes issue with duping items and serialization, and sector lists. (#1662)

This commit is contained in:
Kamron Batman 2024-01-23 23:08:52 -08:00 • committed by GitHub
parent 497ea87943
commit 3812a783ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 53 deletions

View file

@ -32,13 +32,9 @@ public abstract partial class BaseMulti : Item
{
if (base.ItemID != value)
{
var facet = Parent == null ? Map : null;
facet?.OnLeave(this);
Map?.OnLeave(this);
base.ItemID = value;
facet?.OnEnter(this);
Map?.OnEnter(this);
}
}
}
@ -69,21 +65,6 @@ public abstract partial class BaseMulti : Item
public virtual MultiComponentList Components => MultiData.GetComponents(ItemID);
[Obsolete("Replace with calls to OnLeave and OnEnter surrounding component invalidation.", true)]
public virtual void RefreshComponents()
{
if (Parent == null)
{
var facet = Map;
if (facet != null)
{
facet.OnLeave(this);
facet.OnEnter(this);
}
}
}
public override int GetMaxUpdateRange() => 22;
public override int GetUpdateRange(Mobile m) => 22;

View file

@ -599,18 +599,16 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
var oldParent = m_Parent;
if (m_Map != null && oldParent == null && value != null)
{
m_Map.OnLeave(this);
}
m_Parent = value;
if (m_Map != null)
if (m_Map != null && oldParent != null && value == null)
{
if (oldParent != null && m_Parent == null)
{
m_Map.OnEnter(this);
}
else if (m_Parent != null)
{
m_Map.OnLeave(this);
}
m_Map.OnEnter(this);
}
}
}
@ -1207,9 +1205,13 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
{
var old = m_Map;
if (m_Map != null && m_Parent == null)
if (m_Map != null)
{
m_Map.OnLeave(this);
if (m_Parent == null)
{
m_Map.OnLeave(this);
}
SendRemovePacket();
}
@ -3328,13 +3330,14 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
}
}
private static readonly HashSet<string> _excludedProperties = new()
{
private static readonly HashSet<string> _excludedProperties =
[
"SaveBuffer",
"Parent",
"Next",
"Previous",
"OnLinkList"
};
];
public virtual bool DupeExcludedProperty(string propertyName) => _excludedProperties.Contains(propertyName);