feat(net): handle 0xF74E VectorUpdate so remote players' jumps render

Remote-player jumps were silently dropped — we never parsed the
VectorUpdate broadcast that carries the jump launch velocity, so
the remote body's Z velocity stayed at 0 and the jump animation
showed without any vertical motion.

ACE Player.cs:954 enqueues GameMessageVectorUpdate (opcode 0xF74E)
on every jump in addition to the bracketing UpdateMotion. Wire
layout (GameMessageVectorUpdate.cs):

  u32 opcode (= 0xF74E)
  u32 objectGuid
  3xf32 velocity (world-space, post-rotation)
  3xf32 omega
  u16 instanceSequence
  u16 vectorSequence

This commit:

1. Adds VectorUpdate.TryParse + VectorUpdated session event.
2. WorldSession.ProcessDatagram dispatches 0xF74E.
3. GameWindow subscribes via OnLiveVectorUpdated:
   - Sets remote PhysicsBody.Velocity from the wire vector.
   - When velocity.Z > 0.5 m/s, marks the remote as Airborne,
     clears Contact + OnWalkable bits, and enables the Gravity
     state flag — so calc_acceleration returns (0, 0, -9.8) and
     UpdatePhysicsInternal produces a parabolic arc.
4. The per-tick remote update (TickAnimations remote-physics
   block) now SKIPS the "force OnWalkable + apply_current_movement"
   step when Airborne. Otherwise that path stomps the +Z velocity
   each frame — same shape as the bug the local jump hit before
   K-fix7.
5. ResolveWithTransition for remotes now passes
   isOnGround: !rm.Airborne. Mirrors K-fix7's local-player gate —
   airborne resolves must NOT pre-seed the ContactPlane,
   otherwise AdjustOffset's snap-to-plane branch zeroes the
   upward offset.
6. UpdatePosition handler clears the airborne flag and restores
   ground-contact bits, so the server's authoritative re-grounding
   ends the arc cleanly at the new ground location.

ACDREAM_DUMP_MOTION=1 logs each VectorUpdate as
"VU guid=0x... vel=(...) airborne=...".

Tests stay 1222 green. Live verification pending — watch a remote
character jump.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-26 17:38:32 +02:00
parent 1fce21034a
commit b609b5ea6e
3 changed files with 190 additions and 5 deletions

View file

@ -0,0 +1,71 @@
using System.Buffers.Binary;
using System.Numerics;
namespace AcDream.Core.Net.Messages;
/// <summary>
/// Inbound <c>VectorUpdate</c> GameMessage (opcode <c>0xF74E</c>). The
/// server broadcasts this when a remote entity's velocity / omega changes
/// without an accompanying full UpdatePosition — most importantly when a
/// remote player JUMPS. Without handling this, remote jumps look like
/// the player teleported through a tiny vertical hop and back: we never
/// see the +Z velocity that would integrate into a proper arc.
///
/// <para>
/// Wire layout (see
/// <c>references/ACE/Source/ACE.Server/Network/GameMessages/Messages/GameMessageVectorUpdate.cs</c>):
/// </para>
/// <list type="bullet">
/// <item><b>u32 opcode</b> — 0xF74E</item>
/// <item><b>u32 objectGuid</b></item>
/// <item><b>3xf32 velocity</b> — world-space (already rotated by ACE's
/// GameMessageVectorUpdate.cs:20 from PhysicsObj.Velocity).</item>
/// <item><b>3xf32 omega</b> — world-space angular velocity.</item>
/// <item><b>u16 instanceSequence</b> — for stale-packet rejection.</item>
/// <item><b>u16 vectorSequence</b> — for stale-packet rejection.</item>
/// </list>
///
/// Total body size after opcode: 32 bytes.
/// </summary>
public static class VectorUpdate
{
public const uint Opcode = 0xF74Eu;
public readonly record struct Parsed(
uint Guid,
Vector3 Velocity,
Vector3 Omega,
ushort InstanceSequence,
ushort VectorSequence);
/// <summary>
/// Parse a 0xF74E body. Returns null if the buffer is truncated or
/// malformed (sequence-number mismatch is not checked here — the
/// session-level handler decides what to do).
/// </summary>
public static Parsed? TryParse(ReadOnlySpan<byte> body)
{
if (body.Length < 32) return null;
try
{
uint guid = BinaryPrimitives.ReadUInt32LittleEndian(body[..4]);
float vx = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(4, 4)));
float vy = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(8, 4)));
float vz = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(12, 4)));
float ox = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(16, 4)));
float oy = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(20, 4)));
float oz = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(body.Slice(24, 4)));
ushort instSeq = BinaryPrimitives.ReadUInt16LittleEndian(body.Slice(28, 2));
ushort vecSeq = BinaryPrimitives.ReadUInt16LittleEndian(body.Slice(30, 2));
return new Parsed(guid, new Vector3(vx, vy, vz), new Vector3(ox, oy, oz), instSeq, vecSeq);
}
catch
{
return null;
}
}
}

View file

@ -92,6 +92,17 @@ public sealed class WorldSession : IDisposable
/// </summary>
public event Action<EntityPositionUpdate>? PositionUpdated;
/// <summary>
/// Fires when the session parses a 0xF74E VectorUpdate game message.
/// ACE broadcasts this whenever a remote entity's velocity / omega
/// changes outside the normal UpdatePosition cadence — the canonical
/// case is a remote player JUMPING (Player.cs:954
/// <c>EnqueueBroadcast(new GameMessageVectorUpdate(this));</c>).
/// Subscribers update the remote's PhysicsBody velocity + airborne
/// state so the dead-reckoning produces a proper jump arc.
/// </summary>
public event Action<VectorUpdate.Parsed>? VectorUpdated;
/// <summary>
/// Fires when the server sends a PlayerTeleport (0xF751) game message,
/// signalling that the player is entering portal space. The uint payload
@ -667,6 +678,20 @@ public sealed class WorldSession : IDisposable
posUpdate.Value.Velocity));
}
}
else if (op == VectorUpdate.Opcode)
{
// K-fix9 (2026-04-26): server-broadcast remote jump
// velocity. ACE Player.cs:954 enqueues this on every
// jump in addition to the bracketing UpdateMotion. The
// payload's velocity field is the world-space launch
// velocity (post-rotation in
// GameMessageVectorUpdate.cs:20-24); subscribers feed
// it into the remote PhysicsBody so the dead-reckoning
// tick can integrate the arc.
var parsed = VectorUpdate.TryParse(body);
if (parsed is not null)
VectorUpdated?.Invoke(parsed.Value);
}
else if (op == HearSpeech.LocalOpcode || op == HearSpeech.RangedOpcode)
{
// Phase H.1: local/ranged chat. Standalone GameMessage