diff --git a/Data/expansions/wotlk/dbc_layouts.json b/Data/expansions/wotlk/dbc_layouts.json index de137ad8..73d50a87 100644 --- a/Data/expansions/wotlk/dbc_layouts.json +++ b/Data/expansions/wotlk/dbc_layouts.json @@ -113,5 +113,8 @@ "Threshold0": 38, "Threshold1": 39, "Threshold2": 40, "Threshold3": 41, "Threshold4": 42, "Threshold5": 43, "Threshold6": 44, "Threshold7": 45, "Threshold8": 46, "Threshold9": 47 + }, + "LFGDungeons": { + "ID": 0, "Name": 1 } } diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 10ca1c43..78cc0bbf 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -2977,6 +2977,12 @@ private: bool mapNameCacheLoaded_ = false; void loadMapNameCache(); std::string getMapName(uint32_t mapId) const; + + // LFG dungeon name cache (lazy-loaded from LFGDungeons.dbc; WotLK only) + std::unordered_map lfgDungeonNameCache_; + bool lfgDungeonNameCacheLoaded_ = false; + void loadLfgDungeonDbc(); + std::string getLfgDungeonName(uint32_t dungeonId) const; std::vector trainerTabs_; void handleTrainerList(network::Packet& packet); void loadSpellNameCache(); diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 161f0b95..94a7ccd7 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -14809,7 +14809,13 @@ void GameHandler::handleLfgJoinResult(network::Packet& packet) { // Success — state tells us what phase we're entering lfgState_ = static_cast(state); LOG_INFO("SMSG_LFG_JOIN_RESULT: success, state=", static_cast(state)); - addSystemChatMessage("Dungeon Finder: Joined the queue."); + { + std::string dName = getLfgDungeonName(lfgDungeonId_); + if (!dName.empty()) + addSystemChatMessage("Dungeon Finder: Joined the queue for " + dName + "."); + else + addSystemChatMessage("Dungeon Finder: Joined the queue."); + } } else { const char* msg = lfgJoinResultString(result); std::string errMsg = std::string("Dungeon Finder: ") + (msg ? msg : "Join failed."); @@ -14860,15 +14866,25 @@ void GameHandler::handleLfgProposalUpdate(network::Packet& packet) { lfgProposalId_ = 0; addSystemChatMessage("Dungeon Finder: Group proposal failed."); break; - case 1: + case 1: { lfgState_ = LfgState::InDungeon; lfgProposalId_ = 0; - addSystemChatMessage("Dungeon Finder: Group found! Entering dungeon..."); + std::string dName = getLfgDungeonName(dungeonId); + if (!dName.empty()) + addSystemChatMessage("Dungeon Finder: Group found for " + dName + "! Entering dungeon..."); + else + addSystemChatMessage("Dungeon Finder: Group found! Entering dungeon..."); break; - case 2: + } + case 2: { lfgState_ = LfgState::Proposal; - addSystemChatMessage("Dungeon Finder: A group has been found. Accept or decline."); + std::string dName = getLfgDungeonName(dungeonId); + if (!dName.empty()) + addSystemChatMessage("Dungeon Finder: A group has been found for " + dName + ". Accept or decline."); + else + addSystemChatMessage("Dungeon Finder: A group has been found. Accept or decline."); break; + } default: break; } @@ -23118,6 +23134,42 @@ std::string GameHandler::getMapName(uint32_t mapId) const { return (it != mapNameCache_.end()) ? it->second : std::string{}; } +// --------------------------------------------------------------------------- +// LFG dungeon name cache (WotLK: LFGDungeons.dbc) +// --------------------------------------------------------------------------- + +void GameHandler::loadLfgDungeonDbc() { + if (lfgDungeonNameCacheLoaded_) return; + lfgDungeonNameCacheLoaded_ = true; + + auto* am = core::Application::getInstance().getAssetManager(); + if (!am || !am->isInitialized()) return; + + auto dbc = am->loadDBC("LFGDungeons.dbc"); + if (!dbc || !dbc->isLoaded()) return; + + const auto* layout = pipeline::getActiveDBCLayout() + ? pipeline::getActiveDBCLayout()->getLayout("LFGDungeons") : nullptr; + const uint32_t idField = layout ? (*layout)["ID"] : 0; + const uint32_t nameField = layout ? (*layout)["Name"] : 1; + + for (uint32_t i = 0; i < dbc->getRecordCount(); ++i) { + uint32_t id = dbc->getUInt32(i, idField); + if (id == 0) continue; + std::string name = dbc->getString(i, nameField); + if (!name.empty()) + lfgDungeonNameCache_[id] = std::move(name); + } + LOG_INFO("LFGDungeons.dbc: loaded ", lfgDungeonNameCache_.size(), " dungeon names"); +} + +std::string GameHandler::getLfgDungeonName(uint32_t dungeonId) const { + if (dungeonId == 0) return {}; + const_cast(this)->loadLfgDungeonDbc(); + auto it = lfgDungeonNameCache_.find(dungeonId); + return (it != lfgDungeonNameCache_.end()) ? it->second : std::string{}; +} + // --------------------------------------------------------------------------- // Aura duration update // ---------------------------------------------------------------------------