From b9c16e9be5704f80d128a250ae92031f2ed2c144 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 13 Mar 2026 06:00:39 -0700 Subject: [PATCH] fix: suppress duplicate "Upgraded to X" message on trainer rank-up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When buying a higher spell rank from a trainer, SMSG_TRAINER_BUY_SUCCEEDED already announces "You have learned X", and SMSG_SUPERCEDED_SPELLS would then also print "Upgraded to X" — two messages for one action. Fix: check if the new spell ID was already in knownSpells before inserting it in handleSupercededSpell. If so, the trainer handler already announced it and we skip the redundant "Upgraded to" message. Non-trainer supersedes (quest rewards, etc.) where the spell wasn't pre-inserted still show it. --- src/game/game_handler.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 0b8846e6..1fcedce0 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -16576,6 +16576,11 @@ void GameHandler::handleSupercededSpell(network::Packet& packet) { // Remove old spell knownSpells.erase(oldSpellId); + // Track whether the new spell was already announced via SMSG_TRAINER_BUY_SUCCEEDED. + // If it was pre-inserted there, that handler already showed "You have learned X" so + // we should skip the "Upgraded to X" message to avoid a duplicate. + const bool newSpellAlreadyAnnounced = knownSpells.count(newSpellId) > 0; + // Add new spell knownSpells.insert(newSpellId); @@ -16596,9 +16601,14 @@ void GameHandler::handleSupercededSpell(network::Packet& packet) { } if (barChanged) saveCharacterConfig(); - const std::string& newName = getSpellName(newSpellId); - if (!newName.empty()) { - addSystemChatMessage("Upgraded to " + newName); + // Show "Upgraded to X" only when the new spell wasn't already announced by the + // trainer-buy handler. For non-trainer supersedes (e.g. quest rewards), the new + // spell won't be pre-inserted so we still show the message. + if (!newSpellAlreadyAnnounced) { + const std::string& newName = getSpellName(newSpellId); + if (!newName.empty()) { + addSystemChatMessage("Upgraded to " + newName); + } } }