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:
parent
d7d914df6c
commit
59dcd24bed
3 changed files with 61 additions and 26 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue