From b8f24ef3301dca70ae5b281f013480717c15310f Mon Sep 17 00:00:00 2001 From: Aqru Date: Fri, 20 Oct 2023 00:26:03 +0200 Subject: [PATCH] Fixed bug with var name interception with hardcore --- .../DeathNotificationLib.lua | 8 +-- .../table_localization.lua | 56 +++++++++---------- MenuElements/deadliest_creature_container.lua | 2 +- .../deadliest_creature_container_extended.lua | 8 +-- Widgets/CreatureRankingTooltip/widget.lua | 14 ++--- Widgets/DeathAlert/widget.lua | 4 +- Widgets/Minilog/widget.lua | 4 +- menu.lua | 8 +-- utils.lua | 10 ++-- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/Libs/DeathNotificationLib/DeathNotificationLib.lua b/Libs/DeathNotificationLib/DeathNotificationLib.lua index 1accea0..99d6a2d 100755 --- a/Libs/DeathNotificationLib/DeathNotificationLib.lua +++ b/Libs/DeathNotificationLib/DeathNotificationLib.lua @@ -620,7 +620,7 @@ local function selfDeathAlertLastWords(last_words) end local death_source = "-1" if DeathLog_Last_Attack_Source then - death_source = npc_to_id[death_source_str] + death_source = d_npc_to_id[death_source_str] end local player_data = @@ -647,8 +647,8 @@ local function selfDeathAlert(death_source_str) local _, _, race_id = UnitRace("player") local _, _, class_id = UnitClass("player") local death_source = "-1" - if death_source_str and npc_to_id[death_source_str] then - death_source = npc_to_id[death_source_str] + if death_source_str and d_npc_to_id[death_source_str] then + death_source = d_npc_to_id[death_source_str] end if death_source_str and environment_damage[death_source_str] then @@ -683,7 +683,7 @@ local function signalGuildDeath(_name, _class_str, _level, _zone, _race, _source local msg = lesserEncodeMessage( _name, guildName, - npc_to_id[_source], + d_npc_to_id[_source], nil, _class_tbl[_class_str], _level, diff --git a/Libs/DeathNotificationLib/table_localization.lua b/Libs/DeathNotificationLib/table_localization.lua index ad436cb..f775f26 100644 --- a/Libs/DeathNotificationLib/table_localization.lua +++ b/Libs/DeathNotificationLib/table_localization.lua @@ -1,56 +1,56 @@ local localeMap = { ["koKR"] = { - id_to_npc = id_to_npc_ko, - npc_to_id = npc_to_id_ko + d_id_to_npc = id_to_npc_ko, + d_npc_to_id = npc_to_id_ko }, ["frFR"] = { - id_to_npc = id_to_npc_fr, - npc_to_id = npc_to_id_fr + d_id_to_npc = id_to_npc_fr, + d_npc_to_id = npc_to_id_fr }, ["deDE"] = { - id_to_npc = id_to_npc_de, - npc_to_id = npc_to_id_de + d_id_to_npc = id_to_npc_de, + d_npc_to_id = npc_to_id_de }, ["enGB"] = { - id_to_npc = id_to_npc_en, - npc_to_id = npc_to_id_en + d_id_to_npc = id_to_npc_en, + d_npc_to_id = npc_to_id_en }, ["enUS"] = { - id_to_npc = id_to_npc_en, - npc_to_id = npc_to_id_en + d_id_to_npc = id_to_npc_en, + d_npc_to_id = npc_to_id_en }, ["itIT"] = { - id_to_npc = id_to_npc_it, - npc_to_id = npc_to_id_it + d_id_to_npc = id_to_npc_it, + d_npc_to_id = npc_to_id_it }, ["zhCN"] = { - id_to_npc = id_to_npc_cn, - npc_to_id = npc_to_id_cn + d_id_to_npc = id_to_npc_cn, + d_npc_to_id = npc_to_id_cn }, ["zhTW"] = { - id_to_npc = id_to_npc_cn, - npc_to_id = npc_to_id_cn + d_id_to_npc = id_to_npc_cn, + d_npc_to_id = npc_to_id_cn }, ["ruRU"] = { - id_to_npc = id_to_npc_ru, - npc_to_id = npc_to_id_ru + d_id_to_npc = id_to_npc_ru, + d_npc_to_id = npc_to_id_ru }, ["esES"] = { - id_to_npc = id_to_npc_es, - npc_to_id = npc_to_id_es + d_id_to_npc = id_to_npc_es, + d_npc_to_id = npc_to_id_es }, ["esMX"] = { - id_to_npc = id_to_npc_es, - npc_to_id = npc_to_id_es + d_id_to_npc = id_to_npc_es, + d_npc_to_id = npc_to_id_es }, ["ptBR"] = { - id_to_npc = id_to_npc_pt, - npc_to_id = npc_to_id_pt + d_id_to_npc = id_to_npc_pt, + d_npc_to_id = npc_to_id_pt }, -- Default table to English ["default"] = { - id_to_npc = id_to_npc_en, - npc_to_id = npc_to_id_en + d_id_to_npc = id_to_npc_en, + d_npc_to_id = npc_to_id_en } } @@ -61,5 +61,5 @@ local function getDataByLocale(localeCode, dataType) end _localeCode = GetLocale() -id_to_npc = getDataByLocale(_localeCode, "id_to_npc") -npc_to_id = getDataByLocale(_localeCode, "npc_to_id") +d_id_to_npc = getDataByLocale(_localeCode, "d_id_to_npc") +d_npc_to_id = getDataByLocale(_localeCode, "d_npc_to_id") diff --git a/MenuElements/deadliest_creature_container.lua b/MenuElements/deadliest_creature_container.lua index a89cb9d..3c2f7e1 100644 --- a/MenuElements/deadliest_creature_container.lua +++ b/MenuElements/deadliest_creature_container.lua @@ -168,7 +168,7 @@ function deadliest_creatures_container.updateMenuElement(scroll_frame, current_m deadliest_creatures_container:GetWidth() * most_deadly_units[i][2] / max_kills ) deadliest_creatures_textures[i]:SetCreatureName( - id_to_npc[most_deadly_units[i][1]] or environment_damage[most_deadly_units[i][1]] + d_id_to_npc[most_deadly_units[i][1]] or environment_damage[most_deadly_units[i][1]] ) deadliest_creatures_textures[i]:SetNumKills(most_deadly_units[i][2]) if valid_map then diff --git a/MenuElements/deadliest_creature_container_extended.lua b/MenuElements/deadliest_creature_container_extended.lua index a740a9c..f10999f 100644 --- a/MenuElements/deadliest_creature_container_extended.lua +++ b/MenuElements/deadliest_creature_container_extended.lua @@ -556,7 +556,7 @@ function deadliest_creatures_container.updateMenuElement( else for k, v in ipairs(most_deadly_units) do if - filter(id_to_npc[v[1]] or environment_damage[v[1]]) + filter(d_id_to_npc[v[1]] or environment_damage[v[1]]) and lvlFunction(_stats["all"]["all"]["all"][v[1]]["avg_lvl"]) then filtered_most_deadly_units[#filtered_most_deadly_units + 1] = v @@ -588,8 +588,8 @@ function deadliest_creatures_container.updateMenuElement( deadliest_creatures_textures[i]:SetBackgroundWidth( deadliest_creatures_container:GetWidth() * filtered_most_deadly_units[idx][2] / max_kills ) - if id_to_npc[filtered_most_deadly_units[idx][1]] ~= nil then - deadliest_creatures_textures[i]:SetCreatureName(id_to_npc[filtered_most_deadly_units[idx][1]]) + if d_id_to_npc[filtered_most_deadly_units[idx][1]] ~= nil then + deadliest_creatures_textures[i]:SetCreatureName(d_id_to_npc[filtered_most_deadly_units[idx][1]]) elseif environment_damage[filtered_most_deadly_units[idx][1]] ~= nil then deadliest_creatures_textures[i]:SetCreatureName( environment_damage[filtered_most_deadly_units[idx][1]] @@ -599,7 +599,7 @@ function deadliest_creatures_container.updateMenuElement( if valid_map then deadliest_creatures_textures[i]:SetScript("OnMouseDown", function() local c_id = filtered_most_deadly_units[idx][1] - local c_name = id_to_npc[filtered_most_deadly_units[idx][1]] + local c_name = d_id_to_npc[filtered_most_deadly_units[idx][1]] updateFun(c_id, c_name, function(name) if name == nil then return false diff --git a/Widgets/CreatureRankingTooltip/widget.lua b/Widgets/CreatureRankingTooltip/widget.lua index 2179ace..b6930c3 100644 --- a/Widgets/CreatureRankingTooltip/widget.lua +++ b/Widgets/CreatureRankingTooltip/widget.lua @@ -35,7 +35,7 @@ function Deathlog_activateCreatureRankingTooltip() zone_name = (deathlog_id_to_instance_tbl[_instance_id] or _instance_id) end if creature_ranking_by_zone[_zone] then - local source_id = npc_to_id[a] + local source_id = d_npc_to_id[a] local rank = creature_ranking_by_zone[_zone][source_id] if rank then GameTooltip:AddLine( @@ -106,8 +106,8 @@ function Deathlog_CRTWidget_applySettings() if deathlog_settings[widget_name]["crt_metric"] == "Total Kills" then local most_deadly_units = deathlogGetOrdered(precomputed_general_stats, { "all", "all", "all", nil }) for k, v in ipairs(most_deadly_units) do - if id_to_npc[v[1]] then - creature_ranking[id_to_npc[v[1]]] = k + if d_id_to_npc[v[1]] then + creature_ranking[d_id_to_npc[v[1]]] = k end end elseif deathlog_settings[widget_name]["crt_metric"] == "Normalized Score" then @@ -119,16 +119,16 @@ function Deathlog_CRTWidget_applySettings() ) for k, v in ipairs(most_deadly_units_normalized) do - if id_to_npc[v[1]] then - creature_ranking[id_to_npc[v[1]]] = k + if d_id_to_npc[v[1]] then + creature_ranking[d_id_to_npc[v[1]]] = k end end end end for k, v in pairs(precomputed_general_stats["all"]["all"]["all"]) do - if id_to_npc[k] then - creature_avg_lvl[id_to_npc[k]] = v["avg_lvl"] + if d_id_to_npc[k] then + creature_avg_lvl[d_id_to_npc[k]] = v["avg_lvl"] end end diff --git a/Widgets/DeathAlert/widget.lua b/Widgets/DeathAlert/widget.lua index 7565a12..4a1bebe 100755 --- a/Widgets/DeathAlert/widget.lua +++ b/Widgets/DeathAlert/widget.lua @@ -188,8 +188,8 @@ function Deathlog_DeathAlertPlay(entry) local msg = deathlog_settings[widget_name]["message"] local source_name = "" if entry["source_id"] then - if id_to_npc[entry["source_id"]] then - source_name = id_to_npc[entry["source_id"]] + if d_id_to_npc[entry["source_id"]] then + source_name = d_id_to_npc[entry["source_id"]] end end if entry["source_id"] == -2 then diff --git a/Widgets/Minilog/widget.lua b/Widgets/Minilog/widget.lua index 5d81f03..5d9c470 100644 --- a/Widgets/Minilog/widget.lua +++ b/Widgets/Minilog/widget.lua @@ -183,7 +183,7 @@ local subtitle_metadata = { if _entry.player_data["source_id"] == nil then return "" end - local _source = id_to_npc[_entry.player_data["source_id"]] + local _source = d_id_to_npc[_entry.player_data["source_id"]] or environment_damage[_entry.player_data["source_id"]] or deathlog_decode_pvp_source(_entry.player_data["source_id"]) or "" @@ -1285,7 +1285,7 @@ options = { end idx = math.random(1, 100) local some_source_id = -2 - for k, v in pairs(id_to_npc) do + for k, v in pairs(d_id_to_npc) do idx = idx - 1 some_source_id = k if idx < 1 then diff --git a/menu.lua b/menu.lua index f75d7f7..d99fda2 100755 --- a/menu.lua +++ b/menu.lua @@ -195,7 +195,7 @@ local subtitle_data = { "Death Source", 140, function(_entry, _server_name) - local _source = id_to_npc[_entry["source_id"]] + local _source = d_id_to_npc[_entry["source_id"]] or environment_damage[_entry["source_id"]] or deathlog_decode_pvp_source(_entry["source_id"]) or "" @@ -892,8 +892,8 @@ local function drawLogTab(container) if #text > 0 then death_source_filter = function(_, _entry) if - id_to_npc[_entry["source_id"]] ~= nil - and string.find(string.lower(id_to_npc[_entry["source_id"]]), string.lower(text)) + d_id_to_npc[_entry["source_id"]] ~= nil + and string.find(string.lower(d_id_to_npc[_entry["source_id"]]), string.lower(text)) then return true else @@ -1216,7 +1216,7 @@ local function drawCreatureStatisticsTab(container) description_label:SetText( string.format("%.2f", deaths_by_creature / all_deaths * 100) .. "% of all deaths are caused by " - .. id_to_npc[creature_id] + .. d_id_to_npc[creature_id] .. "." ) end diff --git a/utils.lua b/utils.lua index 48346ac..bf269ed 100644 --- a/utils.lua +++ b/utils.lua @@ -125,8 +125,8 @@ function deathlogPredictSource(entry_map_pos, entry_map_id) if precomputed_heatmap_intensity[map_id][x][y] then for k, v in pairs(precomputed_heatmap_creature_subset[map_id]) do if v[x] and v[x][y] then - if id_to_npc[k] then - return id_to_npc[k] .. "*" + if d_id_to_npc[k] then + return d_id_to_npc[k] .. "*" end if environment_damage[k] then return environment_damage[k] .. "*" @@ -487,7 +487,7 @@ function deathlog_calculate_statistics(_deathlog_data) -- local ordered = deathlogGetOrdered(stats, {"all", "all", "all", nil}) -- for i,v in ipairs(ordered) do -- if i < 25 then - -- print(i, id_to_npc[v[1]], v[2]) + -- print(i, d_id_to_npc[v[1]], v[2]) -- end -- end @@ -633,7 +633,7 @@ function deathlog_setTooltipFromEntry(_entry) local _guild = _entry["guild"] local _race = nil local _class = nil - local _source = id_to_npc[_entry["source_id"]] + local _source = d_id_to_npc[_entry["source_id"]] or environment_damage[_entry["source_id"]] or deathlog_decode_pvp_source(_entry["source_id"]) or "" @@ -812,7 +812,7 @@ function deathlog_decode_pvp_source(source_id) source_id == nil or source_id == "-1" or source_id == -1 - or id_to_npc[source_id] + or d_id_to_npc[source_id] or environment_damage[source_id] then return ""