chore: Use var everywhere (#2294)
This commit is contained in:
parent
0b34cc4417
commit
ebaf104935
267 changed files with 873 additions and 873 deletions
|
|
@ -188,7 +188,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadAsciiString()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hello"u8;
|
||||
var buffer = "Hello"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadAscii();
|
||||
|
|
@ -200,7 +200,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadAsciiStringWithNull()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hel\0o"u8;
|
||||
var buffer = "Hel\0o"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadAscii();
|
||||
|
|
@ -212,7 +212,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadAsciiStringFixedLength()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hello\0\0\0\0\0"u8;
|
||||
var buffer = "Hello\0\0\0\0\0"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadAscii(10);
|
||||
|
|
@ -227,7 +227,7 @@ public class SpanReaderTests
|
|||
Assert.Throws<EndOfStreamException>(
|
||||
() =>
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hel"u8;
|
||||
var buffer = "Hel"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
reader.ReadAscii(10);
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadUTF8String()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hello"u8;
|
||||
var buffer = "Hello"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadUTF8();
|
||||
|
|
@ -261,7 +261,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadUTF8StringWithNull()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "Hi\0Bye"u8;
|
||||
var buffer = "Hi\0Bye"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadUTF8();
|
||||
|
|
@ -273,7 +273,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadLittleUniString()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "H\0i\0"u8;
|
||||
var buffer = "H\0i\0"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadLittleUni();
|
||||
|
|
@ -285,7 +285,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadLittleUniStringWithNull()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "H\0i\0\0\0X\0"u8;
|
||||
var buffer = "H\0i\0\0\0X\0"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadLittleUni();
|
||||
|
|
@ -297,7 +297,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadLittleUniStringFixedLength()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "H\0i\0\0\0\0\0"u8;
|
||||
var buffer = "H\0i\0\0\0\0\0"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadLittleUni(4);
|
||||
|
|
@ -321,7 +321,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadBigUniString()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "\0H\0i"u8;
|
||||
var buffer = "\0H\0i"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadBigUni();
|
||||
|
|
@ -333,7 +333,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadBigUniStringWithNull()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "\0H\0i\0\0\0X"u8;
|
||||
var buffer = "\0H\0i\0\0\0X"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadBigUni();
|
||||
|
|
@ -345,7 +345,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadBigUniStringFixedLength()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "\0H\0i\0\0\0\0"u8;
|
||||
var buffer = "\0H\0i\0\0\0\0"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
var result = reader.ReadBigUni(4);
|
||||
|
|
@ -560,7 +560,7 @@ public class SpanReaderTests
|
|||
[Fact]
|
||||
public void TestReadMultipleStringsWithNullTerminators()
|
||||
{
|
||||
ReadOnlySpan<byte> buffer = "AB\0CD\0EF"u8;
|
||||
var buffer = "AB\0CD\0EF"u8;
|
||||
var reader = new SpanReader(buffer);
|
||||
|
||||
Assert.Equal("AB", reader.ReadAscii());
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class OrderedSetTests
|
|||
Assert.True(set.Contains(4));
|
||||
Assert.False(set.Contains(8));
|
||||
|
||||
int index = 0;
|
||||
var index = 0;
|
||||
foreach (var value in set)
|
||||
{
|
||||
Assert.Equal(expected[index++], value);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class Point2DTests
|
|||
[Fact]
|
||||
public void TestPoint2DTryFormatSucceeds()
|
||||
{
|
||||
char[] array = new char[128];
|
||||
var array = new char[128];
|
||||
|
||||
var p1 = new Point2D(0, 0);
|
||||
Assert.True(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
@ -44,7 +44,7 @@ public class Point2DTests
|
|||
[Fact]
|
||||
public void TestPoint2DTryFormatFails()
|
||||
{
|
||||
char[] array = new char[1];
|
||||
var array = new char[1];
|
||||
|
||||
var p1 = new Point2D(0, 0);
|
||||
Assert.False(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class Point3DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[128];
|
||||
var array = new char[128];
|
||||
|
||||
var p1 = new Point3D(0, 0, 0);
|
||||
Assert.True(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
@ -59,7 +59,7 @@ public class Point3DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[1];
|
||||
var array = new char[1];
|
||||
|
||||
var p1 = new Point3D(0, 0, 0);
|
||||
Assert.False(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class Rectangle2DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[128];
|
||||
var array = new char[128];
|
||||
|
||||
var p1 = new Rectangle2D(0, 0, 0, 0);
|
||||
Assert.True(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
@ -48,7 +48,7 @@ public class Rectangle2DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[1];
|
||||
var array = new char[1];
|
||||
|
||||
var p1 = new Rectangle2D(0, 0, 0, 0);
|
||||
Assert.False(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class Rectangle3DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[128];
|
||||
var array = new char[128];
|
||||
|
||||
var p1 = new Rectangle3D(0, 0, 0, 0, 0, 0);
|
||||
Assert.True(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
@ -48,7 +48,7 @@ public class Rectangle3DTests
|
|||
{
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[1];
|
||||
var array = new char[1];
|
||||
|
||||
var p1 = new Rectangle3D(0, 0, 0, 0, 0, 0);
|
||||
Assert.False(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public sealed class WorldLocationTests
|
|||
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[128];
|
||||
var array = new char[128];
|
||||
|
||||
var p1 = new WorldLocation(0, 0, 0, map);
|
||||
Assert.True(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
@ -82,7 +82,7 @@ public sealed class WorldLocationTests
|
|||
|
||||
const int max = int.MaxValue;
|
||||
const int min = int.MinValue;
|
||||
char[] array = new char[1];
|
||||
var array = new char[1];
|
||||
|
||||
var p1 = new WorldLocation(0, 0, 0, map);
|
||||
Assert.False(p1.TryFormat(array, out var cp1, null, null));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class ContainerTests
|
|||
|
||||
container2.AddItem(static1);
|
||||
|
||||
List<Static> statics = new List<Static>();
|
||||
var statics = new List<Static>();
|
||||
foreach (var item in container.FindItemsByType<Static>())
|
||||
{
|
||||
statics.Add(item);
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ public class ItemByDistanceEnumeratorTests
|
|||
for (var side = 0; side < 4; side++)
|
||||
{
|
||||
var offset = ringOffset * Map.SectorSize;
|
||||
Point3D pos = side switch
|
||||
var pos = side switch
|
||||
{
|
||||
0 => new Point3D(center.X + offset, center.Y, 0),
|
||||
1 => new Point3D(center.X, center.Y + offset, 0),
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ namespace Server.Tests.Tests.Maps
|
|||
};
|
||||
|
||||
// When
|
||||
string serialized = JsonConfig.Serialize(mapConfig);
|
||||
TestMapConfig deserialized = JsonSerializer.Deserialize<TestMapConfig>(serialized, JsonConfig.GetOptions());
|
||||
var serialized = JsonConfig.Serialize(mapConfig);
|
||||
var deserialized = JsonSerializer.Deserialize<TestMapConfig>(serialized, JsonConfig.GetOptions());
|
||||
|
||||
// Then
|
||||
Assert.Equal(mapConfig.TestMapFlags, deserialized.TestMapFlags);
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ public class MobileByDistanceEnumeratorTests
|
|||
for (var side = 0; side < 4; side++)
|
||||
{
|
||||
var offset = ringOffset * Map.SectorSize;
|
||||
Point3D pos = side switch
|
||||
var pos = side switch
|
||||
{
|
||||
0 => new Point3D(center.X + offset, center.Y, 0),
|
||||
1 => new Point3D(center.X, center.Y + offset, 0),
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class FirewallTests
|
|||
var entry = new SingleIpFirewallEntry("172.16.0.1");
|
||||
Firewall.Add(entry);
|
||||
|
||||
bool found = false;
|
||||
var found = false;
|
||||
Firewall.ReadFirewallSet(set =>
|
||||
{
|
||||
found = set.Contains(entry);
|
||||
|
|
@ -86,8 +86,8 @@ public class FirewallTests
|
|||
[Fact]
|
||||
public void Firewall_IsThreadSafe()
|
||||
{
|
||||
IPAddress[] testIps = new IPAddress[256];
|
||||
for (int i = 0; i <= 255; i++)
|
||||
var testIps = new IPAddress[256];
|
||||
for (var i = 0; i <= 255; i++)
|
||||
{
|
||||
testIps[i] = IPAddress.Parse($"192.168.0.{i}");
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ public class FirewallTests
|
|||
|
||||
Parallel.ForEach(testIps, ip =>
|
||||
{
|
||||
bool shouldBlock = int.Parse(ip.ToString().Split('.')[3]) is > 0;
|
||||
var shouldBlock = int.Parse(ip.ToString().Split('.')[3]) is > 0;
|
||||
Assert.Equal(shouldBlock, Firewall.IsBlocked(ip));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSwing()
|
||||
{
|
||||
Serial attacker = (Serial)0x1024;
|
||||
Serial defender = (Serial)0x2048;
|
||||
var attacker = (Serial)0x1024;
|
||||
var defender = (Serial)0x2048;
|
||||
|
||||
var expected = new Swing(attacker, defender).Compile();
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestChangeCombatant()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new ChangeCombatant(serial).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerDisplay()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplay(serial, gumpId).Compile();
|
||||
|
|
@ -26,7 +26,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerDisplayHS()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplayHS(serial, gumpId).Compile();
|
||||
|
|
@ -42,7 +42,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDisplaySpellbook()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbook(serial).Compile();
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDisplaySpellbookHS()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbookHS(serial).Compile();
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestNewSpellbookContent()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort graphic = 100;
|
||||
ushort offset = 10;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
bool opl = ObjectPropertyList.Enabled;
|
||||
var opl = ObjectPropertyList.Enabled;
|
||||
|
||||
var expected = new NewSpellbookContent(serial, graphic, offset, content).Compile();
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSpellbookContent()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort offset = 10;
|
||||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
|
@ -109,7 +109,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSpellbookContent6017()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort offset = 10;
|
||||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
|
@ -127,7 +127,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerContentUpdate()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate(item).Compile();
|
||||
|
|
@ -142,7 +142,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerContentUpdate6017()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate6017(item).Compile();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class DamagePacketTests
|
|||
[Theory, InlineData(10), InlineData(-5), InlineData(1024)]
|
||||
public void TestDamagePacketOld(int inputAmount)
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacketOld(serial, inputAmount).Compile();
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class DamagePacketTests
|
|||
[Theory, InlineData(10), InlineData(-5), InlineData(1024), InlineData(100000)]
|
||||
public void TestDamage(int inputAmount)
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacket(serial, inputAmount).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ namespace Server.Tests.Network
|
|||
public void TestParticleEffect()
|
||||
{
|
||||
var effectType = EffectType.Moving;
|
||||
Serial serial = (Serial)0x4000;
|
||||
Serial from = (Serial)0x1000;
|
||||
Serial to = (Serial)0x2000;
|
||||
var serial = (Serial)0x4000;
|
||||
var from = (Serial)0x1000;
|
||||
var to = (Serial)0x2000;
|
||||
var itemId = 0x100;
|
||||
var fromPoint = new Point3D(1000, 100, -10);
|
||||
var toPoint = new Point3D(1500, 500, 0);
|
||||
|
|
@ -63,8 +63,8 @@ namespace Server.Tests.Network
|
|||
public void TestHuedEffect()
|
||||
{
|
||||
var effectType = EffectType.Moving;
|
||||
Serial from = (Serial)0x1000;
|
||||
Serial to = (Serial)0x2000;
|
||||
var from = (Serial)0x1000;
|
||||
var to = (Serial)0x2000;
|
||||
var itemId = 0x100;
|
||||
var fromPoint = new Point3D(1000, 100, -10);
|
||||
var toPoint = new Point3D(1500, 500, 0);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class GumpPacketTests
|
|||
[Fact]
|
||||
public void TestDisplaySignGump()
|
||||
{
|
||||
Serial gumpSerial = (Serial)0x1000;
|
||||
var gumpSerial = (Serial)0x1000;
|
||||
const int gumpId = 100;
|
||||
const string unknownString = "This is an unknown string";
|
||||
const string caption = "This is a caption";
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class ItemPacketTests
|
|||
[Fact]
|
||||
public void TestWorldItemPacket()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
@ -45,7 +45,7 @@ public class ItemPacketTests
|
|||
[Fact]
|
||||
public void TestWorldItemSAPacket()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
ushort itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
@ -81,7 +81,7 @@ public class ItemPacketTests
|
|||
[Fact]
|
||||
public void TestWorldItemHSPacket()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestPersonalLightLevel()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
byte lightLevel = 5;
|
||||
var expected = new PersonalLightLevel(serial, lightLevel).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMessageLocalized()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -48,7 +48,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMessageLocalizedAffix()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -93,7 +93,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestAsciiMessage()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -131,7 +131,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestUnicodeMessage()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
var serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -171,8 +171,8 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestFollowMessage()
|
||||
{
|
||||
Serial serial = (Serial)0x1024;
|
||||
Serial serial2 = (Serial)0x2;
|
||||
var serial = (Serial)0x1024;
|
||||
var serial2 = (Serial)0x2;
|
||||
|
||||
var expected = new FollowMessage(serial, serial2).Compile();
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestObjectHelpResponse()
|
||||
{
|
||||
Serial s = (Serial)0x100;
|
||||
var s = (Serial)0x100;
|
||||
var text = "This is some testing text";
|
||||
|
||||
var expected = new ObjectHelpResponse(s, text).Compile();
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ public class MobilePacketTests
|
|||
[Fact]
|
||||
public void TestDeathAnimation()
|
||||
{
|
||||
Serial killed = (Serial)0x1;
|
||||
Serial corpse = (Serial)0x1000;
|
||||
var killed = (Serial)0x1;
|
||||
var corpse = (Serial)0x1000;
|
||||
|
||||
var expected = new DeathAnimation(killed, corpse).Compile();
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class MobilePacketTests
|
|||
[Fact]
|
||||
public void TestBondStatus()
|
||||
{
|
||||
Serial petSerial = (Serial)0x1;
|
||||
var petSerial = (Serial)0x1;
|
||||
const bool bonded = true;
|
||||
|
||||
var expected = new BondedStatus(petSerial, bonded).Compile();
|
||||
|
|
@ -79,7 +79,7 @@ public class MobilePacketTests
|
|||
[InlineData(10, 100, 25, true, false, 0)]
|
||||
public void TestMobileAnimation(int action, int frameCount, int repeatCount, bool reverse, bool repeat, byte delay)
|
||||
{
|
||||
Serial mobile = (Serial)0x1;
|
||||
var mobile = (Serial)0x1;
|
||||
|
||||
var expected = new MobileAnimation(
|
||||
mobile,
|
||||
|
|
@ -111,7 +111,7 @@ public class MobilePacketTests
|
|||
[InlineData(10, 100, 20)]
|
||||
public void TestNewMobileAnimation(int action, int frameCount, byte delay)
|
||||
{
|
||||
Serial mobile = (Serial)0x1;
|
||||
var mobile = (Serial)0x1;
|
||||
|
||||
var expected = new NewMobileAnimation(
|
||||
mobile,
|
||||
|
|
@ -490,7 +490,7 @@ public class MobilePacketTests
|
|||
[Fact]
|
||||
public void TestRemoveEntity()
|
||||
{
|
||||
Serial e = (Serial)0x1000;
|
||||
var e = (Serial)0x1000;
|
||||
var expected = new RemoveEntity(e).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class DecimalSerializationTests
|
|||
public void TestSerializeDecimal(decimal value)
|
||||
{
|
||||
// Arrange
|
||||
byte[] buffer = new byte[sizeof(decimal)];
|
||||
var buffer = new byte[sizeof(decimal)];
|
||||
|
||||
// Act
|
||||
Write(buffer, value);
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ public class TypeConverterTests
|
|||
public void TestReadAfterWrite()
|
||||
{
|
||||
// Arrange
|
||||
Type itemType = typeof(Item);
|
||||
var itemType = typeof(Item);
|
||||
|
||||
JsonSerializerOptions options = new JsonSerializerOptions();
|
||||
var options = new JsonSerializerOptions();
|
||||
|
||||
TypeConverter converter = new TypeConverter();
|
||||
var converter = new TypeConverter();
|
||||
var bufferWriter = new ArrayBufferWriter<byte>();
|
||||
using var jsonWriter = new Utf8JsonWriter(bufferWriter);
|
||||
converter.Write(jsonWriter, itemType, options);
|
||||
|
|
@ -28,11 +28,11 @@ public class TypeConverterTests
|
|||
jsonWriter.Flush();
|
||||
var jsonData = bufferWriter.WrittenSpan;
|
||||
|
||||
Utf8JsonReader jsonReader = new Utf8JsonReader(jsonData);
|
||||
var jsonReader = new Utf8JsonReader(jsonData);
|
||||
jsonReader.Read();
|
||||
|
||||
// Assert
|
||||
Type readType = converter.Read(ref jsonReader, typeof(Type), options);
|
||||
var readType = converter.Read(ref jsonReader, typeof(Type), options);
|
||||
Assert.Equal(typeof(Item), readType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class TimerTests
|
|||
|
||||
var tickCount = expectedTicks / 8;
|
||||
|
||||
for (int i = 1; i <= tickCount; i++)
|
||||
for (var i = 1; i <= tickCount; i++)
|
||||
{
|
||||
timerTicks.Ticks = i * 8;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ public class TimerTests
|
|||
|
||||
var tickCount = (expectedDelayTicks + (expectedIntervalTicks * count - 1)) / 8;
|
||||
|
||||
for (int i = 1; i <= tickCount; i++)
|
||||
for (var i = 1; i <= tickCount; i++)
|
||||
{
|
||||
timerTicks.Ticks = i * 8;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ public class VirtualSerialTests
|
|||
public void TestNewVirtualGetsAndRollover()
|
||||
{
|
||||
// Acquire virtual serials until we hit the max
|
||||
Serial lastSerial = World.NewVirtual;
|
||||
var lastSerial = World.NewVirtual;
|
||||
do
|
||||
{
|
||||
Serial virtualSerial = World.NewVirtual;
|
||||
var virtualSerial = World.NewVirtual;
|
||||
Assert.Equal(lastSerial + 1, virtualSerial);
|
||||
lastSerial = (Serial) (uint) virtualSerial;
|
||||
} while (lastSerial != World.MaxVirtualSerial);
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public static class AssemblyHandler
|
|||
{
|
||||
var types = assembly.GetTypes();
|
||||
|
||||
for (int i = 0; i < types.Length; i++)
|
||||
for (var i = 0; i < types.Length; i++)
|
||||
{
|
||||
var m = types[i].GetMethod(method, BindingFlags.Static | BindingFlags.Public);
|
||||
if (m?.GetParameters().Length == 0)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public ref struct RawInterpolatedStringHandler
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] // used only on a few hot paths
|
||||
public void Clear()
|
||||
{
|
||||
char[]? toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
this = default; // defensive clear
|
||||
if (toReturn is not null)
|
||||
{
|
||||
|
|
@ -102,8 +102,8 @@ public ref struct RawInterpolatedStringHandler
|
|||
{
|
||||
if (value.Length == 1)
|
||||
{
|
||||
Span<char> chars = _chars;
|
||||
int pos = _pos;
|
||||
var chars = _chars;
|
||||
var pos = _pos;
|
||||
if ((uint)pos < (uint)chars.Length)
|
||||
{
|
||||
chars[pos] = value[0];
|
||||
|
|
@ -312,7 +312,7 @@ public ref struct RawInterpolatedStringHandler
|
|||
/// <param name="alignment">Minimum number of characters that should be written for this value. If the value is negative, it indicates left-aligned and the required minimum is the absolute value.</param>
|
||||
public void AppendFormatted<T>(T value, int alignment)
|
||||
{
|
||||
int startingPos = _pos;
|
||||
var startingPos = _pos;
|
||||
AppendFormatted(value);
|
||||
if (alignment != 0)
|
||||
{
|
||||
|
|
@ -326,7 +326,7 @@ public ref struct RawInterpolatedStringHandler
|
|||
/// <param name="alignment">Minimum number of characters that should be written for this value. If the value is negative, it indicates left-aligned and the required minimum is the absolute value.</param>
|
||||
public void AppendFormatted<T>(T value, int alignment, string? format)
|
||||
{
|
||||
int startingPos = _pos;
|
||||
var startingPos = _pos;
|
||||
AppendFormatted(value, format);
|
||||
if (alignment != 0)
|
||||
{
|
||||
|
|
@ -357,14 +357,14 @@ public ref struct RawInterpolatedStringHandler
|
|||
/// <param name="format">The format string.</param>
|
||||
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
|
||||
{
|
||||
bool leftAlign = false;
|
||||
var leftAlign = false;
|
||||
if (alignment < 0)
|
||||
{
|
||||
leftAlign = true;
|
||||
alignment = -alignment;
|
||||
}
|
||||
|
||||
int paddingRequired = alignment - value.Length;
|
||||
var paddingRequired = alignment - value.Length;
|
||||
if (paddingRequired <= 0)
|
||||
{
|
||||
// The value is as large or larger than the required amount of padding,
|
||||
|
|
@ -477,7 +477,7 @@ public ref struct RawInterpolatedStringHandler
|
|||
Debug.Assert(_hasCustomFormatter);
|
||||
Debug.Assert(_provider != null);
|
||||
|
||||
ICustomFormatter? formatter = (ICustomFormatter?)_provider.GetFormat(typeof(ICustomFormatter));
|
||||
var formatter = (ICustomFormatter?)_provider.GetFormat(typeof(ICustomFormatter));
|
||||
Debug.Assert(formatter != null, "An incorrectly written provider said it implemented ICustomFormatter, and then didn't");
|
||||
|
||||
if (formatter?.Format(format, value, _provider) is string customFormatted)
|
||||
|
|
@ -494,16 +494,16 @@ public ref struct RawInterpolatedStringHandler
|
|||
Debug.Assert(startingPos >= 0 && startingPos <= _pos);
|
||||
Debug.Assert(alignment != 0);
|
||||
|
||||
int charsWritten = _pos - startingPos;
|
||||
var charsWritten = _pos - startingPos;
|
||||
|
||||
bool leftAlign = false;
|
||||
var leftAlign = false;
|
||||
if (alignment < 0)
|
||||
{
|
||||
leftAlign = true;
|
||||
alignment = -alignment;
|
||||
}
|
||||
|
||||
int paddingNeeded = alignment - charsWritten;
|
||||
var paddingNeeded = alignment - charsWritten;
|
||||
if (paddingNeeded > 0)
|
||||
{
|
||||
EnsureCapacityForAdditionalChars(paddingNeeded);
|
||||
|
|
@ -583,13 +583,13 @@ public ref struct RawInterpolatedStringHandler
|
|||
// ints that could technically overflow if someone tried to, for example, append a huge string to a huge string, we also clamp to int.MaxValue.
|
||||
// Even if the array creation fails in such a case, we may later fail in ToStringAndClear.
|
||||
|
||||
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, 0x3FFFFFDF));
|
||||
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
|
||||
var newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, 0x3FFFFFDF));
|
||||
var arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
|
||||
|
||||
char[] newArray = STArrayPool<char>.Shared.Rent(arraySize);
|
||||
var newArray = STArrayPool<char>.Shared.Rent(arraySize);
|
||||
_chars[.._pos].CopyTo(newArray);
|
||||
|
||||
char[]? toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
_chars = _arrayToReturnToPool = newArray;
|
||||
|
||||
if (toReturn is not null)
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static int GetMaxSizeForBucket(int binIndex)
|
||||
{
|
||||
int maxSize = 16 << binIndex;
|
||||
var maxSize = 16 << binIndex;
|
||||
Debug.Assert(maxSize >= 0);
|
||||
return maxSize;
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
|
||||
internal static MemoryPressure GetMemoryPressure()
|
||||
{
|
||||
GCMemoryInfo memoryInfo = GC.GetGCMemoryInfo();
|
||||
var memoryInfo = GC.GetGCMemoryInfo();
|
||||
|
||||
if (memoryInfo.MemoryLoadBytes >= memoryInfo.HighMemoryLoadThresholdBytes * 0.90)
|
||||
{
|
||||
|
|
@ -333,7 +333,7 @@ public class STArrayPool<T> : ArrayPool<T>
|
|||
return;
|
||||
}
|
||||
|
||||
int trimCount = 1;
|
||||
var trimCount = 1;
|
||||
switch (pressure)
|
||||
{
|
||||
case MemoryPressure.Medium:
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public ref struct ValueStringBuilder
|
|||
Grow(count);
|
||||
}
|
||||
|
||||
int remaining = _length - index;
|
||||
var remaining = _length - index;
|
||||
_chars.Slice(index, remaining).CopyTo(_chars[(index + count)..]);
|
||||
_chars.Slice(index, count).Fill(value);
|
||||
_length += count;
|
||||
|
|
@ -165,14 +165,14 @@ public ref struct ValueStringBuilder
|
|||
return;
|
||||
}
|
||||
|
||||
int count = s.Length;
|
||||
var count = s.Length;
|
||||
|
||||
if (_length > _chars.Length - count)
|
||||
{
|
||||
Grow(count);
|
||||
}
|
||||
|
||||
int remaining = _length - index;
|
||||
var remaining = _length - index;
|
||||
_chars.Slice(index, remaining).CopyTo(_chars[(index + count)..]);
|
||||
s.AsSpan().CopyTo(_chars[index..]);
|
||||
_length += count;
|
||||
|
|
@ -184,7 +184,7 @@ public ref struct ValueStringBuilder
|
|||
{
|
||||
if (value is ISpanFormattable)
|
||||
{
|
||||
Span<char> destination = _chars[_length..];
|
||||
var destination = _chars[_length..];
|
||||
int charsWritten;
|
||||
while (!((ISpanFormattable)value).TryFormat(destination, out charsWritten, format, default))
|
||||
{
|
||||
|
|
@ -229,7 +229,7 @@ public ref struct ValueStringBuilder
|
|||
return;
|
||||
}
|
||||
|
||||
int pos = _length;
|
||||
var pos = _length;
|
||||
if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc.
|
||||
{
|
||||
_chars[pos] = s[0];
|
||||
|
|
@ -265,7 +265,7 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void AppendSlow(string? s)
|
||||
{
|
||||
int pos = _length;
|
||||
var pos = _length;
|
||||
if (pos > _chars.Length - s.Length)
|
||||
{
|
||||
Grow(s.Length);
|
||||
|
|
@ -283,8 +283,8 @@ public ref struct ValueStringBuilder
|
|||
Grow(count);
|
||||
}
|
||||
|
||||
Span<char> dst = _chars.Slice(_length, count);
|
||||
for (int i = 0; i < dst.Length; i++)
|
||||
var dst = _chars.Slice(_length, count);
|
||||
for (var i = 0; i < dst.Length; i++)
|
||||
{
|
||||
dst[i] = c;
|
||||
}
|
||||
|
|
@ -294,14 +294,14 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Append(char* value, int length)
|
||||
{
|
||||
int pos = _length;
|
||||
var pos = _length;
|
||||
if (pos > _chars.Length - length)
|
||||
{
|
||||
Grow(length);
|
||||
}
|
||||
|
||||
Span<char> dst = _chars.Slice(_length, length);
|
||||
for (int i = 0; i < dst.Length; i++)
|
||||
var dst = _chars.Slice(_length, length);
|
||||
for (var i = 0; i < dst.Length; i++)
|
||||
{
|
||||
dst[i] = *value++;
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Append(scoped ReadOnlySpan<char> value)
|
||||
{
|
||||
int pos = _length;
|
||||
var pos = _length;
|
||||
if (pos > _chars.Length - value.Length)
|
||||
{
|
||||
Grow(value.Length);
|
||||
|
|
@ -324,7 +324,7 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<char> AppendSpan(int length)
|
||||
{
|
||||
int origPos = _length;
|
||||
var origPos = _length;
|
||||
if (origPos > _chars.Length - length)
|
||||
{
|
||||
Grow(length);
|
||||
|
|
@ -345,11 +345,11 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void Grow(int additionalCapacityBeyondPos)
|
||||
{
|
||||
char[] poolArray = ArrayPool.Rent(Math.Max(_length + additionalCapacityBeyondPos, _chars.Length * 2));
|
||||
var poolArray = ArrayPool.Rent(Math.Max(_length + additionalCapacityBeyondPos, _chars.Length * 2));
|
||||
|
||||
_chars[.._length].CopyTo(poolArray);
|
||||
|
||||
char[] toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
_chars = _arrayToReturnToPool = poolArray;
|
||||
if (toReturn != null)
|
||||
{
|
||||
|
|
@ -372,7 +372,7 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReplaceAny(ReadOnlySpan<char> oldChars, ReadOnlySpan<char> newChars, int startIndex, int count)
|
||||
{
|
||||
int currentLength = _length;
|
||||
var currentLength = _length;
|
||||
if ((uint)startIndex > (uint)currentLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(startIndex));
|
||||
|
|
@ -403,7 +403,7 @@ public ref struct ValueStringBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Replace(char oldChar, char newChar, int startIndex, int count)
|
||||
{
|
||||
int currentLength = _length;
|
||||
var currentLength = _length;
|
||||
if ((uint)startIndex > (uint)currentLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(startIndex));
|
||||
|
|
|
|||
|
|
@ -106,15 +106,15 @@ public class ArtData : IDisposable
|
|||
|
||||
public static Rectangle2D GetBoundsFromRGBA1555Bitmap(int width, int height, ReadOnlySpan<ushort> data)
|
||||
{
|
||||
ReadOnlySpan<ushort> lookups = data[..height];
|
||||
var lookups = data[..height];
|
||||
data = data[height..];
|
||||
|
||||
int xMin = width;
|
||||
int yMin = height;
|
||||
int xMax = -1;
|
||||
int yMax = -1;
|
||||
var xMin = width;
|
||||
var yMin = height;
|
||||
var xMax = -1;
|
||||
var yMax = -1;
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
var i = lookups[y];
|
||||
var x = 0;
|
||||
|
|
@ -133,7 +133,7 @@ public class ArtData : IDisposable
|
|||
for (var end = x + pixelCount; x < end; x++)
|
||||
{
|
||||
// Get the pixel value from the bitmap data
|
||||
ushort pixel = data[i++];
|
||||
var pixel = data[i++];
|
||||
|
||||
// Check if the pixel is non-black (0 in 555 RGB is completely black)
|
||||
if (pixel == 0)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public static class UOClient
|
|||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
using FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
var buffer = GC.AllocateUninitializedArray<byte>((int)fs.Length, true);
|
||||
_ = fs.Read(buffer);
|
||||
// VS_VERSION_INFO (unicode)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public struct ArrayEnumerator<T> : IEnumerator<T>
|
|||
|
||||
public bool MoveNext()
|
||||
{
|
||||
T[] localList = _array;
|
||||
var localList = _array;
|
||||
|
||||
if ((uint)_index < (uint)localList.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ internal static class HashHelpers
|
|||
{
|
||||
if ((candidate & 1) != 0)
|
||||
{
|
||||
int limit = (int)Math.Sqrt(candidate);
|
||||
for (int divisor = 3; divisor <= limit; divisor += 2)
|
||||
var limit = (int)Math.Sqrt(candidate);
|
||||
for (var divisor = 3; divisor <= limit; divisor += 2)
|
||||
{
|
||||
if (candidate % divisor == 0)
|
||||
{
|
||||
|
|
@ -63,9 +63,9 @@ internal static class HashHelpers
|
|||
throw new ArgumentException("Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < primes.Length; i++)
|
||||
for (var i = 0; i < primes.Length; i++)
|
||||
{
|
||||
int prime = primes[i];
|
||||
var prime = primes[i];
|
||||
if (prime >= min)
|
||||
{
|
||||
return prime;
|
||||
|
|
@ -74,7 +74,7 @@ internal static class HashHelpers
|
|||
|
||||
//outside of our predefined table.
|
||||
//compute the hard way.
|
||||
for (int i = min | 1; i < int.MaxValue; i += 2)
|
||||
for (var i = min | 1; i < int.MaxValue; i += 2)
|
||||
{
|
||||
if (IsPrime(i) && (i - 1) % HashPrime != 0)
|
||||
{
|
||||
|
|
@ -87,7 +87,7 @@ internal static class HashHelpers
|
|||
// Returns size of hashtable to grow to.
|
||||
public static int ExpandPrime(int oldSize)
|
||||
{
|
||||
int newSize = 2 * oldSize;
|
||||
var newSize = 2 * oldSize;
|
||||
|
||||
// Allow the hashtables to grow to maximum possible size (~2G elements) before encountering capacity overflow.
|
||||
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
|
||||
|
|
@ -116,7 +116,7 @@ internal static class HashHelpers
|
|||
|
||||
// This is equivalent of (uint)Math.BigMul(multiplier * value, divisor, out _). This version
|
||||
// is faster than BigMul currently because we only need the high bits.
|
||||
uint highbits = (uint)(((((multiplier * value) >> 32) + 1) * divisor) >> 32);
|
||||
var highbits = (uint)(((((multiplier * value) >> 32) + 1) * divisor) >> 32);
|
||||
|
||||
Debug.Assert(highbits == value % divisor);
|
||||
return highbits;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public ref struct PooledRefList<T>
|
|||
_version = 0;
|
||||
_mt = mt;
|
||||
|
||||
int count = collection.Count;
|
||||
var count = collection.Count;
|
||||
if (count == 0)
|
||||
{
|
||||
_items = s_emptyArray;
|
||||
|
|
@ -100,7 +100,7 @@ public ref struct PooledRefList<T>
|
|||
|
||||
if (collection is ICollection<T> c)
|
||||
{
|
||||
int count = c.Count;
|
||||
var count = c.Count;
|
||||
if (count == 0)
|
||||
{
|
||||
_items = s_emptyArray;
|
||||
|
|
@ -117,7 +117,7 @@ public ref struct PooledRefList<T>
|
|||
{
|
||||
_size = 0;
|
||||
_items = s_emptyArray;
|
||||
using IEnumerator<T> en = collection!.GetEnumerator();
|
||||
using var en = collection!.GetEnumerator();
|
||||
while (en.MoveNext())
|
||||
{
|
||||
Add(en.Current);
|
||||
|
|
@ -143,7 +143,7 @@ public ref struct PooledRefList<T>
|
|||
{
|
||||
if (value > 0)
|
||||
{
|
||||
T[] newItems = ArrayPool.Rent(value);
|
||||
var newItems = ArrayPool.Rent(value);
|
||||
if (_size > 0)
|
||||
{
|
||||
Array.Copy(_items, newItems, _size);
|
||||
|
|
@ -211,8 +211,8 @@ public ref struct PooledRefList<T>
|
|||
public void Add(T item)
|
||||
{
|
||||
_version++;
|
||||
T[] array = _items;
|
||||
int size = _size;
|
||||
var array = _items;
|
||||
var size = _size;
|
||||
if ((uint)size < (uint)array.Length)
|
||||
{
|
||||
_size = size + 1;
|
||||
|
|
@ -229,7 +229,7 @@ public ref struct PooledRefList<T>
|
|||
private void AddWithResize(T item)
|
||||
{
|
||||
Debug.Assert(_size == _items.Length);
|
||||
int size = _size;
|
||||
var size = _size;
|
||||
Grow(size + 1);
|
||||
_size = size + 1;
|
||||
_items[size] = item;
|
||||
|
|
@ -292,7 +292,7 @@ public ref struct PooledRefList<T>
|
|||
_version++;
|
||||
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
|
||||
{
|
||||
int size = _size;
|
||||
var size = _size;
|
||||
_size = 0;
|
||||
if (size > 0)
|
||||
{
|
||||
|
|
@ -329,8 +329,8 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(converter));
|
||||
}
|
||||
|
||||
PooledRefList<TOutput> list = new PooledRefList<TOutput>(_size);
|
||||
for (int i = 0; i < _size; i++)
|
||||
var list = new PooledRefList<TOutput>(_size);
|
||||
for (var i = 0; i < _size; i++)
|
||||
{
|
||||
list._items[i] = converter(_items[i]);
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ public ref struct PooledRefList<T>
|
|||
{
|
||||
Debug.Assert(_items.Length < capacity);
|
||||
|
||||
int newcapacity = _items.Length == 0 ? DefaultCapacity : 2 * _items.Length;
|
||||
var newcapacity = _items.Length == 0 ? DefaultCapacity : 2 * _items.Length;
|
||||
|
||||
// Allow the list to grow to maximum possible capacity (~2G elements) before encountering overflow.
|
||||
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
|
||||
|
|
@ -421,7 +421,7 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
for (int i = 0; i < _size; i++)
|
||||
for (var i = 0; i < _size; i++)
|
||||
{
|
||||
if (match(_items[i]))
|
||||
{
|
||||
|
|
@ -438,8 +438,8 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
PooledRefList<T> list = new PooledRefList<T>();
|
||||
for (int i = 0; i < _size; i++)
|
||||
var list = new PooledRefList<T>();
|
||||
for (var i = 0; i < _size; i++)
|
||||
{
|
||||
if (match(_items[i]))
|
||||
{
|
||||
|
|
@ -470,8 +470,8 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
int endIndex = startIndex + count;
|
||||
for (int i = startIndex; i < endIndex; i++)
|
||||
var endIndex = startIndex + count;
|
||||
for (var i = startIndex; i < endIndex; i++)
|
||||
{
|
||||
if (match(_items[i]))
|
||||
{
|
||||
|
|
@ -488,7 +488,7 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
for (int i = _size - 1; i >= 0; i--)
|
||||
for (var i = _size - 1; i >= 0; i--)
|
||||
{
|
||||
if (match(_items[i]))
|
||||
{
|
||||
|
|
@ -532,8 +532,8 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
|
||||
int endIndex = startIndex - count;
|
||||
for (int i = startIndex; i > endIndex; i--)
|
||||
var endIndex = startIndex - count;
|
||||
for (var i = startIndex; i > endIndex; i--)
|
||||
{
|
||||
if (match(_items[i]))
|
||||
{
|
||||
|
|
@ -550,9 +550,9 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
int version = _version;
|
||||
var version = _version;
|
||||
|
||||
for (int i = 0; i < _size; i++)
|
||||
for (var i = 0; i < _size; i++)
|
||||
{
|
||||
if (version != _version)
|
||||
{
|
||||
|
|
@ -591,7 +591,7 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentException("Length must be greater than zero");
|
||||
}
|
||||
|
||||
PooledRefList<T> list = new PooledRefList<T>(count);
|
||||
var list = new PooledRefList<T>(count);
|
||||
Array.Copy(_items, index, list._items, 0, count);
|
||||
list._size = count;
|
||||
return list;
|
||||
|
|
@ -694,7 +694,7 @@ public ref struct PooledRefList<T>
|
|||
|
||||
if (collection is ICollection<T> c)
|
||||
{
|
||||
int count = c.Count;
|
||||
var count = c.Count;
|
||||
if (count > 0)
|
||||
{
|
||||
if (_items.Length - _size < count)
|
||||
|
|
@ -712,7 +712,7 @@ public ref struct PooledRefList<T>
|
|||
}
|
||||
else
|
||||
{
|
||||
using IEnumerator<T> en = collection.GetEnumerator();
|
||||
using var en = collection.GetEnumerator();
|
||||
while (en.MoveNext())
|
||||
{
|
||||
Insert(index++, en.Current);
|
||||
|
|
@ -801,7 +801,7 @@ public ref struct PooledRefList<T>
|
|||
// decreased by one.
|
||||
public bool Remove(T item)
|
||||
{
|
||||
int index = IndexOf(item);
|
||||
var index = IndexOf(item);
|
||||
if (index >= 0)
|
||||
{
|
||||
RemoveAt(index);
|
||||
|
|
@ -820,7 +820,7 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
int freeIndex = 0; // the first free slot in items array
|
||||
var freeIndex = 0; // the first free slot in items array
|
||||
|
||||
// Find the first item which needs to be removed.
|
||||
while (freeIndex < _size && !match(_items[freeIndex]))
|
||||
|
|
@ -833,7 +833,7 @@ public ref struct PooledRefList<T>
|
|||
return 0;
|
||||
}
|
||||
|
||||
int current = freeIndex + 1;
|
||||
var current = freeIndex + 1;
|
||||
while (current < _size)
|
||||
{
|
||||
// Find the first item which needs to be kept.
|
||||
|
|
@ -854,7 +854,7 @@ public ref struct PooledRefList<T>
|
|||
Array.Clear(_items, freeIndex, _size - freeIndex); // Clear the elements so that the gc can reclaim the references.
|
||||
}
|
||||
|
||||
int result = _size - freeIndex;
|
||||
var result = _size - freeIndex;
|
||||
_size = freeIndex;
|
||||
_version++;
|
||||
return result;
|
||||
|
|
@ -1002,7 +1002,7 @@ public ref struct PooledRefList<T>
|
|||
return s_emptyArray;
|
||||
}
|
||||
|
||||
T[] array = new T[_size];
|
||||
var array = new T[_size];
|
||||
Array.Copy(_items, array, _size);
|
||||
return array;
|
||||
}
|
||||
|
|
@ -1014,7 +1014,7 @@ public ref struct PooledRefList<T>
|
|||
return s_emptyArray;
|
||||
}
|
||||
|
||||
T[] array = ArrayPool.Rent(_size);
|
||||
var array = ArrayPool.Rent(_size);
|
||||
Array.Copy(_items, array, _size);
|
||||
return array;
|
||||
}
|
||||
|
|
@ -1030,7 +1030,7 @@ public ref struct PooledRefList<T>
|
|||
//
|
||||
public void TrimExcess()
|
||||
{
|
||||
int threshold = (int)(_items.Length * 0.9);
|
||||
var threshold = (int)(_items.Length * 0.9);
|
||||
if (_size < threshold)
|
||||
{
|
||||
Capacity = _size;
|
||||
|
|
@ -1044,7 +1044,7 @@ public ref struct PooledRefList<T>
|
|||
throw new ArgumentNullException(nameof(match));
|
||||
}
|
||||
|
||||
for (int i = 0; i < _size; i++)
|
||||
for (var i = 0; i < _size; i++)
|
||||
{
|
||||
if (!match(_items[i]))
|
||||
{
|
||||
|
|
@ -1077,7 +1077,7 @@ public ref struct PooledRefList<T>
|
|||
|
||||
public bool MoveNext()
|
||||
{
|
||||
PooledRefList<T> localList = _list;
|
||||
var localList = _list;
|
||||
|
||||
if (_version == localList._version && (uint)_index < (uint)localList._size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,13 +97,13 @@ public ref struct PooledRefQueue<T>
|
|||
throw new ArgumentException(CollectionThrowStrings.Argument_InvalidOffLen);
|
||||
}
|
||||
|
||||
int numToCopy = _size;
|
||||
var numToCopy = _size;
|
||||
if (numToCopy == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int firstPart = Math.Min(_array.Length - _head, numToCopy);
|
||||
var firstPart = Math.Min(_array.Length - _head, numToCopy);
|
||||
Array.Copy(_array, _head, array, arrayIndex, firstPart);
|
||||
numToCopy -= firstPart;
|
||||
if (numToCopy > 0)
|
||||
|
|
@ -135,15 +135,15 @@ public ref struct PooledRefQueue<T>
|
|||
// InvalidOperationException.
|
||||
public T Dequeue()
|
||||
{
|
||||
int head = _head;
|
||||
T[] array = _array;
|
||||
var head = _head;
|
||||
var array = _array;
|
||||
|
||||
if (_size == 0)
|
||||
{
|
||||
ThrowForEmptyQueue();
|
||||
}
|
||||
|
||||
T removed = array[head];
|
||||
var removed = array[head];
|
||||
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
|
||||
{
|
||||
array[head] = default!;
|
||||
|
|
@ -156,8 +156,8 @@ public ref struct PooledRefQueue<T>
|
|||
|
||||
public bool TryDequeue([MaybeNullWhen(false)] out T result)
|
||||
{
|
||||
int head = _head;
|
||||
T[] array = _array;
|
||||
var head = _head;
|
||||
var array = _array;
|
||||
|
||||
if (_size == 0)
|
||||
{
|
||||
|
|
@ -248,7 +248,7 @@ public ref struct PooledRefQueue<T>
|
|||
return s_emptyArray;
|
||||
}
|
||||
|
||||
T[] arr = new T[_size];
|
||||
var arr = new T[_size];
|
||||
|
||||
if (_head < _tail)
|
||||
{
|
||||
|
|
@ -270,7 +270,7 @@ public ref struct PooledRefQueue<T>
|
|||
return s_emptyArray;
|
||||
}
|
||||
|
||||
T[] arr = (mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Rent(_size);
|
||||
var arr = (mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Rent(_size);
|
||||
|
||||
if (_head < _tail)
|
||||
{
|
||||
|
|
@ -289,7 +289,7 @@ public ref struct PooledRefQueue<T>
|
|||
// must be >= _size.
|
||||
private void SetCapacity(int capacity)
|
||||
{
|
||||
T[] newarray = (_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Rent(capacity);
|
||||
var newarray = (_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Rent(capacity);
|
||||
if (_size > 0)
|
||||
{
|
||||
if (_head < _tail)
|
||||
|
|
@ -321,7 +321,7 @@ public ref struct PooledRefQueue<T>
|
|||
// It is tempting to use the remainder operator here but it is actually much slower
|
||||
// than a simple comparison and a rarely taken branch.
|
||||
// JIT produces better code than with ternary operator ?:
|
||||
int tmp = index + 1;
|
||||
var tmp = index + 1;
|
||||
if (tmp == _array.Length)
|
||||
{
|
||||
tmp = 0;
|
||||
|
|
@ -359,7 +359,7 @@ public ref struct PooledRefQueue<T>
|
|||
const int GrowFactor = 2;
|
||||
const int MinimumGrow = 4;
|
||||
|
||||
int newcapacity = GrowFactor * _array.Length;
|
||||
var newcapacity = GrowFactor * _array.Length;
|
||||
|
||||
// Allow the list to grow to maximum possible capacity (~2G elements) before encountering overflow.
|
||||
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
|
||||
|
|
@ -441,13 +441,13 @@ public ref struct PooledRefQueue<T>
|
|||
}
|
||||
|
||||
// Cache some fields in locals to decrease code size
|
||||
T[] array = _q._array;
|
||||
int capacity = array.Length;
|
||||
var array = _q._array;
|
||||
var capacity = array.Length;
|
||||
|
||||
// _index represents the 0-based index into the queue, however the queue
|
||||
// doesn't have to start from 0 and it may not even be stored contiguously in memory.
|
||||
|
||||
int arrayIndex = _q._head + _index; // this is the actual index into the queue's backing array
|
||||
var arrayIndex = _q._head + _index; // this is the actual index into the queue's backing array
|
||||
if (arrayIndex >= capacity)
|
||||
{
|
||||
// NOTE: Originally we were using the modulo operator here, however
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public static class Effects
|
|||
|
||||
if (map != null)
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in map.GetClientsInRange(p))
|
||||
{
|
||||
|
|
@ -94,9 +94,9 @@ public static class Effects
|
|||
|
||||
e.ProcessDelta();
|
||||
|
||||
Span<byte> preEffect = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> boltEffect = stackalloc byte[OutgoingEffectPackets.BoltEffectLength].InitializePacket();
|
||||
Span<byte> soundEffect = sound ? stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket() : null;
|
||||
var preEffect = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
var boltEffect = stackalloc byte[OutgoingEffectPackets.BoltEffectLength].InitializePacket();
|
||||
var soundEffect = sound ? stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket() : null;
|
||||
|
||||
foreach (var state in map.GetClientsInRange(e.Location))
|
||||
{
|
||||
|
|
@ -131,7 +131,7 @@ public static class Effects
|
|||
Point3D p, Map map, int itemID, int duration, int speed = 10, int hue = 0, int renderMode = 0
|
||||
)
|
||||
{
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
var effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
OutgoingEffectPackets.CreateLocationHuedEffect(
|
||||
effect,
|
||||
p, itemID, speed, duration, hue, renderMode
|
||||
|
|
@ -161,9 +161,9 @@ public static class Effects
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
var particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
var regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
foreach (var state in map.GetClientsInRange(e.Location))
|
||||
{
|
||||
|
|
@ -192,7 +192,7 @@ public static class Effects
|
|||
{
|
||||
(target as Mobile)?.ProcessDelta();
|
||||
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
var effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
OutgoingEffectPackets.CreateTargetHuedEffect(
|
||||
effect,
|
||||
target, itemID, speed, duration, hue, renderMode
|
||||
|
|
@ -223,8 +223,8 @@ public static class Effects
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
var particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
var regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
foreach (var state in map.GetClientsInRange(target.Location))
|
||||
{
|
||||
|
|
@ -363,7 +363,7 @@ public static class Effects
|
|||
int speed, int duration, bool fixedDirection = false, bool explodes = false, int hue = 0, int renderMode = 0
|
||||
)
|
||||
{
|
||||
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
var effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
|
||||
OutgoingEffectPackets.CreateMovingHuedEffect(
|
||||
effect,
|
||||
from, to, itemID, fromLocation, toLocation, speed, duration, fixedDirection,
|
||||
|
|
@ -435,8 +435,8 @@ public static class Effects
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
Span<byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
var particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength].InitializePacket();
|
||||
var regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket() : null;
|
||||
|
||||
foreach (var state in map.GetClientsInRange(from.Location))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public sealed class EventLoopContext : SynchronizationContext
|
|||
return;
|
||||
}
|
||||
|
||||
AutoResetEvent evt = new AutoResetEvent(false);
|
||||
var evt = new AutoResetEvent(false);
|
||||
|
||||
_queue.Enqueue(() =>
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ public sealed class EventLoopContext : SynchronizationContext
|
|||
|
||||
var count = _priorityQueue.Count;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (_priorityQueue.TryDequeue(out var a))
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ public sealed class EventLoopContext : SynchronizationContext
|
|||
|
||||
count = Math.Min(_queue.Count, _maxPerFrame);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (_queue.TryDequeue(out var a))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ public static class ExceptionExtensions
|
|||
|
||||
private static Func<Exception, StackTrace, Exception> _createStackTraceMethod()
|
||||
{
|
||||
ParameterExpression target = Expression.Parameter(typeof(Exception));
|
||||
ParameterExpression stack = Expression.Parameter(typeof(StackTrace));
|
||||
Type traceFormatType = typeof(StackTrace).GetNestedType("TraceFormat", BindingFlags.NonPublic);
|
||||
MethodInfo toString = typeof(StackTrace).GetMethod("ToString", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { traceFormatType }, null);
|
||||
object normalTraceFormat = Enum.GetValues(traceFormatType!).GetValue(0);
|
||||
MethodCallExpression stackTraceString = Expression.Call(stack, toString!, Expression.Constant(normalTraceFormat, traceFormatType));
|
||||
FieldInfo stackTraceStringField = typeof(Exception).GetField("_stackTraceString", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
BinaryExpression assign = Expression.Assign(Expression.Field(target, stackTraceStringField!), stackTraceString);
|
||||
var target = Expression.Parameter(typeof(Exception));
|
||||
var stack = Expression.Parameter(typeof(StackTrace));
|
||||
var traceFormatType = typeof(StackTrace).GetNestedType("TraceFormat", BindingFlags.NonPublic);
|
||||
var toString = typeof(StackTrace).GetMethod("ToString", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { traceFormatType }, null);
|
||||
var normalTraceFormat = Enum.GetValues(traceFormatType!).GetValue(0);
|
||||
var stackTraceString = Expression.Call(stack, toString!, Expression.Constant(normalTraceFormat, traceFormatType));
|
||||
var stackTraceStringField = typeof(Exception).GetField("_stackTraceString", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var assign = Expression.Assign(Expression.Field(target, stackTraceStringField!), stackTraceString);
|
||||
return Expression.Lambda<Func<Exception, StackTrace, Exception>>(Expression.Block(assign, target), target, stack).Compile();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public class ExpansionInfo
|
|||
|
||||
public static void StoreMapSelection(MapSelectionFlags mapSelectionFlags, Expansion expansion)
|
||||
{
|
||||
int expansionIndex = (int)expansion;
|
||||
var expansionIndex = (int)expansion;
|
||||
Table[expansionIndex].MapSelectionFlags = mapSelectionFlags;
|
||||
}
|
||||
|
||||
|
|
@ -207,14 +207,14 @@ public class ExpansionInfo
|
|||
{
|
||||
var pathToExpansionFile = Path.Combine(Core.BaseDirectory, ExpansionConfigurationPath);
|
||||
|
||||
ExpansionInfo expansionConfig = JsonConfig.Deserialize<ExpansionInfo>(pathToExpansionFile);
|
||||
var expansionConfig = JsonConfig.Deserialize<ExpansionInfo>(pathToExpansionFile);
|
||||
if (expansionConfig == null)
|
||||
{
|
||||
expansion = Expansion.None;
|
||||
return false;
|
||||
}
|
||||
|
||||
int currentExpansionIndex = expansionConfig.Id;
|
||||
var currentExpansionIndex = expansionConfig.Id;
|
||||
Table[currentExpansionIndex] = expansionConfig;
|
||||
expansion = (Expansion)currentExpansionIndex;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ internal sealed class Gen2GcCallback : CriticalFinalizerObject
|
|||
if (_weakTargetObj.IsAllocated)
|
||||
{
|
||||
// Check to see if the target object is still alive.
|
||||
object? targetObj = _weakTargetObj.Target;
|
||||
var targetObj = _weakTargetObj.Target;
|
||||
if (targetObj == null)
|
||||
{
|
||||
// The target object is dead, so this callback object is no longer needed.
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ public struct WorldLocation : IPoint3D, IComparable<WorldLocation>, IEquatable<W
|
|||
{
|
||||
|
||||
int charsWritten;
|
||||
char[] array = ArrayPool<char>.Shared.Rent(128);
|
||||
Span<char> span = array.AsSpan();
|
||||
var array = ArrayPool<char>.Shared.Rent(128);
|
||||
var span = array.AsSpan();
|
||||
while (!TryFormat(span, out charsWritten, null, null))
|
||||
{
|
||||
array = ArrayPool<char>.Shared.Rent(array.Length * 2);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public abstract class BaseGuild : ISerializable
|
|||
{
|
||||
var name = g.Name;
|
||||
|
||||
bool all = true;
|
||||
var all = true;
|
||||
foreach (var t in words)
|
||||
{
|
||||
if (name.InsensitiveIndexOf(t) == -1)
|
||||
|
|
|
|||
|
|
@ -107,17 +107,17 @@ public abstract partial class BaseMulti : Item
|
|||
return false;
|
||||
}
|
||||
|
||||
int minX = Math.Max(bounds.X, Location.X + Components.Min.X);
|
||||
int maxX = Math.Min(bounds.X + bounds.Width, Location.X + Components.Max.X);
|
||||
int minY = Math.Max(bounds.Y, Location.Y + Components.Min.Y);
|
||||
int maxY = Math.Min(bounds.Y + bounds.Height, Location.Y + Components.Max.Y);
|
||||
var minX = Math.Max(bounds.X, Location.X + Components.Min.X);
|
||||
var maxX = Math.Min(bounds.X + bounds.Width, Location.X + Components.Max.X);
|
||||
var minY = Math.Max(bounds.Y, Location.Y + Components.Min.Y);
|
||||
var maxY = Math.Min(bounds.Y + bounds.Height, Location.Y + Components.Max.Y);
|
||||
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
for (var x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
for (var y = minY; y <= maxY; y++)
|
||||
{
|
||||
int offsetX = x - Location.X - Components.Min.X;
|
||||
int offsetY = y - Location.Y - Components.Min.Y;
|
||||
var offsetX = x - Location.X - Components.Min.X;
|
||||
var offsetY = y - Location.Y - Components.Min.Y;
|
||||
|
||||
if (offsetX < 0 || offsetY < 0 || offsetX >= Components.Width || offsetY >= Components.Height)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ public partial class Item
|
|||
|
||||
while (_index < _items.Length)
|
||||
{
|
||||
Item item = _items[_index++];
|
||||
var item = _items[_index++];
|
||||
if (_recurse && item.LookupItems() is { Count: > 0 } items)
|
||||
{
|
||||
_containers.Enqueue(item);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public class BounceInfo
|
|||
var loc = reader.ReadPoint3D();
|
||||
var worldLoc = reader.ReadPoint3D();
|
||||
|
||||
IEntity parent = reader.ReadEntity<IEntity>();
|
||||
var parent = reader.ReadEntity<IEntity>();
|
||||
|
||||
return new BounceInfo(map, loc, worldLoc, parent);
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
{
|
||||
var worldLoc = GetWorldLocation();
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -1139,9 +1139,9 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
|
||||
if (m_Map != null)
|
||||
{
|
||||
Span<byte> oldWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
Span<byte> saWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
Span<byte> hsWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
var oldWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
var saWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
var hsWorldItem = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -1194,7 +1194,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
{
|
||||
if (oldLocation.m_X != 0)
|
||||
{
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -1522,7 +1522,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
{
|
||||
if (m_Location.m_X != 0)
|
||||
{
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -2663,7 +2663,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent))
|
||||
{
|
||||
Serial parent = reader.ReadSerial();
|
||||
var parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
@ -2824,7 +2824,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent))
|
||||
{
|
||||
Serial parent = reader.ReadSerial();
|
||||
var parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
@ -2942,7 +2942,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
AcquireCompactInfo().m_Name = name;
|
||||
}
|
||||
|
||||
Serial parent = reader.ReadSerial();
|
||||
var parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
@ -3296,7 +3296,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
|
||||
var worldLoc = GetWorldLocation();
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -3327,7 +3327,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
|
||||
var worldLoc = GetWorldLocation();
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
@ -3820,7 +3820,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public static class OutgoingVirtualHairPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[EquipUpdatePacketLength].InitializePacket();
|
||||
CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ public static class OutgoingVirtualHairPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[RemovePacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[RemovePacketLength].InitializePacket();
|
||||
CreateRemoveHairPacket(buffer, hairSerial);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class RegionByNameConverter : JsonConverter<Region>
|
|||
throw new JsonException("Invalid json for RegionByName");
|
||||
}
|
||||
|
||||
string property = reader.GetString()?.ToLower();
|
||||
var property = reader.GetString()?.ToLower();
|
||||
|
||||
if (property != "name" && property != "map")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public static class JsonUtilities
|
|||
{
|
||||
public static string SortByPropertyName(string jsonStr)
|
||||
{
|
||||
using JsonDocument doc = JsonDocument.Parse(jsonStr);
|
||||
using var doc = JsonDocument.Parse(jsonStr);
|
||||
return SortByPropertyName(doc.RootElement);
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public static class JsonUtilities
|
|||
{
|
||||
// TODO: Better way to do this than a stream?
|
||||
using var ms = new MemoryStream();
|
||||
JsonWriterOptions opts = new JsonWriterOptions
|
||||
var opts = new JsonWriterOptions
|
||||
{
|
||||
Indented = true,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
|
|
@ -58,7 +58,7 @@ public static class JsonUtilities
|
|||
writer.WriteStartObject();
|
||||
|
||||
// TODO: This is slow, can make it faster?
|
||||
foreach (JsonProperty x in je.EnumerateObject().OrderBy(prop => prop.Name))
|
||||
foreach (var x in je.EnumerateObject().OrderBy(prop => prop.Name))
|
||||
{
|
||||
writer.WritePropertyName(x.Name);
|
||||
WriteJsonElementSorted(x.Value, writer);
|
||||
|
|
@ -70,7 +70,7 @@ public static class JsonUtilities
|
|||
case JsonValueKind.Array:
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
foreach(JsonElement x in je.EnumerateArray())
|
||||
foreach(var x in je.EnumerateArray())
|
||||
{
|
||||
WriteJsonElementSorted(x, writer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public static class Localization
|
|||
private static Dictionary<int, LocalizationEntry> LoadClilocs(string lang, string file)
|
||||
{
|
||||
lang = lang?.ToLower() ?? FallbackLanguage;
|
||||
Dictionary<int, LocalizationEntry> entries = _localizations[lang] = new Dictionary<int, LocalizationEntry>();
|
||||
var entries = _localizations[lang] = new Dictionary<int, LocalizationEntry>();
|
||||
if (lang == FallbackLanguage)
|
||||
{
|
||||
_fallbackEntries = entries;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class LocalizationEntry
|
|||
var sb = ValueStringBuilder.Create(256);
|
||||
using var queue = PooledRefQueue<string>.Create();
|
||||
|
||||
bool hasMatch = false;
|
||||
var hasMatch = false;
|
||||
var prevIndex = 0;
|
||||
foreach (Match match in _textRegex.Matches(text))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -464,11 +464,11 @@ public static class Core
|
|||
#endif
|
||||
|
||||
var cycleCount = _cyclesPerSecond.Length;
|
||||
long last = _tickCount;
|
||||
var last = _tickCount;
|
||||
const int interval = 100;
|
||||
double frequency = Stopwatch.Frequency * interval;
|
||||
|
||||
int sample = 0;
|
||||
var sample = 0;
|
||||
|
||||
while (!Closing)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public partial class Map
|
|||
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
|
||||
}
|
||||
|
||||
NetState current = _current;
|
||||
var current = _current;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -236,8 +236,8 @@ public partial class Map
|
|||
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
|
||||
}
|
||||
|
||||
NetState current = _current;
|
||||
ref Rectangle2D bounds = ref _bounds;
|
||||
var current = _current;
|
||||
ref var bounds = ref _bounds;
|
||||
var currentSectorX = _currentSectorX;
|
||||
var currentSectorY = _currentSectorY;
|
||||
var sectorEndX = _sectorEndX;
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ public partial class Map
|
|||
}
|
||||
|
||||
Item current = _current;
|
||||
ref Rectangle2D bounds = ref _bounds;
|
||||
ref var bounds = ref _bounds;
|
||||
var currentSectorX = _currentSectorX;
|
||||
var currentSectorY = _currentSectorY;
|
||||
var sectorEndX = _sectorEndX;
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ public partial class Map
|
|||
}
|
||||
|
||||
Mobile current = _current;
|
||||
ref Rectangle2D bounds = ref _bounds;
|
||||
ref var bounds = ref _bounds;
|
||||
var currentSectorX = _currentSectorX;
|
||||
var currentSectorY = _currentSectorY;
|
||||
var sectorEndX = _sectorEndX;
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ public partial class Map
|
|||
return false;
|
||||
}
|
||||
|
||||
ref Rectangle2D bounds = ref _bounds;
|
||||
ref var bounds = ref _bounds;
|
||||
var currentSectorX = _currentSectorX;
|
||||
var currentSectorY = _currentSectorY;
|
||||
var sectorEndX = _sectorEndX;
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ public partial class Map
|
|||
var components = multi!.Components;
|
||||
var location = multi!.Location;
|
||||
|
||||
int offsetX = p.X - location.X - components.Min.X;
|
||||
int offsetY = p.Y - location.Y - components.Min.Y;
|
||||
var offsetX = p.X - location.X - components.Min.X;
|
||||
var offsetY = p.Y - location.Y - components.Min.Y;
|
||||
|
||||
if (offsetX >= 0 && offsetY >= 0 && offsetX < components.Width && offsetY < components.Height)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -494,10 +494,10 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
|||
out int sectorStartX, out int sectorStartY,
|
||||
out int sectorEndX, out int sectorEndY)
|
||||
{
|
||||
int left = bounds.Start.X;
|
||||
int top = bounds.Start.Y;
|
||||
int right = bounds.End.X;
|
||||
int bottom = bounds.End.Y;
|
||||
var left = bounds.Start.X;
|
||||
var top = bounds.Start.Y;
|
||||
var right = bounds.End.X;
|
||||
var bottom = bounds.End.Y;
|
||||
|
||||
// Limit the coordinates to inside the valid map region
|
||||
Bound(left, top, out left, out top);
|
||||
|
|
@ -1070,7 +1070,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
|||
contains = ltID == InvalidLandTiles[j];
|
||||
}
|
||||
|
||||
bool foundStatic = false;
|
||||
var foundStatic = false;
|
||||
|
||||
foreach (var t in Tiles.GetStaticAndMultiTiles(point.X, point.Y))
|
||||
{
|
||||
|
|
@ -1094,7 +1094,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
|||
|
||||
if (contains && !foundStatic)
|
||||
{
|
||||
foreach (Item item in GetItemsAt(point))
|
||||
foreach (var item in GetItemsAt(point))
|
||||
{
|
||||
if (item.Visible)
|
||||
{
|
||||
|
|
@ -1289,7 +1289,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
|||
return Internal;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Maps.Length; i++)
|
||||
for (var i = 0; i < Maps.Length; i++)
|
||||
{
|
||||
var map = Maps[i];
|
||||
if (map == null)
|
||||
|
|
@ -1332,7 +1332,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
|||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Maps.Length; i++)
|
||||
for (var i = 0; i < Maps.Length; i++)
|
||||
{
|
||||
var map = Maps[i];
|
||||
if (map == null)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public static class MapSelection
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
MapSelectionFlags[] localList = _allMaps;
|
||||
var localList = _allMaps;
|
||||
|
||||
while ((uint)_index < (uint)localList.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2726,18 +2726,18 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> hairPacket = stackalloc byte[hairLength].InitializePacket();
|
||||
var hairPacket = stackalloc byte[hairLength].InitializePacket();
|
||||
|
||||
var facialHairSerial = FacialHair.VirtualSerial;
|
||||
var facialHairLength = removeFacialHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> facialHairPacket = stackalloc byte[facialHairLength].InitializePacket();
|
||||
var facialHairPacket = stackalloc byte[facialHairLength].InitializePacket();
|
||||
|
||||
const int cacheLength = OutgoingMobilePackets.MobileMovingPacketCacheByteLength;
|
||||
|
||||
Span<byte> mobileMovingCache = stackalloc byte[cacheLength].InitializePacket();
|
||||
var mobileMovingCache = stackalloc byte[cacheLength].InitializePacket();
|
||||
|
||||
var ourState = m_NetState;
|
||||
|
||||
|
|
@ -2879,13 +2879,13 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> statBufferTrue = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
Span<byte> statBufferFalse = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
Span<byte> hbpBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
Span<byte> hbyBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
Span<byte> deadBuffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength].InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
Span<byte> hitsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
|
||||
var statBufferTrue = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
var statBufferFalse = stackalloc byte[OutgoingMobilePackets.MobileStatusCompactLength].InitializePacket();
|
||||
var hbpBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
var hbyBuffer = stackalloc byte[OutgoingMobilePackets.MobileHealthbarPacketLength].InitializePacket();
|
||||
var deadBuffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var hitsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
|
||||
mobileMovingCache.InitializePacket();
|
||||
|
||||
foreach (var state in Map.GetClientsInRange(m_Location))
|
||||
|
|
@ -3288,7 +3288,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
var hasTitle = PropertyTitle && !string.IsNullOrEmpty(Title);
|
||||
var hasGuild = guild != null && (m_Player || m_DisplayGuildTitle);
|
||||
|
||||
string suffix = hasTitle switch
|
||||
var suffix = hasTitle switch
|
||||
{
|
||||
true when hasGuild => $" {Title} [{guild.Abbreviation.FixHtmlFormattable()}]",
|
||||
true => $" {Title}",
|
||||
|
|
@ -4759,8 +4759,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
{
|
||||
var corpseSerial = c?.Serial ?? Serial.Zero;
|
||||
|
||||
Span<byte> deathAnimation = stackalloc byte[OutgoingMobilePackets.DeathAnimationPacketLength].InitializePacket();
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var deathAnimation = stackalloc byte[OutgoingMobilePackets.DeathAnimationPacketLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -5049,7 +5049,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
{
|
||||
var rootItem = root as Item;
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength]
|
||||
var buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength]
|
||||
.InitializePacket();
|
||||
|
||||
foreach (var ns in map.GetClientsInRange(from.Location))
|
||||
|
|
@ -5205,7 +5205,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
|
||||
foreach (var ns in map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -5352,7 +5352,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
|
||||
var length = text.Length;
|
||||
char[] rentedChars = null;
|
||||
Span<char> chars = length <= 256
|
||||
var chars = length <= 256
|
||||
? stackalloc char[length]
|
||||
: rentedChars = STArrayPool<char>.Shared.Rent(length);
|
||||
|
||||
|
|
@ -5565,8 +5565,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
|
||||
ProcessDelta();
|
||||
|
||||
Span<byte> regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
Span<byte> mutBuffer =
|
||||
var regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
var mutBuffer =
|
||||
stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
|
||||
// TODO: Should this be sorted like onSpeech is below?
|
||||
|
|
@ -6658,7 +6658,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
|
||||
ProcessDelta();
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMobilePackets.MobileAnimationPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMobilePackets.MobileAnimationPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -6735,7 +6735,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -6785,7 +6785,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -7015,7 +7015,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -7238,7 +7238,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (map != null)
|
||||
{
|
||||
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
var removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
|
||||
foreach (var ns in map.GetClientsInRange(oldLocation))
|
||||
{
|
||||
|
|
@ -8795,7 +8795,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -8835,7 +8835,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -8874,7 +8874,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)]
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)]
|
||||
.InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
|
|
@ -8933,7 +8933,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
@ -8968,7 +8968,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
|
||||
foreach (var state in m_Map.GetClientsInRange(m_Location))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public static class MultiData
|
|||
// TODO: Find out if housing.bin is needed and read that.
|
||||
var uopEntries = UOPFiles.ReadUOPIndexes(stream, ".bin", 0x10000, 4, 6);
|
||||
|
||||
byte[] compressionBuffer = STArrayPool<byte>.Shared.Rent(0x10000);
|
||||
var compressionBuffer = STArrayPool<byte>.Shared.Rent(0x10000);
|
||||
var buffer = STArrayPool<byte>.Shared.Rent(0x10000);
|
||||
|
||||
foreach (var (i, entry) in uopEntries)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class CidrFirewallEntry : BaseFirewallEntry
|
|||
|
||||
private static IPAddress ParseIPAddress(ReadOnlySpan<char> ipString, out int prefixLength)
|
||||
{
|
||||
int slashIndex = ipString.IndexOf('/');
|
||||
var slashIndex = ipString.IndexOf('/');
|
||||
var ipAddress = IPAddress.Parse(slashIndex > -1 ? ipString[..slashIndex] : ipString);
|
||||
var maxPrefixLength = ipAddress.AddressFamily == AddressFamily.InterNetworkV6 ? 128 : 32;
|
||||
|
||||
|
|
|
|||
|
|
@ -136,10 +136,10 @@ public class IPRateLimiter
|
|||
{
|
||||
await _cleanupSignal.WaitAsync(_cts.Token);
|
||||
|
||||
int maxToProcess = Math.Min(_cleanupQueue.Count, 500);
|
||||
var maxToProcess = Math.Min(_cleanupQueue.Count, 500);
|
||||
var nowTicks = Core.TickCount;
|
||||
|
||||
for (int i = 0; i < maxToProcess; i++)
|
||||
for (var i = 0; i < maxToProcess; i++)
|
||||
{
|
||||
if (!_cts.IsCancellationRequested)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ public static class MovementThrottle
|
|||
return false;
|
||||
}
|
||||
|
||||
long now = Core.TickCount;
|
||||
long credit = ns._movementCredit;
|
||||
long nextMove = ns._nextMovementTime;
|
||||
var now = Core.TickCount;
|
||||
var credit = ns._movementCredit;
|
||||
var nextMove = ns._nextMovementTime;
|
||||
|
||||
// Reset system if idle for more than 1 second
|
||||
if (now - nextMove + _movementThrottleReset > 0)
|
||||
|
|
@ -54,7 +54,7 @@ public static class MovementThrottle
|
|||
return false;
|
||||
}
|
||||
|
||||
long cost = nextMove - now;
|
||||
var cost = nextMove - now;
|
||||
|
||||
if (credit < cost)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -278,9 +278,9 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _packetCounts.Length; i++)
|
||||
for (var i = 0; i < _packetCounts.Length; i++)
|
||||
{
|
||||
long count = _packetCounts[i];
|
||||
var count = _packetCounts[i];
|
||||
_packetCounts[i] = 0;
|
||||
|
||||
if (count > PacketPerSecondThreshold)
|
||||
|
|
@ -583,7 +583,7 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
|
||||
var packetReader = new SpanReader(buffer);
|
||||
var packetId = packetReader.ReadByte();
|
||||
int packetLength = length;
|
||||
var packetLength = length;
|
||||
|
||||
// These can arrive at any time and are only informational
|
||||
if (_protocolState != ProtocolState.AwaitingSeed && IncomingPackets.IsInfoPacket(packetId))
|
||||
|
|
@ -608,7 +608,7 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
}
|
||||
else if (length >= 4)
|
||||
{
|
||||
int newSeed = (packetId << 24) | (packetReader.ReadByte() << 16) | (packetReader.ReadByte() << 8) | packetReader.ReadByte();
|
||||
var newSeed = (packetId << 24) | (packetReader.ReadByte() << 16) | (packetReader.ReadByte() << 8) | packetReader.ReadByte();
|
||||
|
||||
if (newSeed == 0)
|
||||
{
|
||||
|
|
@ -763,8 +763,8 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
*/
|
||||
private unsafe ParserState HandlePacket(SpanReader packetReader, byte packetId, out int packetLength)
|
||||
{
|
||||
PacketHandler handler = IncomingPackets.GetHandler(packetId);
|
||||
int length = packetReader.Length;
|
||||
var handler = IncomingPackets.GetHandler(packetId);
|
||||
var length = packetReader.Length;
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
|
|
@ -999,7 +999,7 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
|
||||
if (count > 0)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
(_polledStates[i].Target as NetState)?.HandleReceive();
|
||||
_polledStates[i] = default;
|
||||
|
|
@ -1050,7 +1050,7 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
{
|
||||
try
|
||||
{
|
||||
long curTicks = Core.TickCount;
|
||||
var curTicks = Core.TickCount;
|
||||
|
||||
foreach (var ns in Instances)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -67,15 +67,15 @@ public static class NetworkCompression
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bitCount = 0;
|
||||
int bitValue = 0;
|
||||
var bitCount = 0;
|
||||
var bitValue = 0;
|
||||
|
||||
int inputIdx = 0;
|
||||
int outputIdx = 0;
|
||||
var inputIdx = 0;
|
||||
var outputIdx = 0;
|
||||
|
||||
while (inputIdx < input.Length)
|
||||
{
|
||||
int i = input[inputIdx++] << 1;
|
||||
var i = input[inputIdx++] << 1;
|
||||
|
||||
bitCount += _huffmanTable[i];
|
||||
bitValue = (bitValue << _huffmanTable[i]) | _huffmanTable[i + 1];
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public static class OutgoingAccountPackets
|
|||
writer.Write((ushort)length);
|
||||
writer.Write((ushort)0); // Count & Placeholder
|
||||
|
||||
int count = 0;
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < a.Length; ++i)
|
||||
{
|
||||
|
|
@ -265,7 +265,7 @@ public static class OutgoingAccountPackets
|
|||
|
||||
writer.Write((byte)count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var m = a[i];
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ public static class OutgoingAccountPackets
|
|||
writer.Write((ushort)length);
|
||||
writer.Write((byte)count); // TODO: It is probably more proper to use count.
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var m = acct[i];
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ public static class OutgoingAccountPackets
|
|||
|
||||
writer.Write((byte)cityInfo.Length);
|
||||
|
||||
for (int i = 0; i < cityInfo.Length; ++i)
|
||||
for (var i = 0; i < cityInfo.Length; ++i)
|
||||
{
|
||||
var ci = cityInfo[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public static class OutgoingEffectPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[SoundPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[SoundPacketLength].InitializePacket();
|
||||
CreateSoundEffect(buffer, soundID, target);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public static class OutgoingEntityPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OPLPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OPLPacketLength].InitializePacket();
|
||||
CreateOPLInfo(buffer, serial, hash);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
@ -79,7 +79,7 @@ public static class OutgoingEntityPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[RemoveEntityLength].InitializePacket();
|
||||
var buffer = stackalloc byte[RemoveEntityLength].InitializePacket();
|
||||
CreateRemoveEntity(buffer, serial);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
@ -96,12 +96,12 @@ public static class OutgoingEntityPackets
|
|||
writer.Write((byte)0xF3); // Packet ID
|
||||
writer.Write((short)0x1); // command
|
||||
|
||||
int type = 0;
|
||||
int gfx = 0;
|
||||
int amount = 1;
|
||||
int hue = 0;
|
||||
var type = 0;
|
||||
var gfx = 0;
|
||||
var amount = 1;
|
||||
var hue = 0;
|
||||
byte light = 0;
|
||||
int flags = 0;
|
||||
var flags = 0;
|
||||
|
||||
if (entity is BaseMulti multi)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public static class OutgoingItemPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
|
||||
var length = ns.StygianAbyss ?
|
||||
OutgoingEntityPackets.CreateWorldEntity(buffer, item, ns.HighSeas) :
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public static class OutgoingMapPackets
|
|||
writer.Write((ushort)0x18); // Subpacket
|
||||
writer.Write(4);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var map = Map.Maps[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public static class OutgoingMenuPackets
|
|||
int entriesLength = (byte)entries.Length;
|
||||
|
||||
var maxLength = 11 + questionLength;
|
||||
for (int i = 0; i < entriesLength; i++)
|
||||
for (var i = 0; i < entriesLength; i++)
|
||||
{
|
||||
maxLength += 5 + entries[i].Name?.Length ?? 0; // could be trimmed
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ public static class OutgoingMenuPackets
|
|||
int answersLength = (byte)answers.Length;
|
||||
|
||||
var maxLength = 11 + questionLength;
|
||||
for (int i = 0; i < answersLength; i++)
|
||||
for (var i = 0; i < answersLength; i++)
|
||||
{
|
||||
maxLength += 5 + answers[i]?.Length ?? 0; // could be trimmed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public static class OutgoingMessagePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
var buffer = stackalloc byte[GetMaxMessageLocalizedLength(args)].InitializePacket();
|
||||
var length = CreateMessageLocalized(
|
||||
buffer, serial, graphic, type, hue, font, number, name, args
|
||||
);
|
||||
|
|
@ -97,7 +97,7 @@ public static class OutgoingMessagePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket();
|
||||
var buffer = stackalloc byte[GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket();
|
||||
var length = CreateMessageLocalizedAffix(
|
||||
buffer, serial, graphic, type, hue, font, number, name, affixType, affix, args
|
||||
);
|
||||
|
|
@ -157,7 +157,7 @@ public static class OutgoingMessagePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[GetMaxMessageLength(text)].InitializePacket();
|
||||
var buffer = stackalloc byte[GetMaxMessageLength(text)].InitializePacket();
|
||||
var length = CreateMessage(
|
||||
buffer,
|
||||
serial,
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[DeathAnimationPacketLength].InitializePacket();
|
||||
var span = stackalloc byte[DeathAnimationPacketLength].InitializePacket();
|
||||
CreateDeathAnimation(span, killed, corpse);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[MobileMovingPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[MobileMovingPacketLength].InitializePacket();
|
||||
var packetFlags = (byte)target.GetPacketFlags(ns.StygianAbyss);
|
||||
CreateMobileMoving(buffer, target, noto, packetFlags);
|
||||
ns.Send(buffer);
|
||||
|
|
@ -202,7 +202,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
CreateMobileHits(span, m, normalize);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
CreateMobileMana(span, m, normalize);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
|
||||
CreateMobileStam(span, m, normalize);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileAttributesPacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileAttributesPacketLength].InitializePacket();
|
||||
CreateMobileAttributes(span, m, normalize);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileAnimationPacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileAnimationPacketLength].InitializePacket();
|
||||
CreateMobileAnimation(span, mobile, action, frameCount, repeatCount, forward, repeat, delay);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[NewMobileAnimationPacketLength].InitializePacket();
|
||||
var span = stackalloc byte[NewMobileAnimationPacketLength].InitializePacket();
|
||||
CreateNewMobileAnimation(span, mobile, action, frameCount, delay);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileHealthbarPacketLength].InitializePacket();
|
||||
var span = stackalloc byte[MobileHealthbarPacketLength].InitializePacket();
|
||||
CreateMobileHealthbar(span, m, healthbar);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
|
@ -438,7 +438,7 @@ public static class OutgoingMobilePackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[MobileStatusCompactLength].InitializePacket();
|
||||
var buffer = stackalloc byte[MobileStatusCompactLength].InitializePacket();
|
||||
CreateMobileStatusCompact(buffer, m, canBeRenamed);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
@ -489,7 +489,7 @@ public static class OutgoingMobilePackets
|
|||
}
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[length].InitializePacket();
|
||||
var buffer = stackalloc byte[length].InitializePacket();
|
||||
CreateMobileStatus(buffer, beheld, version, beheld.CanBeRenamedBy(beholder));
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ public static class OutgoingPlayerPackets
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[DragEffectPacketLength].InitializePacket();
|
||||
var buffer = stackalloc byte[DragEffectPacketLength].InitializePacket();
|
||||
CreateDragEffect(buffer, srcSerial, srcLocation, trgSerial, trgLocation, itemID, hue, amount);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public static class OutgoingVendorBuyPackets
|
|||
}
|
||||
|
||||
var length = 8;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
length += 6 + list[i].Description?.Length ?? 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,11 +89,11 @@ public ref struct PacketContainerBuilder
|
|||
private void Grow(int additionalCapacityBeyondPos)
|
||||
{
|
||||
var newLength = Math.Max(Length + additionalCapacityBeyondPos, _bytes.Length * 2);
|
||||
byte[] poolArray = STArrayPool<byte>.Shared.Rent(newLength);
|
||||
var poolArray = STArrayPool<byte>.Shared.Rent(newLength);
|
||||
|
||||
_bytes[..Length].CopyTo(poolArray);
|
||||
|
||||
byte[] toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
_bytes = _arrayToReturnToPool = poolArray;
|
||||
if (toReturn != null)
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ public ref struct PacketContainerBuilder
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
byte[] toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
this = default; // for safety, to avoid using pooled array if this instance is erroneously appended to again
|
||||
if (toReturn != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
|
||||
public void Terminate()
|
||||
{
|
||||
int length = _bufferPos + 4;
|
||||
var length = _bufferPos + 4;
|
||||
if (length != _buffer.Length)
|
||||
{
|
||||
Resize(length);
|
||||
|
|
@ -135,7 +135,7 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
|
||||
AddHash(number);
|
||||
|
||||
int length = _bufferPos + 6;
|
||||
var length = _bufferPos + 6;
|
||||
while (length > _buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
|
|
@ -188,8 +188,8 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
AddHash(number);
|
||||
AddHash(string.GetHashCode(chars, StringComparison.Ordinal));
|
||||
|
||||
int strLength = chars.Length * 2;
|
||||
int length = _bufferPos + 6 + strLength;
|
||||
var strLength = chars.Length * 2;
|
||||
var length = _bufferPos + 6 + strLength;
|
||||
while (length > _buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
|
|
@ -219,8 +219,8 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
{
|
||||
if (value.Length == 1)
|
||||
{
|
||||
Span<char> chars = _arrayToReturnToPool.AsSpan();
|
||||
int pos = _pos;
|
||||
var chars = _arrayToReturnToPool.AsSpan();
|
||||
var pos = _pos;
|
||||
if ((uint)pos < (uint)chars.Length)
|
||||
{
|
||||
chars[pos] = value[0];
|
||||
|
|
@ -318,7 +318,7 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
|
||||
public void AppendFormatted<T>(T value, int alignment)
|
||||
{
|
||||
int startingPos = _pos;
|
||||
var startingPos = _pos;
|
||||
AppendFormatted(value);
|
||||
if (alignment != 0)
|
||||
{
|
||||
|
|
@ -328,7 +328,7 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
|
||||
public void AppendFormatted<T>(T value, int alignment, string? format)
|
||||
{
|
||||
int startingPos = _pos;
|
||||
var startingPos = _pos;
|
||||
AppendFormatted(value, format);
|
||||
if (alignment != 0)
|
||||
{
|
||||
|
|
@ -350,14 +350,14 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
|
||||
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
|
||||
{
|
||||
bool leftAlign = false;
|
||||
var leftAlign = false;
|
||||
if (alignment < 0)
|
||||
{
|
||||
leftAlign = true;
|
||||
alignment = -alignment;
|
||||
}
|
||||
|
||||
int paddingRequired = alignment - value.Length;
|
||||
var paddingRequired = alignment - value.Length;
|
||||
if (paddingRequired <= 0)
|
||||
{
|
||||
AppendFormatted(value);
|
||||
|
|
@ -416,16 +416,16 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
Debug.Assert(startingPos >= 0 && startingPos <= _pos);
|
||||
Debug.Assert(alignment != 0);
|
||||
|
||||
int charsWritten = _pos - startingPos;
|
||||
var charsWritten = _pos - startingPos;
|
||||
|
||||
bool leftAlign = false;
|
||||
var leftAlign = false;
|
||||
if (alignment < 0)
|
||||
{
|
||||
leftAlign = true;
|
||||
alignment = -alignment;
|
||||
}
|
||||
|
||||
int paddingNeeded = alignment - charsWritten;
|
||||
var paddingNeeded = alignment - charsWritten;
|
||||
if (paddingNeeded > 0)
|
||||
{
|
||||
EnsureCapacityForAdditionalChars(paddingNeeded);
|
||||
|
|
@ -486,13 +486,13 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void GrowCore(uint requiredMinCapacity)
|
||||
{
|
||||
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_arrayToReturnToPool.Length * 2, 0x3FFFFFDF));
|
||||
int arraySize = (int)Math.Clamp(newCapacity, 256, int.MaxValue);
|
||||
var newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_arrayToReturnToPool.Length * 2, 0x3FFFFFDF));
|
||||
var arraySize = (int)Math.Clamp(newCapacity, 256, int.MaxValue);
|
||||
|
||||
char[] newArray = STArrayPool<char>.Shared.Rent(arraySize);
|
||||
var newArray = STArrayPool<char>.Shared.Rent(arraySize);
|
||||
_arrayToReturnToPool.AsSpan(.._pos).CopyTo(newArray);
|
||||
|
||||
char[] toReturn = _arrayToReturnToPool;
|
||||
var toReturn = _arrayToReturnToPool;
|
||||
_arrayToReturnToPool = newArray;
|
||||
|
||||
STArrayPool<char>.Shared.Return(toReturn);
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ public static class StableRandom
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ulong NextUInt64(Span<ulong> state, ulong maxValue)
|
||||
{
|
||||
ulong randomProduct = Math.BigMul(maxValue, NextUInt64(ref state), out ulong lowPart);
|
||||
var randomProduct = Math.BigMul(maxValue, NextUInt64(ref state), out var lowPart);
|
||||
|
||||
if (lowPart < maxValue)
|
||||
{
|
||||
ulong remainder = (0ul - maxValue) % maxValue;
|
||||
var remainder = (0ul - maxValue) % maxValue;
|
||||
|
||||
while (lowPart < remainder)
|
||||
{
|
||||
|
|
@ -56,8 +56,8 @@ public static class StableRandom
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ulong NextUInt64(ref Span<ulong> state)
|
||||
{
|
||||
ulong result = BitOperations.RotateLeft(state[1] * 5, 7) * 9;
|
||||
ulong t = state[1] << 17;
|
||||
var result = BitOperations.RotateLeft(state[1] * 5, 7) * 9;
|
||||
var t = state[1] << 17;
|
||||
|
||||
state[2] ^= state[0];
|
||||
state[3] ^= state[1];
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public static class AdhocPersistence
|
|||
|
||||
byte* ptr = null;
|
||||
accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
|
||||
UnmanagedDataReader dataReader = new UnmanagedDataReader(ptr, accessor.Length);
|
||||
var dataReader = new UnmanagedDataReader(ptr, accessor.Length);
|
||||
deserializer(dataReader);
|
||||
|
||||
error = dataReader.Position != fileLength
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
*/
|
||||
private unsafe Dictionary<ulong, ConstructorInfo> ReadTypes(string savePath)
|
||||
{
|
||||
string typesPath = Path.Combine(savePath, Name, $"{Name}.tdb");
|
||||
var typesPath = Path.Combine(savePath, Name, $"{Name}.tdb");
|
||||
if (!File.Exists(typesPath))
|
||||
{
|
||||
return [];
|
||||
|
|
@ -209,7 +209,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
|
||||
public virtual void DeserializeIndexes(string savePath, Dictionary<ulong, string> typesDb)
|
||||
{
|
||||
string indexPath = Path.Combine(savePath, Name, $"{Name}.idx");
|
||||
var indexPath = Path.Combine(savePath, Name, $"{Name}.idx");
|
||||
|
||||
_entities ??= [];
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
ctors[hash] = ctor = GetConstructorFor(typeName, AssemblyHandler.FindTypeByHash(hash), ctorArguments);
|
||||
}
|
||||
|
||||
Serial serial = (Serial)dataReader.ReadUInt();
|
||||
var serial = (Serial)dataReader.ReadUInt();
|
||||
var created = version == 0 ? now : new DateTime(dataReader.ReadLong(), DateTimeKind.Utc);
|
||||
if (version is > 0 and < 3)
|
||||
{
|
||||
|
|
@ -330,7 +330,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
|
||||
public override void Deserialize(string savePath, Dictionary<ulong, string> typesDb)
|
||||
{
|
||||
string dataPath = Path.Combine(savePath, Name, $"{Name}.bin");
|
||||
var dataPath = Path.Combine(savePath, Name, $"{Name}.bin");
|
||||
var fi = new FileInfo(dataPath);
|
||||
|
||||
if (!fi.Exists)
|
||||
|
|
@ -354,7 +354,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
|
||||
byte* ptr = null;
|
||||
accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
|
||||
UnmanagedDataReader dataReader = new UnmanagedDataReader(ptr, accessor.Length, typesDb);
|
||||
var dataReader = new UnmanagedDataReader(ptr, accessor.Length, typesDb);
|
||||
|
||||
Deserialize(dataReader);
|
||||
|
||||
|
|
@ -362,7 +362,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
|
||||
foreach (var entry in _entities[index])
|
||||
{
|
||||
T t = entry.Entity;
|
||||
var t = entry.Entity;
|
||||
|
||||
if (entry.Length == 0)
|
||||
{
|
||||
|
|
@ -527,7 +527,7 @@ public class GenericEntityPersistence<T> : GenericPersistence, IGenericEntityPer
|
|||
case WorldState.PendingSave:
|
||||
case WorldState.Running:
|
||||
{
|
||||
ref var entityEntry = ref CollectionsMarshal.GetValueRefOrAddDefault(EntitiesBySerial, entity.Serial, out bool exists);
|
||||
ref var entityEntry = ref CollectionsMarshal.GetValueRefOrAddDefault(EntitiesBySerial, entity.Serial, out var exists);
|
||||
if (exists)
|
||||
{
|
||||
if (entityEntry == entity)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public interface IGenericReader
|
|||
}
|
||||
IPAddress ReadIPAddress()
|
||||
{
|
||||
byte length = ReadByte();
|
||||
var length = ReadByte();
|
||||
// Either 2 ushorts, or 8 ushorts
|
||||
Span<byte> integer = stackalloc byte[length];
|
||||
Read(integer);
|
||||
|
|
@ -120,8 +120,8 @@ public interface IGenericReader
|
|||
|
||||
public BitArray ReadBitArray()
|
||||
{
|
||||
int bitLength = ReadEncodedInt();
|
||||
int byteLength = (bitLength + 7) / 8;
|
||||
var bitLength = ReadEncodedInt();
|
||||
var byteLength = (bitLength + 7) / 8;
|
||||
|
||||
var buffer = ArrayPool<byte>.Shared.Rent(byteLength);
|
||||
try
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ public interface IGenericWriter
|
|||
|
||||
public void Write(BitArray bitArray)
|
||||
{
|
||||
int bitLength = bitArray.Length;
|
||||
int byteLength = (bitLength + 7) / 8;
|
||||
var bitLength = bitArray.Length;
|
||||
var byteLength = (bitLength + 7) / 8;
|
||||
|
||||
WriteEncodedInt(bitLength);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public abstract class Persistence
|
|||
{
|
||||
var db = new Dictionary<ulong, string>();
|
||||
|
||||
string typesPath = Path.Combine(path, "SerializedTypes.db");
|
||||
var typesPath = Path.Combine(path, "SerializedTypes.db");
|
||||
if (!File.Exists(typesPath))
|
||||
{
|
||||
return db;
|
||||
|
|
@ -96,7 +96,7 @@ public abstract class Persistence
|
|||
|
||||
public static void WriteSerializedTypesSnapshot(string path, HashSet<Type> types)
|
||||
{
|
||||
string typesPath = Path.Combine(path, "SerializedTypes.db");
|
||||
var typesPath = Path.Combine(path, "SerializedTypes.db");
|
||||
using var fs = new FileStream(typesPath, FileMode.Create);
|
||||
using var writer = new MemoryMapFileWriter(fs, 1024 * 1024 * 4);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public static class SerializationExtensions
|
|||
|
||||
public static T ReadEntity<T>(this IGenericReader reader) where T : class, ISerializable
|
||||
{
|
||||
Serial serial = reader.ReadSerial();
|
||||
var serial = reader.ReadSerial();
|
||||
var typeT = typeof(T);
|
||||
|
||||
T entity;
|
||||
|
|
|
|||
|
|
@ -873,7 +873,7 @@ public class Skills
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
Skill[] localList = _skills;
|
||||
var localList = _skills;
|
||||
|
||||
while ((uint)_index < (uint)localList.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ public abstract class Target
|
|||
Mobile mobile = null;
|
||||
var isValidTargetType = true;
|
||||
|
||||
bool valid = targeted switch
|
||||
var valid = targeted switch
|
||||
{
|
||||
LandTarget landTarget => CanTarget(from, landTarget, ref loc, ref map),
|
||||
StaticTarget staticTarget => CanTarget(from, staticTarget, ref loc, ref map),
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public static class HexStringConverter
|
|||
var charsWritten = 0;
|
||||
fixed (char* resultP = result)
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
var resultP2 = (uint*)(resultP + charsWritten);
|
||||
*resultP2 = m_Lookup32Chars[bytes[i]];
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public static class StringHelpers
|
|||
return "";
|
||||
}
|
||||
|
||||
char[] chrs = STArrayPool<char>.Shared.Rent(a.Length);
|
||||
var chrs = STArrayPool<char>.Shared.Rent(a.Length);
|
||||
var span = chrs.AsSpan(0, a.Length);
|
||||
|
||||
a.Remove(b, comparison, span, out var size);
|
||||
|
|
@ -102,7 +102,7 @@ public static class StringHelpers
|
|||
return value;
|
||||
}
|
||||
|
||||
char[] chrs = STArrayPool<char>.Shared.Rent(value.Length);
|
||||
var chrs = STArrayPool<char>.Shared.Rent(value.Length);
|
||||
var span = chrs.AsSpan(0, value.Length);
|
||||
|
||||
var sliced = value.AsSpan();
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public static class TextEncoding
|
|||
var charCount = encoding.GetMaxCharCount(span.Length);
|
||||
|
||||
char[] rentedChars = null;
|
||||
Span<char> chars = charCount <= 256
|
||||
var chars = charCount <= 256
|
||||
? stackalloc char[charCount]
|
||||
: rentedChars = STArrayPool<char>.Shared.Rent(charCount);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public partial class Timer
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
{
|
||||
DelayCallTimer t = new DelayCallTimer(delay, interval, count, callback);
|
||||
var t = new DelayCallTimer(delay, interval, count, callback);
|
||||
t.Start();
|
||||
#if DEBUG_TIMERS
|
||||
t._allowFinalization = true;
|
||||
|
|
@ -70,7 +70,7 @@ public partial class Timer
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
{
|
||||
DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
var t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
t._returnOnDetach = true;
|
||||
t.Start();
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ public partial class Timer
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, out TimerExecutionToken token)
|
||||
{
|
||||
DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
var t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
t.Start();
|
||||
|
||||
#if DEBUG_TIMERS
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public partial class Timer
|
|||
{
|
||||
_lastTickTurned = tickCount;
|
||||
|
||||
for (int i = 0; i < _rings.Length; i++)
|
||||
for (var i = 0; i < _rings.Length; i++)
|
||||
{
|
||||
_rings[i] = new Timer[_ringSize];
|
||||
_ringIndexes[i] = 0;
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ public static class ActivatorExtensions
|
|||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < ctors.Length; i++)
|
||||
for (var i = 0; i < ctors.Length; i++)
|
||||
{
|
||||
ConstructorInfo info = ctors[i];
|
||||
var info = ctors[i];
|
||||
|
||||
if (predicate?.Invoke(info) == false)
|
||||
{
|
||||
|
|
@ -62,12 +62,12 @@ public static class ActivatorExtensions
|
|||
continue;
|
||||
}
|
||||
|
||||
bool validated = true;
|
||||
var validated = true;
|
||||
|
||||
// Check that all args match params
|
||||
for (var j = 0; j < parameters.Length; j++)
|
||||
{
|
||||
ParameterInfo param = parameters[j];
|
||||
var param = parameters[j];
|
||||
|
||||
// All extra parameters must be optional
|
||||
if (j >= args.Length)
|
||||
|
|
@ -124,7 +124,7 @@ public static class ActivatorExtensions
|
|||
var argLength = args?.Length ?? 0;
|
||||
|
||||
var types = argLength > 0 ? new Type[argLength] : [];
|
||||
for (int i = 0; i < types.Length; i++)
|
||||
for (var i = 0; i < types.Length; i++)
|
||||
{
|
||||
types[i] = args![i]?.GetType();
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ public static class ActivatorExtensions
|
|||
else
|
||||
{
|
||||
paramArgs = new object[paramCount];
|
||||
for (int i = 0; i < paramCount; i++)
|
||||
for (var i = 0; i < paramCount; i++)
|
||||
{
|
||||
paramArgs[i] = i < argLength ? args![i] : Type.Missing;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ public static class HashUtility
|
|||
fixed (char* src = &str.GetPinnableReference())
|
||||
{
|
||||
uint hash1 = (5381 << 16) + 5381;
|
||||
uint hash2 = hash1;
|
||||
var hash2 = hash1;
|
||||
|
||||
uint* ptr = (uint*)src;
|
||||
int length = str.Length;
|
||||
var ptr = (uint*)src;
|
||||
var length = str.Length;
|
||||
|
||||
while (length > 2)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -167,14 +167,14 @@ public static class Html
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
int indexOfAny = input.IndexOfAny(_htmlSearchValues);
|
||||
var indexOfAny = input.IndexOfAny(_htmlSearchValues);
|
||||
if (indexOfAny < 0)
|
||||
{
|
||||
return input.ToString();
|
||||
}
|
||||
|
||||
using var builder = ValueStringBuilder.Create(input.Length * 2);
|
||||
int lastIndex = 0;
|
||||
var lastIndex = 0;
|
||||
|
||||
while (indexOfAny >= 0)
|
||||
{
|
||||
|
|
@ -183,7 +183,7 @@ public static class Html
|
|||
builder.Append(input[lastIndex..indexOfAny]);
|
||||
}
|
||||
|
||||
char c = input[indexOfAny];
|
||||
var c = input[indexOfAny];
|
||||
var replacement = c switch
|
||||
{
|
||||
'&' => "&",
|
||||
|
|
|
|||
|
|
@ -75,17 +75,17 @@ public static class PathUtility
|
|||
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
foreach (var file in dir.GetFiles())
|
||||
{
|
||||
string targetFilePath = Path.Combine(destDir, file.Name);
|
||||
var targetFilePath = Path.Combine(destDir, file.Name);
|
||||
file.CopyTo(targetFilePath, true);
|
||||
}
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (DirectoryInfo subdir in dir.GetDirectories())
|
||||
foreach (var subdir in dir.GetDirectories())
|
||||
{
|
||||
string destSubDir = Path.Combine(destDir, subdir.Name);
|
||||
var destSubDir = Path.Combine(destDir, subdir.Name);
|
||||
CopyDirectoryContents(subdir.FullName, destSubDir);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,16 +102,16 @@ public static class PathUtility
|
|||
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
foreach (var file in dir.GetFiles())
|
||||
{
|
||||
file.MoveTo(Path.Combine(destDir, file.Name));
|
||||
}
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (DirectoryInfo subdir in dir.GetDirectories())
|
||||
foreach (var subdir in dir.GetDirectories())
|
||||
{
|
||||
string destSubDir = Path.Combine(destDir, subdir.Name);
|
||||
var destSubDir = Path.Combine(destDir, subdir.Name);
|
||||
MoveDirectoryContents(subdir.FullName, destSubDir);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,16 +93,16 @@ public static partial class Utility
|
|||
|
||||
if (prefixLength < 64)
|
||||
{
|
||||
int bitsToFlip = 64 - prefixLength;
|
||||
ulong highMask = isMax ? ~0UL >> bitsToFlip : ~0UL << (bitsToFlip + 1);
|
||||
var bitsToFlip = 64 - prefixLength;
|
||||
var highMask = isMax ? ~0UL >> bitsToFlip : ~0UL << (bitsToFlip + 1);
|
||||
|
||||
high = isMax ? high | highMask : high & highMask;
|
||||
low = isMax ? ~0UL : 0UL;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bitsToFlip = 128 - prefixLength;
|
||||
ulong lowMask = isMax ? ~0UL >> (64 - bitsToFlip) : ~0UL << bitsToFlip;
|
||||
var bitsToFlip = 128 - prefixLength;
|
||||
var lowMask = isMax ? ~0UL >> (64 - bitsToFlip) : ~0UL << bitsToFlip;
|
||||
|
||||
low = isMax ? low | lowMask : low & lowMask;
|
||||
}
|
||||
|
|
@ -125,8 +125,8 @@ public static partial class Utility
|
|||
return 0;
|
||||
}
|
||||
|
||||
ulong high = BinaryPrimitives.ReadUInt64BigEndian(bytes[..8]);
|
||||
ulong low = BinaryPrimitives.ReadUInt64BigEndian(bytes.Slice(8, 8));
|
||||
var high = BinaryPrimitives.ReadUInt64BigEndian(bytes[..8]);
|
||||
var low = BinaryPrimitives.ReadUInt64BigEndian(bytes.Slice(8, 8));
|
||||
|
||||
return new UInt128(high, low);
|
||||
}
|
||||
|
|
@ -150,8 +150,8 @@ public static partial class Utility
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static UInt128 CreateCidrAddress(ReadOnlySpan<byte> bytes, int prefixLength, bool isMax)
|
||||
{
|
||||
ulong high = BinaryPrimitives.ReadUInt64BigEndian(bytes[..8]);
|
||||
ulong low = BinaryPrimitives.ReadUInt64BigEndian(bytes.Slice(8, 8));
|
||||
var high = BinaryPrimitives.ReadUInt64BigEndian(bytes[..8]);
|
||||
var low = BinaryPrimitives.ReadUInt64BigEndian(bytes.Slice(8, 8));
|
||||
|
||||
if (prefixLength < 128)
|
||||
{
|
||||
|
|
@ -588,7 +588,7 @@ public static partial class Utility
|
|||
while (amount > 0)
|
||||
{
|
||||
// Range is 2^amount exclusively, maximum of 62 bits can be used
|
||||
ulong num = amount >= 62
|
||||
var num = amount >= 62
|
||||
? (ulong)BuiltInRng.NextLong()
|
||||
: (ulong)BuiltInRng.Next(1L << amount);
|
||||
|
||||
|
|
@ -612,7 +612,7 @@ public static partial class Utility
|
|||
while (amount > 0)
|
||||
{
|
||||
// Range is 2^amount exclusively, maximum of 62 bits can be used
|
||||
ulong num = amount >= 62
|
||||
var num = amount >= 62
|
||||
? (ulong)BuiltInRng.NextLong()
|
||||
: (ulong)BuiltInRng.Next(1L << amount);
|
||||
|
||||
|
|
@ -1059,7 +1059,7 @@ public static partial class Utility
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Tidy<T>(this List<T> list) where T : ISerializable
|
||||
{
|
||||
for (int i = list.Count - 1; i >= 0; i--)
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var entry = list[i];
|
||||
if (entry?.Deleted != false)
|
||||
|
|
@ -1127,7 +1127,7 @@ public static partial class Utility
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int Abs(this int value)
|
||||
{
|
||||
int mask = value >> 31;
|
||||
var mask = value >> 31;
|
||||
return (value + mask) ^ mask;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public static class World
|
|||
{
|
||||
var length = OutgoingMessagePackets.GetMaxMessageLength(text);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[length].InitializePacket();
|
||||
var buffer = stackalloc byte[length].InitializePacket();
|
||||
|
||||
foreach (var ns in NetState.Instances)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ public static class World
|
|||
{
|
||||
var length = OutgoingMessagePackets.GetMaxMessageLength(text);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[length].InitializePacket();
|
||||
var buffer = stackalloc byte[length].InitializePacket();
|
||||
|
||||
foreach (var ns in NetState.Instances)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class EventSchedulerTests
|
|||
|
||||
try
|
||||
{
|
||||
bool called = false;
|
||||
var called = false;
|
||||
var evt = EventScheduler.Shared.ScheduleEvent(
|
||||
Core._now,
|
||||
TimeOnly.FromDateTime(Core._now),
|
||||
|
|
@ -154,7 +154,7 @@ public class EventSchedulerTests
|
|||
|
||||
try
|
||||
{
|
||||
int callCount = 0;
|
||||
var callCount = 0;
|
||||
|
||||
// Create a recurrence pattern that fires every 10 seconds, up to 3 times
|
||||
var recurrence = new TestRecurrencePattern(TimeSpan.FromSeconds(10), 3);
|
||||
|
|
@ -191,8 +191,8 @@ public class EventSchedulerTests
|
|||
|
||||
try
|
||||
{
|
||||
bool failedEventCalled = false;
|
||||
bool laterEventCalled = false;
|
||||
var failedEventCalled = false;
|
||||
var laterEventCalled = false;
|
||||
|
||||
// Event that throws exception
|
||||
var failedEvt = EventScheduler.Shared.ScheduleEvent(
|
||||
|
|
@ -234,7 +234,7 @@ public class EventSchedulerTests
|
|||
|
||||
try
|
||||
{
|
||||
bool eventCalled = false;
|
||||
var eventCalled = false;
|
||||
|
||||
var evt = EventScheduler.Shared.ScheduleEvent(
|
||||
Core._now.AddSeconds(10),
|
||||
|
|
@ -264,7 +264,7 @@ public class EventSchedulerTests
|
|||
|
||||
try
|
||||
{
|
||||
int callCount = 0;
|
||||
var callCount = 0;
|
||||
|
||||
// Create a recurrence pattern that fires every 10 seconds
|
||||
var recurrence = new TestRecurrencePattern(TimeSpan.FromSeconds(10));
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class PartyPacketTests
|
|||
[Fact]
|
||||
public void TestPartyEmptyList()
|
||||
{
|
||||
Serial m = (Serial)0x1024u;
|
||||
var m = (Serial)0x1024u;
|
||||
|
||||
var expected = new PartyEmptyList(m).Compile();
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public class PartyPacketTests
|
|||
[InlineData(false)]
|
||||
public void TestPartyTextMessage(bool toAll)
|
||||
{
|
||||
Serial serial = (Serial)0x1024u;
|
||||
var serial = (Serial)0x1024u;
|
||||
var text = "[Party] Stuff Happens";
|
||||
|
||||
var expected = new PartyTextMessage(toAll, serial, text).Compile();
|
||||
|
|
@ -85,7 +85,7 @@ public class PartyPacketTests
|
|||
[Fact]
|
||||
public void TestPartyInvitation()
|
||||
{
|
||||
Serial m = (Serial)0x1024u;
|
||||
var m = (Serial)0x1024u;
|
||||
|
||||
var expected = new PartyInvitation(m).Compile();
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue