From 31ab76427f9530adc62d3bdc845796945217299d Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 16:09:57 -0700 Subject: [PATCH] fix: remove dead duplicate ufNpcFlags check and add missing UNIT_MODEL_CHANGED events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the CREATE update block, the ufNpcFlags check at the end of the else-if chain was unreachable dead code — it was already handled earlier in the same chain. Remove the duplicate. In the VALUES update block, mount display changes via field updates fired mountCallback_ but not the UNIT_MODEL_CHANGED addon event, unlike the CREATE path which fired both. Add the missing event so Lua addons are notified when the player mounts/dismounts via VALUES updates (the common case for aura-based mounting). Also fire UNIT_MODEL_CHANGED for target/focus/pet display ID changes in the VALUES displayIdChanged path, matching the CREATE path behavior. --- src/game/game_handler.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index af9489ba..b908245b 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -12039,7 +12039,7 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem } } unit->setMountDisplayId(val); - } else if (key == ufNpcFlags) { unit->setNpcFlags(val); } + } } if (block.guid == playerGuid) { constexpr uint32_t UNIT_FLAG_TAXI_FLIGHT = 0x00000100; @@ -12587,6 +12587,8 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem uint32_t old = currentMountDisplayId_; currentMountDisplayId_ = val; if (val != old && mountCallback_) mountCallback_(val); + if (val != old && addonEventCallback_) + addonEventCallback_("UNIT_MODEL_CHANGED", {"player"}); if (old == 0 && val != 0) { mountAuraSpellId_ = 0; for (const auto& a : playerAuras) { @@ -12732,6 +12734,15 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem qsPkt.writeUInt64(block.guid); socket->send(qsPkt); } + // Fire UNIT_MODEL_CHANGED for addons that track model swaps + if (addonEventCallback_) { + std::string uid; + if (block.guid == targetGuid) uid = "target"; + else if (block.guid == focusGuid) uid = "focus"; + else if (block.guid == petGuid_) uid = "pet"; + if (!uid.empty()) + addonEventCallback_("UNIT_MODEL_CHANGED", {uid}); + } } } // Update XP / inventory slot / skill fields for player entity