fix: Fixes DeltaQueue recursion, StatMod bug, and memory leak (#1233)

* Fixes recursion with DeltaQueue causing multiple sets of packets to be sent to the client.
* Fixes StatMods that are expired not being checked properly.
* Adds a timer to properly expire/remove stat mods instead of relying on a side-effect.
This commit is contained in:
Kamron Batman 2022-11-08 09:08:05 -08:00 • committed by GitHub
parent d7d914df6c
commit 59dcd24bed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 26 deletions

View file

@ -301,20 +301,19 @@ namespace Server.Spells
public static bool AddStatBonus(Mobile caster, Mobile target, StatType type, int bonus, TimeSpan duration)
{
var offset = bonus;
var name = $"[Magic] {type} Buff";
var mod = target.GetStatMod(name);
if (mod?.Offset < 0)
{
target.AddStatMod(new StatMod(type, name, mod.Offset + offset, duration));
target.AddStatMod(new StatMod(type, name, mod.Offset + bonus, duration));
return true;
}
if (mod == null || mod.Offset <= offset)
if (mod == null || mod.Offset <= bonus)
{
target.AddStatMod(new StatMod(type, name, offset, duration));
target.AddStatMod(new StatMod(type, name, bonus, duration));
return true;
}