From 2a6a97478d3a09856d3bf8427330d283a9e1bd49 Mon Sep 17 00:00:00 2001 From: evil_morfar <10189576+evil-morfar@users.noreply.github.com> Date: Fri, 1 Mar 2024 18:13:05 +0100 Subject: [PATCH] CSVImport optimized `RebuildInstance`. Updated mapIDsToText. Use official API when available if map list is outdated. Note: Unsure why, but a certain unknown data set would corrupt the history when imported. These changes should prevent that from happening. --- Modules/History/CSVImport.lua | 67 +++++++++++++++++++++-------------- changelog.md | 4 +++ 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/Modules/History/CSVImport.lua b/Modules/History/CSVImport.lua index 2f25cc65..46acb380 100644 --- a/Modules/History/CSVImport.lua +++ b/Modules/History/CSVImport.lua @@ -427,6 +427,12 @@ local mapIDsToText = { [2070] = "Battle of Dazar'alor", [2096] = "Crucible of Storms", [2164] = "The Eternal Palace", + [2217] = "Ny'alotha", + [2296] = "Castle Nathria", + [2450] = "Sanctum of Domination", + [2481] = "Sepulcher of the First Ones", + [2522] = "Vault of the Incarnates", + [2569] = "Aberrus, the Shadowed Crucible", } local diffIDToText = { @@ -464,34 +470,41 @@ local diffIDToText = { [149] = "Heroic", } +local function instanceNameFromMapID(mapID) + if not (C_EncounterJournal.GetInstanceForGameMap and EJ_GetInstanceInfo) then return "" end + return select(1,EJ_GetInstanceInfo(C_EncounterJournal.GetInstanceForGameMap(mapID))) +end + function private:RebuildInstance(data, t, line) - local instance, diffID, mapID = data[11], data[13], data[14] - if mapID and diffID then - mapID = tonumber(mapID) - diffID = tonumber(diffID) - if mapIDsToText[mapID] and diffIDToText[diffID] then - t.instance = mapIDsToText[mapID] .."-".. diffIDToText[diffID] - t.mapID = mapID - t.difficultyID = diffID - end - elseif mapID and not diffID and not instance then - mapID = tonumber(mapID) - t.instance = mapIDsToText[mapID] - t.mapID = mapID - t.difficultyID = nil - elseif instance then - if string.find(instance, "-") then - mapID = mapID or tInvert(mapIDsToText)[(string.split("-",instance))] - diffID = diffID or tInvert(diffIDToText)[select(2,string.split("-",instance))] - else - mapID = mapID or tInvert(mapIDsToText)[instance] - end - t.instance = instance - t.mapID = mapID - t.difficultyID = diffID - -- else - -- self:AddError(line, string.format("%s|%s|%s", tostring(instance), tostring(diffID), tostring(mapID)), "Could not recreate instance info.") - end + local instance, diffID, mapID = data[11], tonumber(data[13] or 0), tonumber(data[14] or 0) + if mapID and mapID > 0 then + if diffID > 0 then + local instanceNameFromMapID = instanceNameFromMapID(mapID) + if instanceNameFromMapID == "" and mapIDsToText[mapID] and diffIDToText[diffID] then + t.instance = mapIDsToText[mapID] .."-".. diffIDToText[diffID] + else + t.instance = instanceNameFromMapID .. "-" .. diffIDToText[diffID] + end + t.mapID = mapID + t.difficultyID = diffID + elseif not instance then + t.instance = mapIDsToText[mapID] or "" + t.mapID = mapID + t.difficultyID = nil + end + elseif instance then + if string.find(instance, "-") then + mapID = mapID > 0 and mapID or tInvert(mapIDsToText)[(string.split("-",instance))] + diffID = diffID > 0 and diffID or tInvert(diffIDToText)[select(2,string.split("-",instance))] + else + mapID = mapID or tInvert(mapIDsToText)[instance] + end + t.instance = instance + t.mapID = mapID + t.difficultyID = diffID + -- else + -- self:AddError(line, string.format("%s|%s|%s", tostring(instance), tostring(diffID), tostring(mapID)), "Could not recreate instance info.") + end end function private:AddError (lineNum, value, desc) diff --git a/changelog.md b/changelog.md index e37cff48..52749c4a 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,10 @@ Loot/Voting frames triggered while in combat will now automatically be minimized People joining late, or just before a pull now has a much higher chance of receiving required data from the group leader, which should fix most instances of those people not autopassing group loot. +## Bugfixes + +- *Fixed issue with importing corrupt history data.* + # 3.10.5 ## Changes