Skip to content

Commit

Permalink
fix: Fixes massive capacity bug with pooled ref queue/list (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Jul 7, 2024
1 parent 96de1fd commit 21836cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
5 changes: 2 additions & 3 deletions Projects/Server/Collections/PooledRefList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Server.Buffers;

namespace Server.Collections;
Expand Down Expand Up @@ -152,14 +151,14 @@ public int Capacity

if (_items.Length > 0)
{
Clear();
Array.Clear(_items);
ArrayPool.Return(_items);
}
_items = newItems;
}
else
{
Clear();
Array.Clear(_items);
ArrayPool.Return(_items);
_items = s_emptyArray;
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/Server/Collections/PooledRefQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void SetCapacity(int capacity)

if (_array.Length > 0)
{
Clear();
Array.Clear(_array);
(_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Return(_array);
}

Expand Down
23 changes: 0 additions & 23 deletions Projects/UOContent/Accounting/AccountHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@
using System.Collections.Generic;
using System.Net;
using Server.Accounting;
using Server.Engines.CannedEvil;
using Server.Engines.Help;
using Server.Engines.PlayerMurderSystem;
using Server.Engines.Virtues;
using Server.Logging;
using Server.Network;
using Server.Regions;
using Server.Spells.Fifth;
using Server.Spells.First;
using Server.Spells.Mysticism;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Second;

namespace Server.Misc;

Expand Down Expand Up @@ -236,20 +227,6 @@ public static void DeleteRequest(NetState state, int index)

m.Delete();

StaminaSystem.OnPlayerDeleted(m);
JusticeVirtue.OnPlayerDeleted(m);
PlayerMurderSystem.OnPlayerDeleted(m);
ChampionTitleSystem.OnPlayerDeleted(m);

// Spells
MagicReflectSpell.EndReflect(m);
ReactiveArmorSpell.EndArmor(m);
ProtectionSpell.EndProtection(m);
StoneFormSpell.RemoveEffects(m);
AnimateDeadSpell.RemoveEffects(m);
SummonFamiliarSpell.RemoveEffects(m);
AnimalForm.RemoveLastAnimalForm(m);

state.SendCharacterListUpdate(acct);
return;
}
Expand Down
20 changes: 17 additions & 3 deletions Projects/UOContent/Mobiles/PlayerMobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
using Server.Spells;
using Server.Spells.Bushido;
using Server.Spells.Fifth;
using Server.Spells.First;
using Server.Spells.Fourth;
using Server.Spells.Mysticism;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Second;
using Server.Spells.Seventh;
using Server.Spells.Sixth;
using Server.Spells.Spellweaving;
Expand Down Expand Up @@ -3382,14 +3385,25 @@ public override void OnAfterDelete()
base.OnAfterDelete();

var faction = Faction.Find(this);

faction?.RemoveMember(this);

MLQuestSystem.HandleDeletion(this);

BaseHouse.HandleDeletion(this);

DisguisePersistence.RemoveTimer(this);

StaminaSystem.OnPlayerDeleted(this);
JusticeVirtue.OnPlayerDeleted(this);
PlayerMurderSystem.OnPlayerDeleted(this);
ChampionTitleSystem.OnPlayerDeleted(this);

// Spells
MagicReflectSpell.EndReflect(this);
ReactiveArmorSpell.EndArmor(this);
ProtectionSpell.EndProtection(this);
StoneFormSpell.RemoveEffects(this);
AnimateDeadSpell.RemoveEffects(this);
SummonFamiliarSpell.RemoveEffects(this);
AnimalForm.RemoveLastAnimalForm(this);
}

public override void GetProperties(IPropertyList list)
Expand Down

0 comments on commit 21836cf

Please sign in to comment.