Skip to content

Commit

Permalink
fix: Fixes some buff icons off by 1s (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Jan 18, 2025
1 parent b90f9e5 commit c98b8fd
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions Projects/UOContent/Mobiles/PlayerMobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4478,20 +4478,39 @@ public void AcquireRecipe(int recipeID)

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
);
}

Expand All @@ -4516,29 +4535,9 @@ public void AddBuff(BuffInfo b)
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)
Expand Down

0 comments on commit c98b8fd

Please sign in to comment.