Fixes crash with AreaTriggers

This commit is contained in:
Hondacrx
2025-08-27 22:06:57 -04:00
parent bf3ae44c36
commit 869af17b23
3 changed files with 6 additions and 7 deletions
@@ -1555,7 +1555,7 @@ namespace Game.Entities
public override ObjectGuid GetOwnerGUID() { return GetCasterGuid(); } public override ObjectGuid GetOwnerGUID() { return GetCasterGuid(); }
public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; } public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; }
public bool HasSplines() { return !_spline.Empty(); } public bool HasSplines() { return _spline != null && !_spline.Empty(); }
public Spline<float> GetSpline() { return _spline; } public Spline<float> GetSpline() { return _spline; }
bool HasOrbit() { return m_areaTriggerData.PathData.Is<AreaTriggerOrbit>(); } bool HasOrbit() { return m_areaTriggerData.PathData.Is<AreaTriggerOrbit>(); }
@@ -353,15 +353,14 @@ namespace Game.Entities
} }
} }
public class VariantUpdateField(int blockBit, int bit, params Type[] types) public class VariantUpdateField(int blockBit, int bit)
{ {
public object _value; public object _value;
Type[] _types = types;
public int BlockBit = blockBit; public int BlockBit = blockBit;
public int Bit = bit; public int Bit = bit;
public bool Is<T>() { return _types.Contains(typeof(T)); } public bool Is<T>() { return _value is T; }
public T Get<T>() where T : class, new() public T Get<T>() where T : class, new()
{ {
@@ -466,7 +465,7 @@ namespace Game.Entities
public void ClearChangesMask(VariantUpdateField field) public void ClearChangesMask(VariantUpdateField field)
{ {
if (typeof(IHasChangesMask).IsAssignableFrom(field._value.GetType())) if (field._value != null && typeof(IHasChangesMask).IsAssignableFrom(field._value.GetType()))
((IHasChangesMask)field._value).ClearChangesMask(); ((IHasChangesMask)field._value).ClearChangesMask();
} }
+2 -2
View File
@@ -856,7 +856,7 @@ namespace Game.Entities
public void RemoveAreaTrigger(AuraEffect aurEff) public void RemoveAreaTrigger(AuraEffect aurEff)
{ {
foreach (AreaTrigger areaTrigger in m_areaTrigger) foreach (AreaTrigger areaTrigger in m_areaTrigger.ToList())
{ {
if (areaTrigger.GetAuraEffect() == aurEff) if (areaTrigger.GetAuraEffect() == aurEff)
{ {
@@ -868,7 +868,7 @@ namespace Game.Entities
public void RemoveAllAreaTriggers(AreaTriggerRemoveReason reason = AreaTriggerRemoveReason.Default) public void RemoveAllAreaTriggers(AreaTriggerRemoveReason reason = AreaTriggerRemoveReason.Default)
{ {
foreach (AreaTrigger at in m_areaTrigger) foreach (AreaTrigger at in m_areaTrigger.ToList())
{ {
if (reason == AreaTriggerRemoveReason.UnitDespawn && at.GetTemplate().ActionSetFlags.HasFlag(AreaTriggerActionSetFlag.DontDespawnWithCreator)) if (reason == AreaTriggerRemoveReason.UnitDespawn && at.GetTemplate().ActionSetFlags.HasFlag(AreaTriggerActionSetFlag.DontDespawnWithCreator))
continue; continue;