ModernUO/Projects/Server/Json/Converters
Kamron Batman a28a32f46d
fix(json): Rectangle3DConverter loses a z-level on write (#2506)
## Summary

`Rectangle3DConverter.Write` corrupts a rectangle's Z range for certain bounds. The omit-z guard was:

```csharp
var writeZ = value.Start.Z is > sbyte.MinValue and < sbyte.MaxValue
          || value.End.Z   is > sbyte.MinValue and < sbyte.MaxValue;
```

This drops `z1`/`z2` whenever **both** Z bounds sit at/outside the sbyte extremes — but `Read` reconstructs absent Z as exactly `z1 = -128, z2 = 127` (depth 255). So any rectangle that trips the omit condition without *being* that sentinel round-trips to depth 255 and is corrupted.

The concrete case: a **homeRange-style** bound `Start.Z = -128, End.Z = 128` (depth 256, the full vertical range used by spawners) gets `z1`/`z2` omitted on write, then reads back as depth **255** — silently losing the top z-level on every re-serialize.

(Spotted while working on #2505; spawners now prefer the `homeRange` form so most square bounds avoid this path, but any non-square `spawnBounds` or other `Rectangle3D` JSON is affected.)

## Fix

Omit Z only for the exact sentinel `Read` produces (`z1 == -128 && z2 == 127`); write it for anything else:

```csharp
var writeZ = value.Start.Z != sbyte.MinValue || value.End.Z != sbyte.MaxValue;
```

`Read` is unchanged, so existing `regions.json` rectangles that omit Z keep loading identically.

## Tests

New `Rectangle3DConverterTests`: round-trips the homeRange depth-256 case, the depth-255 sentinel, and ordinary/edge z values; asserts the sentinel omits Z while homeRange bounds write it. Server.Tests 717/717, UOContent.Tests 487/487.
2026-06-25 23:42:49 -07:00
..
BitArrayEnumIndexConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
ClientVersionConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
ClientVersionConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
FlagsConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
GuidConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
GuidConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
IPEndPointConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
IPEndPointConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
MapConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
MapConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Point2DConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Point2DConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Point3DConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Point3DConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Rectangle3DConverter.cs fix(json): Rectangle3DConverter loses a z-level on write (#2506) 2026-06-25 23:42:49 -07:00
Rectangle3DConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
RegionByNameConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
RegionByNameConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TextDefinitionConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TextDefinitionConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TimeSpanConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TimeSpanConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TypeConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
TypeConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
WorldLocationConverter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
WorldLocationConverterFactory.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00