fix: Bufficon timer is not cancelled when refreshed with another one. (#2080)

This commit is contained in:
mark1145 2025-01-21 04:18:52 +11:00 committed by GitHub
parent b4b7182ce6
commit f5e944335b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 21 deletions

View file

@ -127,8 +127,13 @@ namespace Server
public static void RemoveBuff(Mobile m, BuffInfo b)
{
if (b == null)
{
return;
}
b._timerToken.Cancel();
(m as PlayerMobile)?.RemoveBuff(b);
(m as PlayerMobile)?.RemoveBuff(b.ID);
}
public static void RemoveBuff(Mobile m, BuffIcon b)

View file

@ -1591,10 +1591,8 @@ namespace Server.Mobiles
{
base.OnHiddenChanged();
RemoveBuff(
BuffIcon
.Invisibility
); // Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set
// Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set
RemoveBuff(BuffIcon.Invisibility);
if (!Hidden)
{
@ -1602,10 +1600,8 @@ namespace Server.Mobiles
}
else // if (!InvisibilitySpell.HasTimer( this ))
{
BuffInfo.AddBuff(
this,
new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655)
); // Hidden/Stealthing & You Are Hidden
// Hidden/Stealthing & You Are Hidden
BuffInfo.AddBuff(this, new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655));
}
}
@ -2654,7 +2650,7 @@ namespace Server.Mobiles
while (queue.Count > 0)
{
RemoveBuff(queue.Dequeue());
BuffInfo.RemoveBuff(this, queue.Dequeue());
}
}
@ -4532,7 +4528,7 @@ namespace Server.Mobiles
return;
}
RemoveBuff(b); // Check & subsequently remove the old one.
BuffInfo.RemoveBuff(this, b); // Check, stop old timer, & subsequently remove the old one.
m_BuffTable ??= new Dictionary<BuffIcon, BuffInfo>();
m_BuffTable.Add(b.ID, b);
@ -4540,16 +4536,6 @@ namespace Server.Mobiles
SendAddBuffPacket(b);
}
public void RemoveBuff(BuffInfo b)
{
if (b == null)
{
return;
}
RemoveBuff(b.ID);
}
public void RemoveBuff(BuffIcon b)
{
if (m_BuffTable?.Remove(b) != true)