From f5e944335bd688bb8cf1bac36da75c11a1def356 Mon Sep 17 00:00:00 2001 From: mark1145 Date: Tue, 21 Jan 2025 04:18:52 +1100 Subject: [PATCH] fix: Bufficon timer is not cancelled when refreshed with another one. (#2080) --- Projects/UOContent/Misc/BuffIcons.cs | 7 +++++- Projects/UOContent/Mobiles/PlayerMobile.cs | 26 +++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Projects/UOContent/Misc/BuffIcons.cs b/Projects/UOContent/Misc/BuffIcons.cs index 46ab80109..f393747b5 100644 --- a/Projects/UOContent/Misc/BuffIcons.cs +++ b/Projects/UOContent/Misc/BuffIcons.cs @@ -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) diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index abf2d5c67..c29772d42 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -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(); 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)