fix: Fixes the wrong unit used for BuffIcon Timers (#2093)
This commit is contained in:
parent
ea364237f0
commit
f241a9dec0
2 changed files with 22 additions and 11 deletions
|
|
@ -6,7 +6,13 @@ namespace Server.Engines.BuffIcons;
|
||||||
public static class BuffIconPackets
|
public static class BuffIconPackets
|
||||||
{
|
{
|
||||||
public static void SendAddBuffPacket(
|
public static void SendAddBuffPacket(
|
||||||
this NetState ns, Serial mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, long ticks
|
this NetState ns,
|
||||||
|
Serial mob,
|
||||||
|
BuffIcon iconID,
|
||||||
|
int titleCliloc,
|
||||||
|
int secondaryCliloc,
|
||||||
|
TextDefinition args,
|
||||||
|
long seconds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (ns.CannotSendPackets())
|
if (ns.CannotSendPackets())
|
||||||
|
|
@ -28,8 +34,7 @@ public static class BuffIconPackets
|
||||||
writer.Write((short)0x1); // command (0 = remove, 1 = add, 2 = data)
|
writer.Write((short)0x1); // command (0 = remove, 1 = add, 2 = data)
|
||||||
writer.Write(0);
|
writer.Write(0);
|
||||||
|
|
||||||
// Truncate to whole seconds - The packet should be delayed by the partial seconds and then sent "on the second"
|
writer.Write((short)seconds);
|
||||||
writer.Write((short)(ticks / 1000));
|
|
||||||
writer.Clear(3);
|
writer.Clear(3);
|
||||||
writer.Write(titleCliloc);
|
writer.Write(titleCliloc);
|
||||||
writer.Write(secondaryCliloc);
|
writer.Write(secondaryCliloc);
|
||||||
|
|
|
||||||
|
|
@ -4478,28 +4478,34 @@ namespace Server.Mobiles
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration = Utility.Max(buffInfo.Duration - (Core.Now - buffInfo.StartTime), TimeSpan.Zero).TotalSeconds;
|
var duration = Utility.Max(buffInfo.Duration - (Core.Now - buffInfo.StartTime), TimeSpan.Zero);
|
||||||
var rounded = Math.Round(duration);
|
if (duration == TimeSpan.Zero)
|
||||||
var offset = duration - rounded;
|
{
|
||||||
|
SendAddBuffPacket(buffInfo, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var roundedSeconds = Math.Round(duration.TotalSeconds);
|
||||||
|
var offset = duration.TotalMilliseconds - roundedSeconds * TimeSpan.MillisecondsPerSecond;
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(offset), () =>
|
Timer.DelayCall(TimeSpan.FromMilliseconds(offset), () =>
|
||||||
{
|
{
|
||||||
// They are still online, we still have the buff icon in the table, and it is the same buff icon
|
// 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)
|
if (NetState != null && m_BuffTable?.GetValueOrDefault(buffInfo.ID) == buffInfo)
|
||||||
{
|
{
|
||||||
SendAddBuffPacket(buffInfo, (long)rounded);
|
SendAddBuffPacket(buffInfo, (long)roundedSeconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else // Round up, will be removed a little bit early by the server
|
else // Round up, will be removed a little bit early by the server
|
||||||
{
|
{
|
||||||
SendAddBuffPacket(buffInfo, (long)rounded);
|
SendAddBuffPacket(buffInfo, (long)roundedSeconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendAddBuffPacket(BuffInfo buffInfo, long ticks)
|
private void SendAddBuffPacket(BuffInfo buffInfo, long seconds)
|
||||||
{
|
{
|
||||||
NetState.SendAddBuffPacket(
|
NetState.SendAddBuffPacket(
|
||||||
Serial,
|
Serial,
|
||||||
|
|
@ -4507,7 +4513,7 @@ namespace Server.Mobiles
|
||||||
buffInfo.TitleCliloc,
|
buffInfo.TitleCliloc,
|
||||||
buffInfo.SecondaryCliloc,
|
buffInfo.SecondaryCliloc,
|
||||||
buffInfo.Args,
|
buffInfo.Args,
|
||||||
ticks
|
seconds
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue