From 60d5edf97f9dcae2119b7d6b29f5af6efb0a8555 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 18 Mar 2026 00:25:04 -0700 Subject: [PATCH] fix: cancel timed cast immediately on movement start When the player starts moving (forward/backward/strafe/jump) while a timed non-channeled cast is in progress, call cancelCast() before sending the movement packet. Previously the cast bar kept counting down until the server sent SMSG_SPELL_FAILED, causing a visible lag. Channeled spells are excluded (server ends those via MSG_CHANNEL_UPDATE). Turning opcodes are excluded (turning while casting is allowed in WoW). --- src/game/game_handler.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 3e1f8be6..f459637a 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -10706,6 +10706,21 @@ void GameHandler::sendMovement(Opcode opcode) { } } + // Cancel any timed (non-channeled) cast the moment the player starts moving. + // Channeled spells end via MSG_CHANNEL_UPDATE / SMSG_CHANNEL_NOTIFY from the server. + // Turning (MSG_MOVE_START_TURN_*) is allowed while casting. + if (casting && !castIsChannel) { + const bool isPositionalMove = + opcode == Opcode::MSG_MOVE_START_FORWARD || + opcode == Opcode::MSG_MOVE_START_BACKWARD || + opcode == Opcode::MSG_MOVE_START_STRAFE_LEFT || + opcode == Opcode::MSG_MOVE_START_STRAFE_RIGHT || + opcode == Opcode::MSG_MOVE_JUMP; + if (isPositionalMove) { + cancelCast(); + } + } + // Update movement flags based on opcode switch (opcode) { case Opcode::MSG_MOVE_START_FORWARD: