From 73ce601bb5a7b5edbf9ef29eedc6d20d9faa8e18 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 15:50:05 -0700 Subject: [PATCH] feat: fire PLAYER_ENTERING_WORLD and critical login events for addons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PLAYER_ENTERING_WORLD is the single most important WoW addon event — virtually every addon registers for it to initialize UI, state, and data structures. It was never fired, causing widespread addon init failures on login and after teleports. Now fired from: - handleLoginVerifyWorld (initial login + same-map teleports) - handleNewWorld (cross-map teleports, instance transitions) Also fires: - PLAYER_LOGIN on initial world entry only - ZONE_CHANGED_NEW_AREA on all world entries - UPDATE_WORLD_STATES on initial entry - SPELLS_CHANGED + LEARNED_SPELL_IN_TAB after SMSG_INITIAL_SPELLS (so spell book addons can initialize on login) --- src/game/game_handler.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 66c116bf..af9489ba 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -9744,6 +9744,19 @@ void GameHandler::handleLoginVerifyWorld(network::Packet& packet) { LOG_INFO("Auto-requested played time on login"); } } + + // Fire PLAYER_ENTERING_WORLD — THE most important event for addon initialization. + // Fires on initial login, teleports, instance transitions, and zone changes. + if (addonEventCallback_) { + addonEventCallback_("PLAYER_ENTERING_WORLD", {initialWorldEntry ? "1" : "0"}); + // Also fire ZONE_CHANGED_NEW_AREA and UPDATE_WORLD_STATES so map/BG addons refresh + addonEventCallback_("ZONE_CHANGED_NEW_AREA", {}); + addonEventCallback_("UPDATE_WORLD_STATES", {}); + // PLAYER_LOGIN fires only on initial login (not teleports) + if (initialWorldEntry) { + addonEventCallback_("PLAYER_LOGIN", {}); + } + } } void GameHandler::handleClientCacheVersion(network::Packet& packet) { @@ -19318,6 +19331,12 @@ void GameHandler::handleInitialSpells(network::Packet& packet) { loadSkillLineAbilityDbc(); LOG_INFO("Learned ", knownSpells.size(), " spells"); + + // Notify addons that the full spell list is now available + if (addonEventCallback_) { + addonEventCallback_("SPELLS_CHANGED", {}); + addonEventCallback_("LEARNED_SPELL_IN_TAB", {}); + } } void GameHandler::handleCastFailed(network::Packet& packet) { @@ -23635,6 +23654,12 @@ void GameHandler::handleNewWorld(network::Packet& packet) { if (worldEntryCallback_) { worldEntryCallback_(mapId, serverX, serverY, serverZ, isSameMap); } + + // Fire PLAYER_ENTERING_WORLD for teleports / zone transitions + if (addonEventCallback_) { + addonEventCallback_("PLAYER_ENTERING_WORLD", {"0"}); + addonEventCallback_("ZONE_CHANGED_NEW_AREA", {}); + } } // ============================================================