Fix WORLD movement regression from x/y aliasing and recover invalid 0,0 world spawns
This commit is contained in:
@@ -130,8 +130,9 @@ public sealed class WorldHandler : IClientMessageHandler
|
||||
var y = requestedExplicitChunk
|
||||
? WorldPxY(region, zy, cy, ty)
|
||||
: (character.WorldY ?? WorldPxY(region, zy, cy, ty));
|
||||
if (!float.IsFinite(x) || x < 0f) x = WorldPxX(region, zx, cx, tx);
|
||||
if (!float.IsFinite(y) || y < 0f) y = WorldPxY(region, zy, cy, ty);
|
||||
// Stored world coords should be tile-center aligned; treat 0/invalid as legacy-bad and recover.
|
||||
if (!float.IsFinite(x) || x < (TileSize / 2f)) x = WorldPxX(region, zx, cx, tx);
|
||||
if (!float.IsFinite(y) || y < (TileSize / 2f)) y = WorldPxY(region, zy, cy, ty);
|
||||
|
||||
var (pzX, pzY, pcX, pcY) = ToChunkPos(region, x, y);
|
||||
var s = new SessionState
|
||||
@@ -576,13 +577,22 @@ public sealed class WorldHandler : IClientMessageHandler
|
||||
|
||||
// Some clients wrap movement inside an "input" object.
|
||||
var source = root;
|
||||
var sourceIsNestedInput = false;
|
||||
if (TryGetProperty(root, "input", out var nested) && nested.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
source = nested;
|
||||
sourceIsNestedInput = true;
|
||||
}
|
||||
|
||||
var hasMoveX = TryGetFloat(source, out var moveX, "moveX", "dx", "inputX", "x", "horizontal");
|
||||
var hasMoveY = TryGetFloat(source, out var moveY, "moveY", "dy", "inputY", "y", "vertical");
|
||||
// Do not treat top-level x/y as movement to avoid misreading absolute world position fields.
|
||||
float moveX;
|
||||
float moveY;
|
||||
var hasMoveX = sourceIsNestedInput
|
||||
? TryGetFloat(source, out moveX, "moveX", "dx", "inputX", "x", "horizontal")
|
||||
: TryGetFloat(source, out moveX, "moveX", "dx", "inputX", "horizontal");
|
||||
var hasMoveY = sourceIsNestedInput
|
||||
? TryGetFloat(source, out moveY, "moveY", "dy", "inputY", "y", "vertical")
|
||||
: TryGetFloat(source, out moveY, "moveY", "dy", "inputY", "vertical");
|
||||
if (!hasMoveX && !hasMoveY)
|
||||
{
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user