fix: Fixes some buff icons off by 1s (#2073)

This commit is contained in:
Kamron Batman 2025-01-18 10:40:01 -08:00 • committed by GitHub
parent b90f9e51ac
commit c98b8fdeca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4478,20 +4478,39 @@ namespace Server.Mobiles
public void SendAddBuffPacket(BuffInfo buffInfo) public void SendAddBuffPacket(BuffInfo buffInfo)
{ {
if (buffInfo == null) if (buffInfo == null || NetState?.BuffIcon != true)
{ {
return; 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( NetState.SendAddBuffPacket(
Serial, Serial,
buffInfo.ID, buffInfo.ID,
buffInfo.TitleCliloc, buffInfo.TitleCliloc,
buffInfo.SecondaryCliloc, buffInfo.SecondaryCliloc,
buffInfo.Args, buffInfo.Args,
buffInfo.TimeStart == 0 ticks
? 0
: Math.Max(buffInfo.TimeStart + (long)buffInfo.TimeLength.TotalMilliseconds - Core.TickCount, 0)
); );
} }
@ -4516,29 +4535,9 @@ namespace Server.Mobiles
RemoveBuff(b); // Check & subsequently remove the old one. RemoveBuff(b); // Check & subsequently remove the old one.
m_BuffTable ??= new Dictionary<BuffIcon, BuffInfo>(); m_BuffTable ??= new Dictionary<BuffIcon, BuffInfo>();
m_BuffTable.Add(b.ID, b); m_BuffTable.Add(b.ID, b);
if (NetState?.BuffIcon == true) SendAddBuffPacket(b);
{
// 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);
}
}
} }
public void RemoveBuff(BuffInfo b) public void RemoveBuff(BuffInfo b)