From c98b8fdecaee149bb4f6d15c209c3a97bb07ea76 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 18 Jan 2025 10:40:01 -0800 Subject: [PATCH] fix: Fixes some buff icons off by 1s (#2073) --- Projects/UOContent/Mobiles/PlayerMobile.cs | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index 5e5f9352b..abf2d5c67 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -4478,20 +4478,39 @@ namespace Server.Mobiles public void SendAddBuffPacket(BuffInfo buffInfo) { - if (buffInfo == null) + if (buffInfo == null || NetState?.BuffIcon != true) { return; } + // Synchronize the buff icon as close to _on the second_ as we can. + var msecs = buffInfo.TimeLength.Milliseconds; + if (msecs >= 8) + { + Timer.DelayCall(TimeSpan.FromMilliseconds(msecs), () => + { + // They are still online, we still have the buff icon in the table, and it is the same buff icon + if (NetState != null && m_BuffTable?.GetValueOrDefault(buffInfo.ID) == buffInfo) + { + SendAddBuffPacket(buffInfo, (long)buffInfo.TimeLength.TotalMilliseconds - msecs); + } + }); + } + else + { + SendAddBuffPacket(buffInfo, (long)buffInfo.TimeLength.TotalMilliseconds); + } + } + + private void SendAddBuffPacket(BuffInfo buffInfo, long ticks) + { NetState.SendAddBuffPacket( Serial, buffInfo.ID, buffInfo.TitleCliloc, buffInfo.SecondaryCliloc, buffInfo.Args, - buffInfo.TimeStart == 0 - ? 0 - : Math.Max(buffInfo.TimeStart + (long)buffInfo.TimeLength.TotalMilliseconds - Core.TickCount, 0) + ticks ); } @@ -4516,29 +4535,9 @@ namespace Server.Mobiles RemoveBuff(b); // Check & subsequently remove the old one. m_BuffTable ??= new Dictionary(); - m_BuffTable.Add(b.ID, b); - if (NetState?.BuffIcon == true) - { - // Synchronize the buff icon as close to _on the second_ as we can. - var msecs = b.TimeLength.Milliseconds; - if (msecs >= 8) - { - Timer.DelayCall(TimeSpan.FromMilliseconds(msecs), (buffInfo, pm) => - { - // They are still online, we still have the buff icon in the table, and it is the same buff icon - if (pm.NetState != null && pm.m_BuffTable?.GetValueOrDefault(buffInfo.ID) == buffInfo) - { - pm.SendAddBuffPacket(buffInfo); - } - }, b, this); - } - else - { - SendAddBuffPacket(b); - } - } + SendAddBuffPacket(b); } public void RemoveBuff(BuffInfo b)