fix: Fixes sending packets and sidesteps a major issue with stackalloc and PGO in .NET 8 (#1607)
### Summary - Works around a sneaky edge case bug in the JIT with stackalloc where sometimes the buffer is not zero'd. - Fixes SendDisplayBoatHS - Fixes sending health bars in the `SendEverything()` logic. - Fixes a bug in sizing for some string helper functions. ### Developer Note We are enabled `SkipLocalsInit` - do not rely on `stackalloc` to be zero'd. To zero the buffer, use `span.Clear();` Closes #1606
This commit is contained in:
parent
79ba1ea917
commit
03f850fe03
18 changed files with 67 additions and 76 deletions
|
|
@ -21,9 +21,10 @@ namespace Server.Json;
|
|||
|
||||
public class Point2DConverter : JsonConverter<Point2D>
|
||||
{
|
||||
private Point2D DeserializeArray(ref Utf8JsonReader reader)
|
||||
private static Point2D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
data.Clear();
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
|
|
@ -53,9 +54,10 @@ public class Point2DConverter : JsonConverter<Point2D>
|
|||
return new Point2D(data[0], data[1]);
|
||||
}
|
||||
|
||||
private Point2D DeserializeObj(ref Utf8JsonReader reader)
|
||||
private static Point2D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
data.Clear();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ namespace Server.Json;
|
|||
|
||||
public class Point3DConverter : JsonConverter<Point3D>
|
||||
{
|
||||
private Point3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
private static Point3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
data.Clear();
|
||||
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
|
|
@ -53,9 +55,10 @@ public class Point3DConverter : JsonConverter<Point3D>
|
|||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
private Point3D DeserializeObj(ref Utf8JsonReader reader)
|
||||
private static Point3D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
data.Clear();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,9 +21,11 @@ namespace Server.Json;
|
|||
|
||||
public class Rectangle3DConverter : JsonConverter<Rectangle3D>
|
||||
{
|
||||
private Rectangle3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
private static Rectangle3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
data.Clear();
|
||||
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
|
|
@ -53,9 +55,10 @@ public class Rectangle3DConverter : JsonConverter<Rectangle3D>
|
|||
return new Rectangle3D(data[0], data[1], data[2], data[3], data[4], data[5]);
|
||||
}
|
||||
|
||||
private Rectangle3D DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
private static Rectangle3D DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
data.Clear();
|
||||
|
||||
// 0 - xyzwhd, 1 - x1y1z1x2y2z2, 2 - start/end
|
||||
var objType = -1;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@ public class WorldLocationConverter : JsonConverter<WorldLocation>
|
|||
private static Point3DConverter _point3DConverter;
|
||||
private static MapConverter _mapConverter;
|
||||
|
||||
private WorldLocation DeserializeArray(ref Utf8JsonReader reader)
|
||||
private static WorldLocation DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
data.Clear();
|
||||
|
||||
var count = 0;
|
||||
var hasMap = false;
|
||||
Map map = null;
|
||||
|
|
@ -77,9 +79,11 @@ public class WorldLocationConverter : JsonConverter<WorldLocation>
|
|||
return new WorldLocation(data[0], data[1], data[2], map);
|
||||
}
|
||||
|
||||
private WorldLocation DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
private static WorldLocation DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
data.Clear();
|
||||
|
||||
var hasLoc = false;
|
||||
var hasXYZ = false;
|
||||
var hasMap = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue