game/rendering: drive Walk(4) and swim state from movement flags

Add UnitMoveFlagsCallback fired on every MSG_MOVE_* with the raw
movement flags field. Application.cpp uses it to update swimming
and walking state from any packet, not just explicit START_SWIM/
STOP_SWIM opcodes — fixing cold-join cases where a player is already
swimming when we enter the world.

Per-frame animation sync now selects Walk(4) when the WALKING flag is
set, Run(5) otherwise, and Swim(42)/SwimIdle(41) when swimming.
UnitAnimHintCallback is simplified to jump (38=JumpMid) only.
This commit is contained in:
Kelsi 2026-03-10 10:55:23 -07:00
parent 333ada8eb6
commit d7ebc5c8c7
4 changed files with 41 additions and 24 deletions

View file

@ -12174,7 +12174,6 @@ void GameHandler::handleOtherPlayerMovement(network::Packet& packet) {
(wireOp == wireOpcode(Opcode::MSG_MOVE_STOP_SWIM)) ||
(wireOp == wireOpcode(Opcode::MSG_MOVE_FALL_LAND));
const bool isJumpOpcode = (wireOp == wireOpcode(Opcode::MSG_MOVE_JUMP));
const bool isSwimOpcode = (wireOp == wireOpcode(Opcode::MSG_MOVE_START_SWIM));
// For stop opcodes snap the entity position (duration=0) so it doesn't keep interpolating,
// and pass durationMs=0 to the renderer so the Run-anim flash is suppressed.
@ -12189,13 +12188,16 @@ void GameHandler::handleOtherPlayerMovement(network::Packet& packet) {
}
// Signal specific animation transitions that the per-frame sync can't detect reliably.
// WoW M2 animation IDs: 38=JumpMid (loops during airborne), 42=Swim
// animId=0 signals "exit swim mode" (MSG_MOVE_STOP_SWIM) so per-frame sync reverts to Stand.
const bool isStopSwimOpcode = (wireOp == wireOpcode(Opcode::MSG_MOVE_STOP_SWIM));
if (unitAnimHintCallback_) {
if (isJumpOpcode) unitAnimHintCallback_(moverGuid, 38u);
else if (isSwimOpcode) unitAnimHintCallback_(moverGuid, 42u);
else if (isStopSwimOpcode) unitAnimHintCallback_(moverGuid, 0u);
// WoW M2 animation ID 38=JumpMid (loops during airborne).
// Swim/walking state is now authoritative from the movement flags field via unitMoveFlagsCallback_.
if (unitAnimHintCallback_ && isJumpOpcode) {
unitAnimHintCallback_(moverGuid, 38u);
}
// Fire move-flags callback so application.cpp can update swimming/walking state
// from the flags field embedded in every movement packet (covers heartbeats and cold joins).
if (unitMoveFlagsCallback_) {
unitMoveFlagsCallback_(moverGuid, info.flags);
}
}