mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
refactor: use gameHandler.getMapName in instance lockout window
Replaces the static local Map.dbc cache in renderInstanceLockoutsWindow() with the existing GameHandler::getMapName() accessor, eliminating duplicate DBC loading. Moves getMapName declaration to public interface.
This commit is contained in:
parent
75139aca77
commit
ea7b276125
2 changed files with 5 additions and 23 deletions
|
|
@ -1275,6 +1275,7 @@ public:
|
|||
bool isLfgInDungeon() const { return lfgState_ == LfgState::InDungeon; }
|
||||
uint32_t getLfgDungeonId() const { return lfgDungeonId_; }
|
||||
std::string getCurrentLfgDungeonName() const { return getLfgDungeonName(lfgDungeonId_); }
|
||||
std::string getMapName(uint32_t mapId) const;
|
||||
uint32_t getLfgProposalId() const { return lfgProposalId_; }
|
||||
int32_t getLfgAvgWaitSec() const { return lfgAvgWaitSec_; }
|
||||
uint32_t getLfgTimeInQueueMs() const { return lfgTimeInQueueMs_; }
|
||||
|
|
@ -2977,7 +2978,6 @@ private:
|
|||
std::unordered_map<uint32_t, std::string> mapNameCache_;
|
||||
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<uint32_t, std::string> lfgDungeonNameCache_;
|
||||
|
|
|
|||
|
|
@ -19555,24 +19555,6 @@ void GameScreen::renderInstanceLockouts(game::GameHandler& gameHandler) {
|
|||
if (lockouts.empty()) {
|
||||
ImGui::TextColored(ImVec4(0.6f, 0.6f, 0.6f, 1.0f), "No active instance lockouts.");
|
||||
} else {
|
||||
// Build map name lookup from Map.dbc (cached after first call)
|
||||
static std::unordered_map<uint32_t, std::string> sMapNames;
|
||||
static bool sMapNamesLoaded = false;
|
||||
if (!sMapNamesLoaded) {
|
||||
sMapNamesLoaded = true;
|
||||
if (auto* am = core::Application::getInstance().getAssetManager()) {
|
||||
if (auto dbc = am->loadDBC("Map.dbc"); dbc && dbc->isLoaded()) {
|
||||
for (uint32_t i = 0; i < dbc->getRecordCount(); ++i) {
|
||||
uint32_t id = dbc->getUInt32(i, 0);
|
||||
// Field 2 = MapName_enUS (first localized), field 1 = InternalName
|
||||
std::string name = dbc->getString(i, 2);
|
||||
if (name.empty()) name = dbc->getString(i, 1);
|
||||
if (!name.empty()) sMapNames[id] = std::move(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto difficultyLabel = [](uint32_t diff) -> const char* {
|
||||
switch (diff) {
|
||||
case 0: return "Normal";
|
||||
|
|
@ -19598,11 +19580,11 @@ void GameScreen::renderInstanceLockouts(game::GameHandler& gameHandler) {
|
|||
for (const auto& lo : lockouts) {
|
||||
ImGui::TableNextRow();
|
||||
|
||||
// Instance name
|
||||
// Instance name — use GameHandler's Map.dbc cache (avoids duplicate DBC load)
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
auto it = sMapNames.find(lo.mapId);
|
||||
if (it != sMapNames.end()) {
|
||||
ImGui::TextUnformatted(it->second.c_str());
|
||||
std::string mapName = gameHandler.getMapName(lo.mapId);
|
||||
if (!mapName.empty()) {
|
||||
ImGui::TextUnformatted(mapName.c_str());
|
||||
} else {
|
||||
ImGui::Text("Map %u", lo.mapId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue