fix: Fixes buffs don't start/stop properly. Streamlines constructor and Add/Remove buffs. (#2082)

This commit is contained in:
mark1145 2025-01-25 13:20:23 +11:00 committed by GitHub
parent c8f13b2933
commit d5160bd6db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 651 additions and 616 deletions

View file

@ -1,5 +1,6 @@
using System;
using Server;
using Server.Engines.BuffIcons;
using Server.Network;
using Server.Tests;
using Server.Tests.Network;
@ -14,29 +15,29 @@ public class BuffIconPacketTests
[InlineData(0x2048u, BuffIcon.Disguised, 500102, 300203, null, 9000)]
public void TestAddBuffIcon(uint mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, string args, int ts)
{
var timeSpan = new TimeSpan(ts);
var expected = new AddBuffPacket(
(Serial)mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan
).Compile();
var timeSpan = new TimeSpan(ts);
var expected = new AddBuffPacket(
(Serial)mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan
).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendAddBuffPacket((Serial)mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendAddBuffPacket((Serial)mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);
}
}
[Fact]
public void TestRemoveBuffIcon()
{
Serial m = (Serial)0x1024;
var buffIcon = BuffIcon.Disguised;
var expected = new RemoveBuffPacket(m, buffIcon).Compile();
Serial m = (Serial)0x1024;
var buffIcon = BuffIcon.Disguised;
var expected = new RemoveBuffPacket(m, buffIcon).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendRemoveBuffPacket(m, buffIcon);
var ns = PacketTestUtilities.CreateTestNetState();
ns.SendRemoveBuffPacket(m, buffIcon);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);
}
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using Server.Engines.BuffIcons;
namespace Server.Network
{
@ -11,9 +12,7 @@ namespace Server.Network
info.TitleCliloc,
info.SecondaryCliloc,
info.Args,
info.TimeStart != 0 ?
TimeSpan.FromMilliseconds(info.TimeStart + (long)info.TimeLength.TotalMilliseconds - Core.TickCount) :
TimeSpan.Zero
info.Duration
)
{
}