fix: Fixes some buff icons off by 1s (#2073)
This commit is contained in:
parent
b90f9e51ac
commit
c98b8fdeca
1 changed files with 24 additions and 25 deletions
|
|
@ -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<BuffIcon, BuffInfo>();
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue