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

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using Server.Items;
@ -40,10 +41,8 @@ namespace Server.Commands
var split = line.Split(' ');
var e = new SignEntry(
line.Substring(
split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 +
split[3].Length + 1 + split[4].Length + 1
),
line[(split[0].Length + 1 + split[1].Length + 1 + split[2].Length + 1 +
split[3].Length + 1 + split[4].Length + 1)..],
new Point3D(Utility.ToInt32(split[2]), Utility.ToInt32(split[3]), Utility.ToInt32(split[4])),
Utility.ToInt32(split[1]),
Utility.ToInt32(split[0])
@ -112,7 +111,7 @@ namespace Server.Commands
if (name.StartsWithOrdinal("#"))
{
sign = new LocalizedSign(itemID, Utility.ToInt32(name.Substring(1)));
sign = new LocalizedSign(itemID, Utility.ToInt32(name.AsSpan()[1..]));
}
else
{
@ -121,14 +120,12 @@ namespace Server.Commands
if (map == Map.Malas)
{
if (location.X >= 965 && location.Y >= 502 && location.X <= 1012 && location.Y <= 537)
sign.Hue = location.X switch
{
sign.Hue = 0x47E;
}
else if (location.X >= 1960 && location.Y >= 1278 && location.X < 2106 && location.Y < 1413)
{
sign.Hue = 0x44E;
}
>= 965 when location.Y >= 502 && location.X <= 1012 && location.Y <= 537 => 0x47E,
>= 1960 when location.Y >= 1278 && location.X < 2106 && location.Y < 1413 => 0x44E,
_ => sign.Hue
};
}
sign.MoveToWorld(location, map);