Allow top-level x/y as directional WORLD_INPUT only when in -1..1 range
This commit is contained in:
@@ -584,7 +584,7 @@ public sealed class WorldHandler : IClientMessageHandler
|
||||
sourceIsNestedInput = true;
|
||||
}
|
||||
|
||||
// Do not treat top-level x/y as movement to avoid misreading absolute world position fields.
|
||||
// Accept top-level x/y only when they look like direction input; reject absolute coords.
|
||||
float moveX;
|
||||
float moveY;
|
||||
var hasMoveX = sourceIsNestedInput
|
||||
@@ -593,6 +593,19 @@ public sealed class WorldHandler : IClientMessageHandler
|
||||
var hasMoveY = sourceIsNestedInput
|
||||
? TryGetFloat(source, out moveY, "moveY", "dy", "inputY", "y", "vertical")
|
||||
: TryGetFloat(source, out moveY, "moveY", "dy", "inputY", "vertical");
|
||||
if (!sourceIsNestedInput)
|
||||
{
|
||||
if (!hasMoveX && TryGetFloat(source, out var maybeX, "x") && IsDirectionalValue(maybeX))
|
||||
{
|
||||
moveX = maybeX;
|
||||
hasMoveX = true;
|
||||
}
|
||||
if (!hasMoveY && TryGetFloat(source, out var maybeY, "y") && IsDirectionalValue(maybeY))
|
||||
{
|
||||
moveY = maybeY;
|
||||
hasMoveY = true;
|
||||
}
|
||||
}
|
||||
if (!hasMoveX && !hasMoveY)
|
||||
{
|
||||
return null;
|
||||
@@ -694,6 +707,9 @@ public sealed class WorldHandler : IClientMessageHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsDirectionalValue(float value)
|
||||
=> float.IsFinite(value) && value >= -1.05f && value <= 1.05f;
|
||||
|
||||
private async Task BroadcastAsync(int opCode, object payload, int regionId, Guid? exceptConnectionId = null)
|
||||
{
|
||||
var tasks = _players.Values
|
||||
|
||||
Reference in New Issue
Block a user