chore: Use var everywhere (#2294)
This commit is contained in:
parent
0b34cc4417
commit
ebaf104935
267 changed files with 873 additions and 873 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue