From 3b499d6871ed4df93d5ee6f600f2a18ad572cec7 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 13 Mar 2026 06:14:28 -0700 Subject: [PATCH] fix: prefix SMSG_SPELL_FAILURE error message with spell name Previously a spell failure like "Not in range" gave no context about which spell failed. Now the message reads e.g. "Fireball: Not in range" using the spell name from the DBC cache. Falls back to the bare reason string if the spell name is not yet cached. --- src/game/game_handler.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 778c8980..8ce64482 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -2998,7 +2998,7 @@ void GameHandler::handlePacket(network::Packet& packet) { const size_t remainingFields = isClassic ? 5u : 6u; // spellId(4)+reason(1) [+castCount(1)] if (packet.getSize() - packet.getReadPos() >= remainingFields) { if (!isClassic) /*uint8_t castCount =*/ packet.readUInt8(); - /*uint32_t spellId =*/ packet.readUInt32(); + uint32_t failSpellId = packet.readUInt32(); uint8_t rawFailReason = packet.readUInt8(); // Classic result enum starts at 0=AFFECTING_COMBAT; shift +1 for WotLK table uint8_t failReason = isClassic ? static_cast(rawFailReason + 1) : rawFailReason; @@ -3010,11 +3010,15 @@ void GameHandler::handlePacket(network::Packet& packet) { pt = static_cast(pu->getPowerType()); const char* reason = getSpellCastResultString(failReason, pt); if (reason) { - addUIError(reason); + // Prefix with spell name for context, e.g. "Fireball: Not in range" + const std::string& sName = getSpellName(failSpellId); + std::string fullMsg = sName.empty() ? reason + : sName + ": " + reason; + addUIError(fullMsg); MessageChatData emsg; emsg.type = ChatType::SYSTEM; emsg.language = ChatLanguage::UNIVERSAL; - emsg.message = reason; + emsg.message = std::move(fullMsg); addLocalChatMessage(emsg); } }