fix(core): Updates slice with range selectors (#583)

- [X] Replaces Span slicing with range selection
- [X] Replaces string slicing with range selection
This commit is contained in:
Kamron Batman 2021-04-23 20:57:24 -07:00 • committed by GitHub
parent 9f9d990f85
commit a0893b68c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 363 additions and 382 deletions

View file

@ -39,15 +39,15 @@ namespace Server.Items
if (ns.StygianAbyss)
{
length = OutgoingEntityPackets.CreateWorldEntity(buffer, this, ns.HighSeas);
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(8, 2), GMItemId);
BinaryPrimitives.WriteUInt16BigEndian(buffer[8..10], GMItemId);
}
else
{
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(7, 2), GMItemId);
BinaryPrimitives.WriteUInt16BigEndian(buffer[7..9], GMItemId);
}
ns.Send(buffer.SliceToLength(length));
ns.Send(buffer[..length]);
}
public override void Serialize(IGenericWriter writer)

View file

@ -45,15 +45,15 @@ namespace Server.Items
if (ns.StygianAbyss)
{
length = OutgoingEntityPackets.CreateWorldEntity(buffer, this, ns.HighSeas);
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(8, 2), GMItemId);
BinaryPrimitives.WriteUInt16BigEndian(buffer[8..10], GMItemId);
}
else
{
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(7, 2), GMItemId);
BinaryPrimitives.WriteUInt16BigEndian(buffer[7..2], GMItemId);
}
ns.Send(buffer.SliceToLength(length));
ns.Send(buffer[..length]);
}
public override void Serialize(IGenericWriter writer)

View file

@ -239,7 +239,7 @@ namespace Server.Items
if (text.Length > 255)
{
text = text.Substring(0, 255);
text = text[..255];
}
if (text.Length > 0)
@ -316,7 +316,7 @@ namespace Server.Items
if (text.Length > 255)
{
text = text.Substring(0, 255);
text = text[..255];
}
if (text.Length > 0)