From 0cdfa2b900e79790933885aecaef01ef32a014e5 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Mon, 22 May 2023 15:31:29 -0300 Subject: [PATCH] Replacing table.wipe with Details:Destroy() --- Definitions.lua | 3 + boot.lua | 218 +++++----- classes/class_custom.lua | 8 +- classes/class_damage.lua | 28 +- classes/class_heal.lua | 10 +- classes/class_instance.lua | 2 +- classes/class_utility.lua | 2 +- classes/container_actors.lua | 20 +- classes/container_pets.lua | 5 +- classes/container_segments.lua | 335 +++++++------- core/control.lua | 25 +- core/gears.lua | 35 +- core/meta.lua | 443 +++++++++---------- core/parser.lua | 144 +++--- core/timemachine.lua | 4 +- core/util.lua | 6 +- frames/window_aura_tracker.lua | 4 +- frames/window_cdtracker.lua | 2 +- frames/window_currentdps.lua | 10 +- frames/window_forge.lua | 8 +- frames/window_main.lua | 8 +- frames/window_playerbreakdown.lua | 3 +- frames/window_playerbreakdown_charts | 2 +- frames/window_playerbreakdown_spells.lua | 3 +- frames/window_scrolldamage.lua | 4 +- frames/window_statistics.lua | 12 +- frames/window_wa.lua | 2 +- functions/bossmods.lua | 4 +- functions/currentdps.lua | 4 +- functions/loaddata.lua | 137 +++--- functions/mythicdungeon.lua | 2 +- functions/pack.lua | 10 +- functions/plater.lua | 2 +- functions/profiles.lua | 6 +- functions/savedata.lua | 151 +++---- functions/skins.lua | 3 +- functions/slash.lua | 530 +++++++++-------------- functions/textures.lua | 2 +- functions/timedata.lua | 308 ++++++------- startup.lua | 22 +- 40 files changed, 1205 insertions(+), 1322 deletions(-) diff --git a/Definitions.lua b/Definitions.lua index 80d0539d..88f23114 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -159,6 +159,7 @@ ---@field EnableMouseWheel fun(self: frame, enable: boolean) ---@field RegisterForDrag fun(self: frame, button: string) ---@field SetResizeBounds fun(self: frame, minWidth: number, minHeight: number, maxWidth: number, maxHeight: number) +---@field RegisterEvent fun(self: frame, event: string) ---@class button : frame ---@field Click fun(self: button) @@ -357,6 +358,8 @@ ---@field GetTotalOnRaid fun(container: actorcontainer, key: string, combat: combat) get the total amount of actor[key] only for the actors which are in the raid ---@field GetActorTable fun(container: actorcontainer) get the table which contains the actors ---@field ListActors fun(container: actorcontainer) usage: for index, actorObject in container:ListActors() do +---@field RemoveActor fun(container: actorcontainer, actor: actor) remove an actor from the container +---@field GetType fun(container: actorcontainer) : number get the container type, 1 for damage, 2 for heal, 3 for energy, 4 for utility ---@class spellcontainer : table ---@field _ActorTable table store [spellId] = spelltable diff --git a/boot.lua b/boot.lua index 1da7d45f..b41e1a7f 100644 --- a/boot.lua +++ b/boot.lua @@ -20,7 +20,7 @@ Details.dont_open_news = true Details.game_version = version Details.userversion = version .. " " .. Details.build_counter - Details.realversion = 151 --core version, this is used to check API version for scripts and plugins (see alias below) + Details.realversion = 152 --core version, this is used to check API version for scripts and plugins (see alias below) Details.APIVersion = Details.realversion --core version Details.version = Details.userversion .. " (core " .. Details.realversion .. ")" --simple stirng to show to players @@ -1218,8 +1218,6 @@ function Details222.PlayerStats:SetStat(statName, value) Details.player_stats[statName] = value end - - ---destroy a table and remove it from the object, if the key isn't passed, the object itself is destroyed ---@param object any ---@param key string|nil @@ -1240,133 +1238,119 @@ function Details:Destroy(object, key) end end ----destroy an actor within a combat object, this call will +---destroy the actor, also calls container:RemoveActor(actor) +---@param self details ---@param actorObject actor +---@param actorContainer actorcontainer ---@param combatObject combat -function Details:DestroyActor(actorObject, combatObject) - --using low level api here for performance - ---@type actor[] - local allActors = {} +function Details:DestroyActor(actorObject, actorContainer, combatObject) + local containerType = actorContainer:GetType() + local combatTotalsTable = combatObject.totals[containerType] --without group + local combatTotalsTableInGroup = combatObject.totals_grupo[containerType] --with group - for containerType = 1, 4 do - local index = combatObject[containerType]._NameIndexTable[actorObject.nome] - if (index) then - ---@type actor - local actor = combatObject[containerType]._ActorTable[index] + if (containerType == 1 or containerType == 2) then --damage|healing done + combatTotalsTable = combatTotalsTable - actorObject.total + if (actorObject.grupo) then + combatTotalsTableInGroup = combatTotalsTableInGroup - actorObject.total + end - if (actor) then - allActors[#allActors+1] = actor + elseif (containerType == 3) then + if (actorObject.total and actorObject.total > 0) then + if (actorObject.powertype) then + combatTotalsTable[actorObject.powertype] = combatTotalsTable[actorObject.powertype] - actorObject.total + combatTotalsTableInGroup[actorObject.powertype] = combatTotalsTableInGroup[actorObject.powertype] - actorObject.total + end + end + if (actorObject.alternatepower and actorObject.alternatepower > 0) then + combatTotalsTable.alternatepower = combatTotalsTable.alternatepower - actorObject.alternatepower + combatTotalsTableInGroup.alternatepower = combatTotalsTableInGroup.alternatepower - actorObject.alternatepower + end - --need to reduce the amount done by the actor from the combatObject - local combatTotalsTable = combatObject.totals --without group - local combatTotalsTableInGroup = combatObject.totals_grupo --with group + elseif (containerType == 4) then + --decrease the amount of CC break from the combat totals + if (actorObject.cc_break and actorObject.cc_break > 0) then + if (combatTotalsTable.cc_break) then + combatTotalsTable.cc_break = combatTotalsTable.cc_break - actorObject.cc_break + end + if (combatTotalsTableInGroup.cc_break) then + combatTotalsTableInGroup.cc_break = combatTotalsTableInGroup.cc_break - actorObject.cc_break + end + end - if (containerType == 1 or containerType == 2) then --damage|healing done - combatTotalsTable[containerType] = combatTotalsTable[containerType] - actor.total - if (actor.grupo) then - combatTotalsTableInGroup[containerType] = combatTotalsTableInGroup[containerType] - actor.total - end + --decrease the amount of dispell from the combat totals + if (actorObject.dispell and actorObject.dispell > 0) then + if (combatTotalsTable.dispell) then + combatTotalsTable.dispell = combatTotalsTable.dispell - actorObject.dispell + end + if (combatTotalsTableInGroup.dispell) then + combatTotalsTableInGroup.dispell = combatTotalsTableInGroup.dispell - actorObject.dispell + end + end - elseif (containerType == 3) then - if (actor.total and actor.total > 0) then - combatTotalsTable[containerType][actor.powertype] = combatTotalsTable[containerType][actor.powertype] - actor.total - combatTotalsTableInGroup[containerType][actor.powertype] = combatTotalsTableInGroup[containerType][actor.powertype] - actor.total - end - if (actor.alternatepower and actor.alternatepower > 0) then - combatTotalsTable[containerType].alternatepower = combatTotalsTable[containerType].alternatepower - actor.alternatepower - combatTotalsTableInGroup[containerType].alternatepower = combatTotalsTableInGroup[containerType].alternatepower - actor.alternatepower - end + --decrease the amount of interrupt from the combat totals + if (actorObject.interrupt and actorObject.interrupt > 0) then + if (combatTotalsTable.interrupt) then + combatTotalsTable.interrupt = combatTotalsTable.interrupt - actorObject.interrupt + end + if (combatTotalsTableInGroup.interrupt) then + combatTotalsTableInGroup.interrupt = combatTotalsTableInGroup.interrupt - actorObject.interrupt + end + end - elseif (containerType == 4) then - --decrease the amount of CC break from the combat totals - if (actor.cc_break and actor.cc_break > 0) then - if (combatTotalsTable[containerType].cc_break) then - combatTotalsTable[containerType].cc_break = combatTotalsTable[containerType].cc_break - actor.cc_break - end - if (combatTotalsTableInGroup[containerType].cc_break) then - combatTotalsTableInGroup[containerType].cc_break = combatTotalsTableInGroup[containerType].cc_break - actor.cc_break - end - end + --decrease the amount of ress from the combat totals + if (actorObject.ress and actorObject.ress > 0) then + if (combatTotalsTable.ress) then + combatTotalsTable.ress = combatTotalsTable.ress - actorObject.ress + end + if (combatTotalsTableInGroup.ress) then + combatTotalsTableInGroup.ress = combatTotalsTableInGroup.ress - actorObject.ress + end + end - --decrease the amount of dispell from the combat totals - if (actor.dispell and actor.dispell > 0) then - if (combatTotalsTable[containerType].dispell) then - combatTotalsTable[containerType].dispell = combatTotalsTable[containerType].dispell - actor.dispell - end - if (combatTotalsTableInGroup[containerType].dispell) then - combatTotalsTableInGroup[containerType].dispell = combatTotalsTableInGroup[containerType].dispell - actor.dispell - end - end + --decrease the amount of dead from the combat totals + if (actorObject.dead and actorObject.dead > 0) then + if (combatTotalsTable.dead) then + combatTotalsTable.dead = combatTotalsTable.dead - actorObject.dead + end + if (combatTotalsTableInGroup.dead) then + combatTotalsTableInGroup.dead = combatTotalsTableInGroup.dead - actorObject.dead + end + end - --decrease the amount of interrupt from the combat totals - if (actor.interrupt and actor.interrupt > 0) then - if (combatTotalsTable[containerType].interrupt) then - combatTotalsTable[containerType].interrupt = combatTotalsTable[containerType].interrupt - actor.interrupt - end - if (combatTotalsTableInGroup[containerType].interrupt) then - combatTotalsTableInGroup[containerType].interrupt = combatTotalsTableInGroup[containerType].interrupt - actor.interrupt - end - end + --decreate the amount of cooldowns used from the combat totals + if (actorObject.cooldowns_defensive and actorObject.cooldowns_defensive > 0) then + if (combatTotalsTable.cooldowns_defensive) then + combatTotalsTable.cooldowns_defensive = combatTotalsTable.cooldowns_defensive - actorObject.cooldowns_defensive + end + if (combatTotalsTableInGroup.cooldowns_defensive) then + combatTotalsTableInGroup.cooldowns_defensive = combatTotalsTableInGroup.cooldowns_defensive - actorObject.cooldowns_defensive + end + end - --decrease the amount of ress from the combat totals - if (actor.ress and actor.ress > 0) then - if (combatTotalsTable[containerType].ress) then - combatTotalsTable[containerType].ress = combatTotalsTable[containerType].ress - actor.ress - end - if (combatTotalsTableInGroup[containerType].ress) then - combatTotalsTableInGroup[containerType].ress = combatTotalsTableInGroup[containerType].ress - actor.ress - end - end + --decrease the amount of buff uptime from the combat totals + if (actorObject.buff_uptime and actorObject.buff_uptime > 0) then + if (combatTotalsTable.buff_uptime) then + combatTotalsTable.buff_uptime = combatTotalsTable.buff_uptime - actorObject.buff_uptime + end + if (combatTotalsTableInGroup.buff_uptime) then + combatTotalsTableInGroup.buff_uptime = combatTotalsTableInGroup.buff_uptime - actorObject.buff_uptime + end + end - --decrease the amount of dead from the combat totals - if (actor.dead and actor.dead > 0) then - if (combatTotalsTable[containerType].dead) then - combatTotalsTable[containerType].dead = combatTotalsTable[containerType].dead - actor.dead - end - if (combatTotalsTableInGroup[containerType].dead) then - combatTotalsTableInGroup[containerType].dead = combatTotalsTableInGroup[containerType].dead - actor.dead - end - end - - --decreate the amount of cooldowns used from the combat totals - if (actor.cooldowns_defensive and actor.cooldowns_defensive > 0) then - if (combatTotalsTable[containerType].cooldowns_defensive) then - combatTotalsTable[containerType].cooldowns_defensive = combatTotalsTable[containerType].cooldowns_defensive - actor.cooldowns_defensive - end - if (combatTotalsTableInGroup[containerType].cooldowns_defensive) then - combatTotalsTableInGroup[containerType].cooldowns_defensive = combatTotalsTableInGroup[containerType].cooldowns_defensive - actor.cooldowns_defensive - end - end - - --decrease the amount of buff uptime from the combat totals - if (actor.buff_uptime and actor.buff_uptime > 0) then - if (combatTotalsTable[containerType].buff_uptime) then - combatTotalsTable[containerType].buff_uptime = combatTotalsTable[containerType].buff_uptime - actor.buff_uptime - end - if (combatTotalsTableInGroup[containerType].buff_uptime) then - combatTotalsTableInGroup[containerType].buff_uptime = combatTotalsTableInGroup[containerType].buff_uptime - actor.buff_uptime - end - end - - --decrease the amount of debuff uptime from the combat totals - if (actor.debuff_uptime and actor.debuff_uptime > 0) then - if (combatTotalsTable[containerType].debuff_uptime) then - combatTotalsTable[containerType].debuff_uptime = combatTotalsTable[containerType].debuff_uptime - actor.debuff_uptime - end - if (combatTotalsTableInGroup[containerType].debuff_uptime) then - combatTotalsTableInGroup[containerType].debuff_uptime = combatTotalsTableInGroup[containerType].debuff_uptime - actor.debuff_uptime - end - end - end - - for i = 1, #allActors do - local thisActor = allActors[i] - setmetatable(thisActor, nil) - thisActor.__index = nil - thisActor.__newindex = nil - Details:Destroy(thisActor) - end + --decrease the amount of debuff uptime from the combat totals + if (actorObject.debuff_uptime and actorObject.debuff_uptime > 0) then + if (combatTotalsTable.debuff_uptime) then + combatTotalsTable.debuff_uptime = combatTotalsTable.debuff_uptime - actorObject.debuff_uptime + end + if (combatTotalsTableInGroup.debuff_uptime) then + combatTotalsTableInGroup.debuff_uptime = combatTotalsTableInGroup.debuff_uptime - actorObject.debuff_uptime end end end + + setmetatable(actorObject, nil) + actorObject.__index = nil + actorObject.__newindex = nil + actorContainer:RemoveActor(actorObject) + Details:Destroy(actorObject) end \ No newline at end of file diff --git a/classes/class_custom.lua b/classes/class_custom.lua index 3d7fee5d..0070cdf7 100644 --- a/classes/class_custom.lua +++ b/classes/class_custom.lua @@ -263,7 +263,7 @@ --check if is a spell target custom if (custom_object:IsSpellTarget()) then - table.wipe(classCustom._TargetActorsProcessed) + Details:Destroy(classCustom._TargetActorsProcessed) classCustom._TargetActorsProcessedAmt = 0 classCustom._TargetActorsProcessedTotal = 0 classCustom._TargetActorsProcessedTop = 0 @@ -736,8 +736,8 @@ end function classCustom:WipeCustomActorContainer() - table.wipe(self._ActorTable) - table.wipe(self._NameIndexTable) + Details:Destroy(self._ActorTable) + Details:Destroy(self._NameIndexTable) end function classCustom:GetValue (actor) @@ -1071,7 +1071,7 @@ end function _detalhes:ResetCustomFunctionsCache() - table.wipe(_detalhes.custom_function_cache) + Details:Destroy(_detalhes.custom_function_cache) end function _detalhes.refresh:r_atributo_custom() diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 9096a8d2..c063707c 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -1874,7 +1874,7 @@ function damageClass:RefreshWindow(instancia, combatObject, forcar, exportar, re elseif (keyName == "damage_taken_by_spells") then local bs_index, total = 0, 0 - wipe (bs_index_table) + Details:Destroy (bs_index_table) local combat = combatObject local AllDamageCharacters = combat:GetActorList (DETAILS_ATTRIBUTE_DAMAGE) @@ -2590,11 +2590,11 @@ end local eventListener = Details:CreateEventListener() eventListener:RegisterEvent("COMBAT_PLAYER_ENTER", function() if (Details.CacheInLineMaxDistance) then - wipe(Details.CacheInLineMaxDistance) + Details:Destroy(Details.CacheInLineMaxDistance) for i = 1, 10 do C_Timer.After(i, function() - wipe(Details.CacheInLineMaxDistance) + Details:Destroy(Details.CacheInLineMaxDistance) end) end end @@ -4467,7 +4467,7 @@ end end local wipeSpellCache = function() --deprecated - table.wipe(Details222.PlayerBreakdown.DamageSpellsCache) + Details:Destroy(Details222.PlayerBreakdown.DamageSpellsCache) end local addToSpellCache = function(unitGUID, spellName, spellTable) --deprecated @@ -5582,11 +5582,11 @@ function damageClass:MontaDetalhesDamageDone (spellId, spellLine, instance) --th local index = 1 local data = data_table - table.wipe(t1) - table.wipe(t2) - table.wipe(t3) - table.wipe(t4) - table.wipe(data) + Details:Destroy(t1) + Details:Destroy(t2) + Details:Destroy(t3) + Details:Destroy(t4) + Details:Destroy(data) --GERAL local media = 0 @@ -6213,14 +6213,14 @@ end end if (bs_tooltip_table) then - wipe (bs_tooltip_table) + Details:Destroy (bs_tooltip_table) end if (frags_tooltip_table) then - wipe (frags_tooltip_table) + Details:Destroy (frags_tooltip_table) end - wipe (bs_index_table) - wipe (tooltip_temp_table) - wipe (tooltip_void_zone_temp) + Details:Destroy (bs_index_table) + Details:Destroy (tooltip_temp_table) + Details:Destroy (tooltip_void_zone_temp) end --atualize a funcao de abreviacao diff --git a/classes/class_heal.lua b/classes/class_heal.lua index fc4966df..70c64634 100644 --- a/classes/class_heal.lua +++ b/classes/class_heal.lua @@ -2536,11 +2536,11 @@ function atributo_heal:MontaDetalhesHealingDone (spellid, barra) local index = 1 local data = data_table - table.wipe(t1) - table.wipe(t2) - table.wipe(t3) - table.wipe(t4) - table.wipe(data) + Details:Destroy(t1) + Details:Destroy(t2) + Details:Destroy(t3) + Details:Destroy(t4) + Details:Destroy(data) if (esta_magia.total > 0) then diff --git a/classes/class_instance.lua b/classes/class_instance.lua index d730417e..5e2070ad 100644 --- a/classes/class_instance.lua +++ b/classes/class_instance.lua @@ -547,7 +547,7 @@ local instanceMixins = { } ---get the table with all instances, these instance could be not initialized yet, some might be open, some not in use ----@return table +---@return instance[] function Details:GetAllInstances() return Details.tabela_instancias end diff --git a/classes/class_utility.lua b/classes/class_utility.lua index 15547fa3..5d5905e3 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -417,7 +417,7 @@ function atributo_misc:ReportSingleDeadLine (morte, instancia) end local default_len = _detalhes.fontstring_len:GetStringWidth() - wipe (report_table) + Details:Destroy (report_table) local report_array = report_table report_array[1] = {"Details! " .. Loc ["STRING_REPORT_SINGLE_DEATH"] .. " " .. morte [3] .. " " .. Loc ["STRING_ACTORFRAME_REPORTAT"] .. " " .. morte [6], "", "", ""} diff --git a/classes/container_actors.lua b/classes/container_actors.lua index 9edd3668..2b242d44 100644 --- a/classes/container_actors.lua +++ b/classes/container_actors.lua @@ -371,6 +371,13 @@ end end end + ---return the actor type which is containing on this container + ---@self actorcontainer + ---@return number + function actorContainer:GetType() + return self.tipo + end + ---return the actor object for a given actor name ---@param actorName string ---@return table|nil @@ -1087,7 +1094,7 @@ end Details:UpdatePetsOnParser() end function Details:ClearCCPetsBlackList() - table.wipe(petBlackList) + Details:Destroy(petBlackList) end function actorContainer:FuncaoDeCriacao (tipo) @@ -1144,6 +1151,17 @@ end return self:remapear() end + ---remove an actor from the container, by removing this way, the container does not need to be remapped + ---@param self actorcontainer + ---@param actorObject actor + function actorContainer:RemoveActor(actorObject) + local nameMap = self._NameIndexTable + local actorList = self._ActorTable + local actorIndex = nameMap[actorObject.nome] + nameMap[actorObject.nome] = nil --actorObject.nome a nil value | Details/boot.lua"]:1374: in function `DestroyActor' | meta.lua"]:590: in function `PrepareTablesForSave' | savedata.lua"]:86 + table.remove(actorList, actorIndex) + end + function actorContainer:remapear() local namingMap = self._NameIndexTable local actorList = self._ActorTable diff --git a/classes/container_pets.lua b/classes/container_pets.lua index 0b4de4df..d55cb2cc 100644 --- a/classes/container_pets.lua +++ b/classes/container_pets.lua @@ -16,7 +16,6 @@ local GetNumGroupMembers = _G.GetNumGroupMembers local setmetatable = setmetatable local _bit_band = bit.band --lua local local pairs = pairs -local wipe = table.wipe --details locals local is_ignored = _detalhes.pets_ignored @@ -210,7 +209,7 @@ end function container_pets:Remover (pet_serial) if (_detalhes.tabela_pets.pets [pet_serial]) then - table.wipe(_detalhes.tabela_pets.pets [pet_serial]) + Details:Destroy(_detalhes.tabela_pets.pets [pet_serial]) end _detalhes.tabela_pets.pets [pet_serial] = nil end @@ -224,7 +223,7 @@ function container_pets:Adicionar (pet_serial, pet_nome, pet_flags, dono_serial, end function _detalhes:WipePets() - return wipe(_detalhes.tabela_pets.pets) + return Details:Destroy(_detalhes.tabela_pets.pets) end function _detalhes:PetContainerCleanup() diff --git a/classes/container_segments.lua b/classes/container_segments.lua index bcac8491..be614990 100644 --- a/classes/container_segments.lua +++ b/classes/container_segments.lua @@ -3,7 +3,6 @@ local Loc = LibStub("AceLocale-3.0"):GetLocale( "Details" ) --lua api local tremove = table.remove local tinsert = table.insert -local wipe = table.wipe local Details = _G.Details local _ @@ -74,7 +73,7 @@ function segmentClass:NovoHistorico() return esta_tabela end -function segmentClass:adicionar_overall (combatObject) +function segmentClass:adicionar_overall(combatObject) local zoneName, zoneType = GetInstanceInfo() if (zoneType ~= "none" and combatObject:GetCombatTime() <= Details.minimum_overall_combat_time) then return @@ -106,6 +105,7 @@ function segmentClass:adicionar_overall (combatObject) if (mythicInfo.TrashOverallSegment) then Details:Msg("error > attempt to add a TrashOverallSegment > func historico:adicionar_overall()") return + elseif (mythicInfo.OverallSegment) then Details:Msg("error > attempt to add a OverallSegment > func historico:adicionar_overall()") return @@ -158,7 +158,7 @@ function segmentClass:adicionar_overall (combatObject) for id, instance in Details:ListInstances() do if (instance:IsEnabled()) then - if (instance:GetSegment() == -1) then + if (instance:GetSegment() == DETAILS_SEGMENTID_OVERALL) then instance:ForceRefresh() end end @@ -243,233 +243,247 @@ function Details:CanAddCombatToOverall (tabela) return false end ---sai do combate, chamou adicionar a tabela ao hist�rico -function segmentClass:adicionar(tabela) +---add the combat to the segment table, check adding to overall +---@param combatObject combat +function segmentClass:adicionar(combatObject) + ---@type combat[] + local segmentTable = self.tabelas + ---@type number + local maxSegmentsAllowed = Details.segments_amount - local tamanho = #self.tabelas - - --verifica se precisa dar UnFreeze() - if (tamanho < Details.segments_amount) then --vai preencher um novo index vazio - local ultima_tabela = self.tabelas[tamanho] - if (not ultima_tabela) then --n�o ha tabelas no historico, esta ser� a #1 - --pega a tabela do combate atual - ultima_tabela = tabela + --check all instances for freeze state + if (#segmentTable < maxSegmentsAllowed) then + ---@type combat + local oldestCombatObject = segmentTable[#segmentTable] + --if there's no segment stored, then this as the first segment + if (not oldestCombatObject) then + oldestCombatObject = combatObject end - Details:InstanciaCallFunction(Details.CheckFreeze, tamanho+1, ultima_tabela) + Details:InstanciaCallFunction(Details.CheckFreeze, #segmentTable + 1, oldestCombatObject) end - --add to history table - tinsert(self.tabelas, 1, tabela) + --add to the first index of the segment table + tinsert(segmentTable, 1, combatObject) --count boss tries - local boss = tabela.is_boss and tabela.is_boss.name - if (boss) then - local try_number = Details.encounter_counter [boss] + ---@type string + local bossName = combatObject.is_boss and combatObject.is_boss.name + if (bossName) then + local tryNumber = Details.encounter_counter[bossName] - if (not try_number) then - local previous_combat - for i = 2, #self.tabelas do - previous_combat = self.tabelas [i] - if (previous_combat and previous_combat.is_boss and previous_combat.is_boss.name and previous_combat.is_boss.try_number and previous_combat.is_boss.name == boss and not previous_combat.is_boss.killed) then - try_number = previous_combat.is_boss.try_number + 1 + if (not tryNumber) then + ---@type combat + local previousCombatObject + for i = 2, #segmentTable do + previousCombatObject = segmentTable[i] + if (previousCombatObject and previousCombatObject.is_boss and previousCombatObject.is_boss.name and previousCombatObject.is_boss.try_number and previousCombatObject.is_boss.name == bossName and not previousCombatObject.is_boss.killed) then + tryNumber = previousCombatObject.is_boss.try_number + 1 break end end - if (not try_number) then - try_number = 1 + if (not tryNumber) then + tryNumber = 1 end else - try_number = Details.encounter_counter [boss] + 1 + tryNumber = Details.encounter_counter[bossName] + 1 end - Details.encounter_counter [boss] = try_number - tabela.is_boss.try_number = try_number + Details.encounter_counter[bossName] = tryNumber + combatObject.is_boss.try_number = tryNumber end --see if can add the encounter to overall data - local canAddToOverall = Details:CanAddCombatToOverall(tabela) + local canAddToOverall = Details:CanAddCombatToOverall(combatObject) if (canAddToOverall) then - --if (InCombatLockdown()) then - -- _detalhes:ScheduleAddCombatToOverall (tabela) - -- if (_detalhes.debug) then - -- _detalhes:Msg("(debug) overall data flag match > in combat scheduling overall addition.") - -- end - --else - if (Details.debug) then - Details:Msg("(debug) overall data flag match addind the combat to overall data.") - end - segmentClass:adicionar_overall (tabela) - --end + if (Details.debug) then + Details:Msg("(debug) overall data flag match addind the combat to overall data.") + end + segmentClass:adicionar_overall(combatObject) end --erase trash segments - if (self.tabelas[2]) then - local _segundo_combate = self.tabelas[2] - local container_damage = _segundo_combate [1] - local container_heal = _segundo_combate [2] + if (segmentTable[2]) then + ---@type combat + local previousCombatObject = segmentTable[2] + ---@type actorcontainer + local containerDamage = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + ---@type actorcontainer + local containerHeal = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL) --regular cleanup - for _, jogador in ipairs(container_damage._ActorTable) do - --remover a tabela de last events - jogador.last_events_table = nil - --verifica se ele ainda esta registrado na time machine - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + for _, actorObject in containerDamage:ListActors() do + ---@cast actorObject actor + --clear last events table + actorObject.last_events_table = nil + + --unregister from time machine + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end - for _, jogador in ipairs(container_heal._ActorTable) do - --remover a tabela de last events - jogador.last_events_table = nil - --verifica se ele ainda esta registrado na time machine - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + + for _, actorObject in containerHeal:ListActors() do + ---@cast actorObject actor + --clear last events table + actorObject.last_events_table = nil + + --unregister from time machine + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end if (Details.trash_auto_remove) then - local _terceiro_combate = self.tabelas[3] + ---@type combat + local thirdCombat = segmentTable[3] - if (_terceiro_combate and not _terceiro_combate.is_mythic_dungeon_segment) then - - if ((_terceiro_combate.is_trash and not _terceiro_combate.is_boss) or (_terceiro_combate.is_temporary)) then - --verificar novamente a time machine - for _, jogador in ipairs(_terceiro_combate [1]._ActorTable) do --damage - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + if (thirdCombat and not thirdCombat.is_mythic_dungeon_segment) then + if ((thirdCombat.is_trash and not thirdCombat.is_boss) or (thirdCombat.is_temporary)) then + --verify again the time machine + for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end - for _, jogador in ipairs(_terceiro_combate [2]._ActorTable) do --heal - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end - --remover - tremove(self.tabelas, 3) - Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED", nil, nil) + + --remove + tremove(segmentTable, 3) + Details:Destroy(thirdCombat) + Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED") end - end - end - end - --verifica se precisa apagar a �ltima tabela do hist�rico - if (#self.tabelas > Details.segments_amount) then + --check if the segment table is full + if (#segmentTable > maxSegmentsAllowed) then + ---@type combat + local combatObjectRemoved + ---@type number + local segmentIdRemoved - local combat_removed, combat_index + --verify if the last combat is a boss and if there's more bosses with the same bossId in the segment table + --then check which combat has the least amount of elapsed time and remove it + --won't remove the latest 3 segments as they are fresh and the player may still look into them + local bossId = combatObject.is_boss and combatObject.is_boss.id - --verifica se est�o dando try em um boss e remove o combate menos relevante - local bossid = tabela.is_boss and tabela.is_boss.id + ---@type combat + local oldestSegment = segmentTable[#segmentTable] + local oldestBossId = oldestSegment.is_boss and oldestSegment.is_boss.id - local last_segment = self.tabelas [#self.tabelas] - local last_bossid = last_segment.is_boss and last_segment.is_boss.id + if (Details.zone_type == "raid" and bossId and oldestBossId and bossId == oldestBossId) then + ---@type combat + local shorterCombatObject + ---@type number + local shorterSegmentId + local minTime = 99999 - if (Details.zone_type == "raid" and bossid and last_bossid and bossid == last_bossid) then - - local shorter_combat - local shorter_id - local min_time = 99999 - - for i = 4, #self.tabelas do - local combat = self.tabelas [i] - if (combat.is_boss and combat.is_boss.id == bossid and combat:GetCombatTime() < min_time and not combat.is_boss.killed) then - shorter_combat = combat - shorter_id = i - min_time = combat:GetCombatTime() + for segmentId = 4, #segmentTable do + ---@type combat + local thisCombatObject = segmentTable[segmentId] + if (thisCombatObject.is_boss and thisCombatObject.is_boss.id == bossId and thisCombatObject:GetCombatTime() < minTime and not thisCombatObject.is_boss.killed) then + shorterCombatObject = thisCombatObject + shorterSegmentId = segmentId + minTime = thisCombatObject:GetCombatTime() end end - if (shorter_combat) then - combat_removed = shorter_combat - combat_index = shorter_id + if (shorterCombatObject) then + combatObjectRemoved = shorterCombatObject + segmentIdRemoved = shorterSegmentId end end - if (not combat_removed) then - combat_removed = self.tabelas [#self.tabelas] - combat_index = #self.tabelas + --if couldn't find a boss to remove, then remove the oldest segment + if (not combatObjectRemoved) then + combatObjectRemoved = segmentTable[#segmentTable] + segmentIdRemoved = #segmentTable end - --verificar novamente a time machine - for _, jogador in ipairs(combat_removed [1]._ActorTable) do --damage - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + --check time machine + for _, actorObject in combatObjectRemoved:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end - for _, jogador in ipairs(combat_removed [2]._ActorTable) do --heal - if (jogador.timeMachine) then - jogador:DesregistrarNaTimeMachine() + for _, actorObject in combatObjectRemoved:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do + if (actorObject.timeMachine) then + actorObject:DesregistrarNaTimeMachine() end end - --remover - tremove(self.tabelas, combat_index) + --remove it + tremove(segmentTable, segmentIdRemoved) + Details:Destroy(combatObjectRemoved) Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED") end - --chama a fun��o que ir� atualizar as inst�ncias com segmentos no hist�rico + --update the combat shown on all instances Details:InstanciaCallFunction(Details.AtualizaSegmentos_AfterCombat, self) - --_detalhes:InstanciaCallFunction(_detalhes.AtualizarJanela) end ---verifica se tem alguma instancia congelada mostrando o segmento rec�m liberado -function Details:CheckFreeze (instancia, index_liberado, tabela) - if (instancia.freezed) then --esta congelada - if (instancia.segmento == index_liberado) then - instancia.showing = tabela - instancia:UnFreeze() +---verify if the instance is freezed, if true unfreeze it +---@param instanceObject instance +---@param segmentId number +---@param combatObject combat +function Details:CheckFreeze(instanceObject, segmentId, combatObject) + if (instanceObject.freezed) then + if (instanceObject:GetSegmentId() == segmentId) then + instanceObject:RefreshCombat() + instanceObject:UnFreeze() end end end -function Details:SetOverallResetOptions (reset_new_boss, reset_new_challenge, reset_on_logoff, reset_new_pvp) - if (reset_new_boss == nil) then - reset_new_boss = Details.overall_clear_newboss +function Details:SetOverallResetOptions(resetOnNewBoss, resetOnNewChallenge, resetOnLogoff, resetOnNewPVP) + if (resetOnNewBoss == nil) then + resetOnNewBoss = Details.overall_clear_newboss end - if (reset_new_challenge == nil) then - reset_new_challenge = Details.overall_clear_newchallenge + if (resetOnNewChallenge == nil) then + resetOnNewChallenge = Details.overall_clear_newchallenge end - if (reset_on_logoff == nil) then - reset_on_logoff = Details.overall_clear_logout + if (resetOnLogoff == nil) then + resetOnLogoff = Details.overall_clear_logout end - if (reset_new_pvp == nil) then - reset_new_pvp = Details.overall_clear_pvp + if (resetOnNewPVP == nil) then + resetOnNewPVP = Details.overall_clear_pvp end - Details.overall_clear_newboss = reset_new_boss - Details.overall_clear_newchallenge = reset_new_challenge - Details.overall_clear_logout = reset_on_logoff - Details.overall_clear_pvp = reset_new_pvp + Details.overall_clear_newboss = resetOnNewBoss + Details.overall_clear_newchallenge = resetOnNewChallenge + Details.overall_clear_logout = resetOnLogoff + Details.overall_clear_pvp = resetOnNewPVP end function segmentClass:resetar_overall() - --if (InCombatLockdown()) then - -- _detalhes:Msg(Loc ["STRING_ERASE_IN_COMBAT"]) - -- _detalhes.schedule_remove_overall = true - --else - --fecha a janela de informa��es do jogador - Details:CloseBreakdownWindow() + Details:CloseBreakdownWindow() - Details.tabela_overall = combatClass:NovaTabela() + Details:Destroy(Details.tabela_overall) + Details.tabela_overall = combatClass:NovaTabela() - for index, instancia in ipairs(Details.tabela_instancias) do - if (instancia.ativa and instancia.segmento == -1) then - instancia:InstanceReset() - instancia:ReajustaGump() + for index, instanceObject in ipairs(Details:GetAllInstances()) do + if (instanceObject:IsEnabled()) then + local segmentId = instanceObject:GetSegmentId() + if (segmentId == DETAILS_SEGMENTID_OVERALL) then + instanceObject:InstanceReset() + instanceObject:ReajustaGump() end end + end - if (Details.schedule_add_to_overall) then --deprecated - wipe (Details.schedule_add_to_overall) - end - --end + if (Details.schedule_add_to_overall) then --deprecated + Details:Destroy(Details.schedule_add_to_overall) + end --stop bar testing if any Details:StopTestBarUpdate() - Details:ClockPluginTickOnSegment() end @@ -503,19 +517,21 @@ function segmentClass:resetar() --empty temporary tables Details.atributo_damage:ClearTempTables() - for _, combate in ipairs(Details.tabela_historico.tabelas) do - wipe(combate) + for _, combatObject in ipairs(Details.tabela_historico.tabelas) do + ---@cast combatObject combat + Details:Destroy(combatObject) end - wipe(Details.tabela_vigente) - wipe(Details.tabela_overall) - wipe(Details.spellcache) + + Details:Destroy(Details.tabela_vigente) + Details:Destroy(Details.tabela_overall) + Details:Destroy(Details.spellcache) if (Details.schedule_add_to_overall) then --deprecated - wipe (Details.schedule_add_to_overall) + Details:Destroy(Details.schedule_add_to_overall) end Details:PetContainerCleanup() - Details:ResetSpecCache (true) --for�ar + Details:ResetSpecCache(true) -- novo container de historico Details.tabela_historico = segmentClass:NovoHistorico() --joga fora a tabela antiga e cria uma nova @@ -531,19 +547,16 @@ function segmentClass:resetar() --marca o addon como fora de combate Details.in_combat = false --zera o contador de combates - Details:NumeroCombate (0) + Details:NumeroCombate(0) - --limpa o cache de magias + --clear caches Details:ClearSpellCache() - - --limpa a tabela de ShieldCache - wipe(Details.ShieldCache) + Details:Destroy(Details.ShieldCache) + Details:Destroy(Details.cache_damage_group) + Details:Destroy(Details.cache_healing_group) --reinicia a time machine timeMachine:Reiniciar() - - wipe(Details.cache_damage_group) - wipe(Details.cache_healing_group) Details:UpdateParserGears() if (not InCombatLockdown() and not UnitAffectingCombat("player")) then diff --git a/core/control.lua b/core/control.lua index 3a2f5d4f..6fd1430a 100644 --- a/core/control.lua +++ b/core/control.lua @@ -12,7 +12,6 @@ local _math_max = math.max --lua local local ipairs = ipairs --lua local local pairs = pairs --lua local - local wipe = table.wipe --lua local local bitBand = bit.band --lua local local GetInstanceInfo = GetInstanceInfo --wow api local @@ -358,14 +357,14 @@ Details:ClearCCPetsBlackList() - wipe(Details.encounter_end_table) + Details:Destroy(Details.encounter_end_table) - wipe(Details.pets_ignored) - wipe(Details.pets_no_owner) + Details:Destroy(Details.pets_ignored) + Details:Destroy(Details.pets_no_owner) Details.container_pets:BuscarPets() - wipe(Details.cache_damage_group) - wipe(Details.cache_healing_group) + Details:Destroy(Details.cache_damage_group) + Details:Destroy(Details.cache_healing_group) Details:UpdateParserGears() --get all buff already applied before the combat start @@ -878,11 +877,11 @@ Details.leaving_combat = false Details:OnCombatPhaseChanged() - wipe(Details.tabela_vigente.PhaseData.damage_section) - wipe(Details.tabela_vigente.PhaseData.heal_section) + Details:Destroy(Details.tabela_vigente.PhaseData.damage_section) + Details:Destroy(Details.tabela_vigente.PhaseData.heal_section) - wipe(Details.cache_damage_group) - wipe(Details.cache_healing_group) + Details:Destroy(Details.cache_damage_group) + Details:Destroy(Details.cache_healing_group) Details:UpdateParserGears() @@ -899,7 +898,7 @@ --do not wipe the encounter table if is in the argus encounter ~REMOVE on 8.0 if (Details.encounter_table and Details.encounter_table.id ~= 2092) then - wipe(Details.encounter_table) + Details:Destroy(Details.encounter_table) else if (Details.debug) then Details:Msg("(debug) in argus encounter, cannot wipe the encounter table.") @@ -938,7 +937,7 @@ --enemies local enemiesAmount = GetNumArenaOpponentSpecs and GetNumArenaOpponentSpecs() or 5 - table.wipe(_detalhes.arena_enemies) + Details:Destroy(_detalhes.arena_enemies) for i = 1, enemiesAmount do local enemyName = _G.GetUnitName("arena" .. i, true) @@ -1330,7 +1329,7 @@ --store pets sent through 'needpetowner' Details.sent_pets = Details.sent_pets or {n = time()} if (Details.sent_pets.n+20 < time()) then - wipe(Details.sent_pets) + Details:Destroy(Details.sent_pets) Details.sent_pets.n = time() end diff --git a/core/gears.lua b/core/gears.lua index 5b5c1df9..680bbd95 100644 --- a/core/gears.lua +++ b/core/gears.lua @@ -232,7 +232,8 @@ end local statusbar_enabled1 = window1.show_statusbar local statusbar_enabled2 = window2.show_statusbar - table.wipe(window1.snap); table.wipe(window2.snap) + Details:Destroy(window1.snap) + Details:Destroy(window2.snap) window1.snap [3] = 2; window2.snap [1] = 1; window1.horizontalSnap = true; window2.horizontalSnap = true @@ -345,15 +346,13 @@ end ------------------------------------------------------------------------------------------------------------ -function _detalhes:SetDeathLogLimit (limit) - +function _detalhes:SetDeathLogLimit(limit) if (limit and type(limit) == "number" and limit >= 8) then _detalhes.deadlog_events = limit - local combat = _detalhes.tabela_vigente + local combatObject = Details:GetCurrentCombat() - local wipe = table.wipe - for player_name, event_table in pairs(combat.player_last_events) do + for player_name, event_table in pairs(combatObject.player_last_events) do if (limit > #event_table) then for i = #event_table + 1, limit do event_table [i] = {} @@ -361,7 +360,7 @@ function _detalhes:SetDeathLogLimit (limit) else event_table.n = 1 for _, t in ipairs(event_table) do - wipe (t) + Details:Destroy(t) end end end @@ -442,7 +441,7 @@ function _detalhes:ResetSpecCache (forced) local isininstance = IsInInstance() if (forced or (not isininstance and not _detalhes.in_group)) then - table.wipe(_detalhes.cached_specs) + Details:Destroy(_detalhes.cached_specs) if (_detalhes.track_specs) then local my_spec = DetailsFramework.GetSpecialization() @@ -458,7 +457,7 @@ function _detalhes:ResetSpecCache (forced) end elseif (_detalhes.in_group and not isininstance) then - table.wipe(_detalhes.cached_specs) + Details:Destroy(_detalhes.cached_specs) if (_detalhes.track_specs) then if (IsInRaid()) then @@ -1913,7 +1912,7 @@ end --test --/run _detalhes.ilevel:CalcItemLevel ("player", UnitGUID("player"), true) ---/run wipe (_detalhes.item_level_pool) +--/run wipe(_detalhes.item_level_pool) function ilvl_core:CalcItemLevel (unitid, guid, shout) @@ -2176,7 +2175,7 @@ function ilvl_core:QueryInspect (unitName, callback, param1) end function ilvl_core:ClearQueryInspectQueue() - wipe (ilvl_core.forced_inspects) + Details:Destroy (ilvl_core.forced_inspects) ilvl_core.clear_queued_list = nil end @@ -3288,7 +3287,7 @@ function Details222.Cache.DoMaintenance() if (currentTime > Details.latest_spell_pool_access + delay) then local spellIdPoolBackup = DetailsFramework.table.copy({}, Details.spell_pool) - wipe(Details.spell_pool) + Details:Destroy(Details.spell_pool) --preserve ignored spells spellId for spellId in pairs(Details.spellid_ignored) do @@ -3296,31 +3295,31 @@ function Details222.Cache.DoMaintenance() end Details.latest_spell_pool_access = currentTime - wipe(spellIdPoolBackup) + Details:Destroy(spellIdPoolBackup) end if (currentTime > Details.latest_npcid_pool_access + delay) then local npcIdPoolBackup = DetailsFramework.table.copy({}, Details.npcid_pool) - wipe(Details.npcid_pool) + Details:Destroy(Details.npcid_pool) --preserve ignored npcs npcId for npcId in pairs (Details.npcid_ignored) do Details.npcid_pool[npcId] = npcIdPoolBackup[npcId] end Details.latest_npcid_pool_access = currentTime - wipe(npcIdPoolBackup) + Details:Destroy(npcIdPoolBackup) end if (currentTime > Details.latest_encounter_spell_pool_access + delay) then - wipe(Details.encounter_spell_pool) + Details:Destroy(Details.encounter_spell_pool) Details.latest_encounter_spell_pool_access = currentTime end if (Details.boss_mods_timers and Details.boss_mods_timers.latest_boss_mods_access) then if (currentTime > Details.boss_mods_timers.latest_boss_mods_access + delay) then - wipe(Details.boss_mods_timers.encounter_timers_bw) - wipe(Details.boss_mods_timers.encounter_timers_dbm) + Details:Destroy(Details.boss_mods_timers.encounter_timers_bw) + Details:Destroy(Details.boss_mods_timers.encounter_timers_dbm) Details.boss_mods_timers.latest_boss_mods_access = currentTime end end diff --git a/core/meta.lua b/core/meta.lua index 34577278..340e9f0e 100644 --- a/core/meta.lua +++ b/core/meta.lua @@ -12,7 +12,6 @@ local setmetatable = setmetatable --lua local local _table_remove = table.remove --lua local local _bit_band = bit.band --lua local - local wipe = table.wipe --lua local local _time = time --lua local local _InCombatLockdown = InCombatLockdown --wow api local @@ -21,21 +20,14 @@ local classHeal = Details.atributo_heal --details local local classEnergy = Details.atributo_energy --details local local classUtility = Details.atributo_misc --details local - local alvo_da_habilidade = Details.alvo_da_habilidade --details local - local habilidade_dano = Details.habilidade_dano --details local - local habilidade_cura = Details.habilidade_cura --details local - local container_habilidades = Details.container_habilidades --details local - local container_combatentes = Details.container_combatentes --details local - - local container_damage_target = Details.container_type.CONTAINER_DAMAGETARGET_CLASS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --constants - local class_type_dano = Details.atributos.dano - local class_type_cura = Details.atributos.cura - local class_type_e_energy = Details.atributos.e_energy - local class_type_misc = Details.atributos.misc + local classTypeDamage = Details.atributos.dano + local classTypeHeal = Details.atributos.cura + local classTypeEnergy = Details.atributos.e_energy + local classTypeUtility = Details.atributos.misc ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --core @@ -44,9 +36,9 @@ ---@param actorContainer actorcontainer local fullRemap = function(actorContainer) local namingMap = actorContainer._NameIndexTable - wipe(namingMap) + Details:Destroy(namingMap) for i = 1, #actorContainer._ActorTable do - local actorName = actorContainer._ActorTable[i].nome + local actorName = actorContainer._ActorTable[i].nome --so the actor got wiped, but the actor table is still there but without any members namingMap[actorName] = i end end @@ -63,14 +55,14 @@ Details.refresh:r_combate (combate) - Details.refresh:r_container_combatentes (combate [class_type_dano]) - Details.refresh:r_container_combatentes (combate [class_type_cura]) - Details.refresh:r_container_combatentes (combate [class_type_e_energy]) - Details.refresh:r_container_combatentes (combate [class_type_misc]) + Details.refresh:r_container_combatentes (combate [classTypeDamage]) + Details.refresh:r_container_combatentes (combate [classTypeHeal]) + Details.refresh:r_container_combatentes (combate [classTypeEnergy]) + Details.refresh:r_container_combatentes (combate [classTypeUtility]) Details.refresh:r_container_combatentes (combate [5]) --ghost container - local todos_atributos = {combate [class_type_dano]._ActorTable, combate [class_type_cura]._ActorTable, combate [class_type_e_energy]._ActorTable, combate [class_type_misc]._ActorTable} + local todos_atributos = {combate [classTypeDamage]._ActorTable, combate [classTypeHeal]._ActorTable, combate [classTypeEnergy]._ActorTable, combate [classTypeUtility]._ActorTable} for class_type, atributo in ipairs(todos_atributos) do for _, esta_classe in ipairs(atributo) do @@ -84,16 +76,16 @@ esta_classe.displayName = nome end - if (class_type == class_type_dano) then + if (class_type == classTypeDamage) then Details.refresh:r_atributo_damage (esta_classe) - elseif (class_type == class_type_cura) then + elseif (class_type == classTypeHeal) then Details.refresh:r_atributo_heal (esta_classe) - elseif (class_type == class_type_e_energy) then + elseif (class_type == classTypeEnergy) then Details.refresh:r_atributo_energy (esta_classe) - elseif (class_type == class_type_misc) then + elseif (class_type == classTypeUtility) then Details.refresh:r_atributo_misc (esta_classe) end end @@ -110,19 +102,16 @@ --reaplica indexes e metatables function Details:RestoreMetatables() - - Details.refresh:r_atributo_custom() - --container de pets e hist�rico Details.refresh:r_container_pets (Details.tabela_pets) Details.refresh:r_historico (Details.tabela_historico) --tabelas dos combates local combate_overall = Details.tabela_overall - local overall_dano = combate_overall [class_type_dano] --damage atalho - local overall_cura = combate_overall [class_type_cura] --heal atalho - local overall_energy = combate_overall [class_type_e_energy] --energy atalho - local overall_misc = combate_overall [class_type_misc] --misc atalho + local overall_dano = combate_overall [classTypeDamage] --damage atalho + local overall_cura = combate_overall [classTypeHeal] --heal atalho + local overall_energy = combate_overall [classTypeEnergy] --energy atalho + local overall_misc = combate_overall [classTypeUtility] --misc atalho local tabelas_do_historico = Details.tabela_historico.tabelas --atalho @@ -183,10 +172,10 @@ end --recupera a meta e indexes dos 4 container - Details.refresh:r_container_combatentes (combate [class_type_dano], overall_dano) - Details.refresh:r_container_combatentes (combate [class_type_cura], overall_cura) - Details.refresh:r_container_combatentes (combate [class_type_e_energy], overall_energy) - Details.refresh:r_container_combatentes (combate [class_type_misc], overall_misc) + Details.refresh:r_container_combatentes (combate [classTypeDamage], overall_dano) + Details.refresh:r_container_combatentes (combate [classTypeHeal], overall_cura) + Details.refresh:r_container_combatentes (combate [classTypeEnergy], overall_energy) + Details.refresh:r_container_combatentes (combate [classTypeUtility], overall_misc) --ghost container if (combate[5]) then @@ -194,7 +183,7 @@ end --tabela com os 4 tabelas de jogadores - local todos_atributos = {combate [class_type_dano]._ActorTable, combate [class_type_cura]._ActorTable, combate [class_type_e_energy]._ActorTable, combate [class_type_misc]._ActorTable} + local todos_atributos = {combate [classTypeDamage]._ActorTable, combate [classTypeHeal]._ActorTable, combate [classTypeEnergy]._ActorTable, combate [classTypeUtility]._ActorTable} for class_type, atributo in ipairs(todos_atributos) do for _, esta_classe in ipairs(atributo) do @@ -211,28 +200,28 @@ local shadow - if (class_type == class_type_dano) then + if (class_type == classTypeDamage) then if (combate.overall_added and not overall_saved) then shadow = classDamage:r_connect_shadow (esta_classe) else shadow = classDamage:r_onlyrefresh_shadow (esta_classe) end - elseif (class_type == class_type_cura) then + elseif (class_type == classTypeHeal) then if (combate.overall_added and not overall_saved) then shadow = classHeal:r_connect_shadow (esta_classe) else shadow = classHeal:r_onlyrefresh_shadow (esta_classe) end - elseif (class_type == class_type_e_energy) then + elseif (class_type == classTypeEnergy) then if (combate.overall_added and not overall_saved) then shadow = classEnergy:r_connect_shadow (esta_classe) else shadow = classEnergy:r_onlyrefresh_shadow (esta_classe) end - elseif (class_type == class_type_misc) then + elseif (class_type == classTypeUtility) then if (combate.overall_added and not overall_saved) then shadow = classUtility:r_connect_shadow (esta_classe) else @@ -370,18 +359,18 @@ function Details:DoOwnerCleanup() ---@type combat[] - local combats = Details.tabela_historico.tabelas or {} + local combatTables = Details.tabela_historico.tabelas or {} local bOverallAdded if (not Details.overall_clear_logout) then - tinsert(combats, Details.tabela_overall) + tinsert(combatTables, Details.tabela_overall) bOverallAdded = true end - for index, combat in ipairs(combats) do + for _, combat in ipairs(combatTables) do ---@cast combat combat - for index, actorContainer in ipairs(combat) do + for _, actorContainer in ipairs(combat) do ---@cast actorContainer actorcontainer - for index, actorObject in ipairs(actorContainer._ActorTable) do + for _, actorObject in ipairs(actorContainer._ActorTable) do ---@cast actorObject actor actorObject.owner = nil end @@ -389,38 +378,41 @@ end if (bOverallAdded) then - tremove(combats, #combats) + tremove(combatTables, #combatTables) end end function Details:DoClassesCleanup() ---@type combat[] - local combats = Details.tabela_historico.tabelas or {} - local bOverallAdded + local combatTables = Details.tabela_historico.tabelas or {} + local bOverallAdded = false if (not Details.overall_clear_logout) then - tinsert(combats, Details.tabela_overall) + --add the overall segment to the cleanup within the other segments + --it is removed after the cleanup + tinsert(combatTables, Details.tabela_overall) bOverallAdded = true end - for index, combatObject in ipairs(combats) do + for index, combatObject in ipairs(combatTables) do + ---@cast combatObject combat for classType, actorContainer in ipairs(combatObject) do ---@cast actorContainer actorcontainer - for index, actorObject in ipairs(actorContainer._ActorTable) do + for _, actorObject in ipairs(actorContainer._ActorTable) do --low level loop for performance ---@cast actorObject actor actorObject.displayName = nil actorObject.minha_barra = nil - if (classType == class_type_dano) then + if (classType == classTypeDamage) then Details.clear:c_atributo_damage(actorObject) - elseif (classType == class_type_cura) then + elseif (classType == classTypeHeal) then Details.clear:c_atributo_heal(actorObject) - elseif (classType == class_type_e_energy) then + elseif (classType == classTypeEnergy) then Details.clear:c_atributo_energy(actorObject) - elseif (classType == class_type_misc) then + elseif (classType == classTypeUtility) then Details.clear:c_atributo_misc(actorObject) end end @@ -428,219 +420,214 @@ end if (bOverallAdded) then - tremove(combats, #combats) + --remove the overall segment from the regular segments + tremove(combatTables, #combatTables) end end function Details:DoContainerCleanup() ---@type combat[] - local combats = Details.tabela_historico.tabelas or {} + local combatTables = Details.tabela_historico.tabelas or {} local bOverallAdded if (not Details.overall_clear_logout) then - tinsert(combats, Details.tabela_overall) + tinsert(combatTables, Details.tabela_overall) bOverallAdded = true end - for index, combat in ipairs(combats) do - Details.clear:c_combate(combat) - for index, container in ipairs(combat) do - Details.clear:c_container_combatentes(container) + for _, combatObject in ipairs(combatTables) do + ---@cast combatObject combat + Details.clear:c_combate(combatObject) + for _, actorContainer in ipairs(combatObject) do + ---@cast actorContainer actorcontainer + Details.clear:c_container_combatentes(actorContainer) end end if (bOverallAdded) then - tremove(combats, #combats) + tremove(combatTables, #combatTables) end end function Details:DoContainerIndexCleanup() ---@type combat[] - local combats = Details.tabela_historico.tabelas or {} + local allSegments = Details.tabela_historico.tabelas or {} local bOverallAdded if (not Details.overall_clear_logout) then - tinsert(combats, Details.tabela_overall) + tinsert(allSegments, Details.tabela_overall) bOverallAdded = true end - for index, combat in ipairs(combats) do - for index, container in ipairs(combat) do - Details.clear:c_container_combatentes_index(container) + for _, combatObject in ipairs(allSegments) do + for _, actorContainer in ipairs(combatObject) do + Details.clear:c_container_combatentes_index(actorContainer) end end if (bOverallAdded) then - tremove(combats, #combats) + tremove(allSegments, #allSegments) end end --limpa indexes, metatables e shadows - function Details:PrepareTablesForSave() - Details.clear_ungrouped = true + function Details:PrepareTablesForSave() + Details.clear_ungrouped = true --clear instances - Details:DoInstanceCleanup() - Details:DoClassesCleanup() --aumentou 1 combat - Details:DoContainerCleanup() --aumentou 1 combat + Details:DoInstanceCleanup() --checked + Details:DoClassesCleanup() --checked + Details:DoContainerCleanup() --checked --clear combats - local combatTables = {} - ---@type combat[] - local combatHistoryTable = Details.tabela_historico.tabelas or {} + ---@type combat[] + local combatTables = {} + ---@type combat[] + local allSegments = Details.tabela_historico.tabelas or {} - --remove os segmentos de trash - for i = #combatHistoryTable, 1, -1 do - ---@type combat - local combateObject = combatHistoryTable[i] - if (combateObject:IsTrash()) then - table.remove(combatHistoryTable, i) - Details:Destroy(combatHistoryTable) - end + --remove segments marked as 'trash' + for i = #allSegments, 1, -1 do + ---@type combat + local combatObject = allSegments[i] + if (combatObject:IsTrash()) then + table.remove(allSegments, i) + Details:Destroy(combatObject) end - - --remove os segmentos > que o limite permitido para salvar - if (Details.segments_amount_to_save and Details.segments_amount_to_save < Details.segments_amount) then - for i = Details.segments_amount, Details.segments_amount_to_save+1, -1 do - if (Details.tabela_historico.tabelas[i]) then - ---@type combat - local combatObject = Details.tabela_historico.tabelas[i] - table.remove(Details.tabela_historico.tabelas, i) - Details:Destroy(combatObject) - end - end - end - - --limpa a tabela overall - if (Details.overall_clear_logout) then - Details.tabela_overall = nil - _detalhes_database.tabela_overall = nil - else - ---@type combat - local overallCombatObject = Details.tabela_overall - - overallCombatObject.previous_combat = nil - ---@type actorcontainer[] - local allAttributes = { - overallCombatObject[class_type_dano], - overallCombatObject[class_type_cura], - overallCombatObject[class_type_e_energy], - overallCombatObject[class_type_misc] - } - - --this is a cleanup for overall data - if (Details.clear_ungrouped) then - --deal with actor which could potentially be removed from the database - for classType, actorContainer in ipairs(allAttributes) do - --get the actor table from the container, this table can be used - local actorTable = actorContainer:GetActorTable() - for i = #actorTable, 1, -1 do - ---@type actor - local actorObject = actorTable[i] - if (actorObject.grupo and not actorObject.boss and not actorObject.boss_fight_component and not actorObject.fight_component and not actorObject.pvp_component and not actorObject.arena_enemy and not actorObject.enemy) then - --remove the actor from the container - table.remove(actorTable, i) - Details:DestroyActor(actorTable, overallCombatObject) - end - end - fullRemap(actorContainer) - end - end - - --now deal with pets without owners - for classType, actorContainer in ipairs(allAttributes) do - --get the actor table from the container, this table can be used - local actorTable = actorContainer:GetActorTable() - for i = #actorTable, 1, -1 do - ---@type actor - local actorObject = actorTable[i] - - if (actorObject.owner) then - if (not actorObject.owner.serial) then - Details:DestroyActor(actorObject, overallCombatObject) - table.remove(actorTable, i) - end - end - end - fullRemap(actorContainer) - end - end - - for i, combatObject in ipairs(combatHistoryTable) do - ---@cast combatObject combat - combatTables[#combatTables+1] = combatObject - end - - --this is a cleanup for combat stored in the segment list - for combatIndex, combatObject in ipairs(combatTables) do - --limpa a tabela do grafico - if (Details.clear_graphic) then - combatObject.TimeData = {} - end - - --limpa a referencia do ultimo combate - combatObject.previous_combat = nil - - local bIsBossEncounter = combatObject.is_boss - if (bIsBossEncounter) then - if (combatObject.pvp) then - bIsBossEncounter = false - end - end - - if (not combatObject.is_mythic_dungeon_segment and Details.clear_ungrouped) then - for i = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do - ---@type actorcontainer - local actorContainer = combatObject:GetContainer(i) - if (actorContainer) then - local actorTable = actorContainer:GetActorTable() - for o = #actorTable, 1, -1 do - local actorObject = actorTable[o] - if (not actorObject.grupo and not actorObject.boss and not actorObject.boss_fight_component and not bIsBossEncounter and not actorObject.pvp_component and not actorObject.fight_component) then - Details:DestroyActor(actorObject, combatObject) - table.remove(actorTable, o) - end - end - fullRemap(actorContainer) - - for o = #actorTable, 1, -1 do - ---@type actor - local actorObject = actorTable[o] - if (actorObject.owner) then - if (not actorObject.owner.serial) then - Details:DestroyActor(actorObject, combatObject) - table.remove(actorTable, i) - end - end - end - fullRemap(actorContainer) - end - end - end - end - - --panic mode (in case the play disconnets during a boss encounter, drop all tables to speedup the login and login back process) - if (Details.segments_panic_mode and Details.can_panic_mode) then - if (Details.tabela_vigente.is_boss) then - Details.tabela_historico = Details.historico:NovoHistorico() - end - end - - --clear all segments on logoff - if (Details.data_cleanup_logout) then - Details.tabela_historico = Details.historico:NovoHistorico() - Details.tabela_overall = nil - _detalhes_database.tabela_overall = nil - end - - --clear customs - Details.clear:c_atributo_custom() - - --clear owners - Details:DoOwnerCleanup() - - --cleer container indexes - Details:DoContainerIndexCleanup() end + --remove segments > of the segment limit to save + if (Details.segments_amount_to_save and Details.segments_amount_to_save < Details.segments_amount) then + for i = Details.segments_amount, Details.segments_amount_to_save + 1, -1 do + if (Details.tabela_historico.tabelas[i]) then + ---@type combat + local combatObject = Details.tabela_historico.tabelas[i] + table.remove(Details.tabela_historico.tabelas, i) + Details:Destroy(combatObject) + end + end + end + + --clear overall segment + if (Details.overall_clear_logout) then + Details.tabela_overall = nil + _detalhes_database.tabela_overall = nil + Details:Destroy(Details.tabela_overall) + else + ---@type combat + local overallCombatObject = Details.tabela_overall + + overallCombatObject.previous_combat = nil + + --this is a cleanup for overall data (overall) + if (Details.clear_ungrouped) then + --deal with actor which could potentially be removed from the database + for containerId = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do + local actorContainer = overallCombatObject:GetContainer(containerId) + local actorTable = actorContainer:GetActorTable() + for actorIndex = #actorTable, 1, -1 do + ---@type actor + local actorObject = actorTable[actorIndex] + if (not actorObject.grupo and not actorObject.boss and not actorObject.boss_fight_component and not actorObject.fight_component and not actorObject.pvp_component and not actorObject.arena_enemy and not actorObject.enemy) then + Details:DestroyActor(actorObject, actorContainer, overallCombatObject) + end + end + end + end + + --find orphans, finding orphans should be done when deleting an actor, it should iterate among the actor pets and delete them as well + --now deal with pets without owners (overall) + for containerId = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do + local actorContainer = overallCombatObject:GetContainer(containerId) + local actorTable = actorContainer:GetActorTable() + for actorIndex = #actorTable, 1, -1 do + ---@type actor + local actorObject = actorTable[actorIndex] + + if (actorObject.owner) then + if (not actorObject.owner.serial) then + Details:DestroyActor(actorObject, actorContainer, overallCombatObject) + end + end + end + end + end + + for i, combatObject in ipairs(allSegments) do + ---@cast combatObject combat + combatTables[#combatTables+1] = combatObject + end + + --this is a cleanup for combat stored in the segment list + for combatIndex, combatObject in ipairs(combatTables) do + ---@cast combatObject combat + + --clear the time data (chart data) - if the option to cleanup on logout is enabled + if (Details.clear_graphic) then + Details:Destroy(combatObject.TimeData) + combatObject.TimeData = {} + end + + --clear the reference of the previous combat + combatObject.previous_combat = nil + + local bIsBossEncounter = combatObject.is_boss + if (bIsBossEncounter) then + if (combatObject.pvp) then + bIsBossEncounter = false + end + end + + if (not combatObject.is_mythic_dungeon_segment and Details.clear_ungrouped) then + for i = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do + ---@type actorcontainer + local actorContainer = combatObject:GetContainer(i) + if (actorContainer) then + local actorTable = actorContainer:GetActorTable() + for o = #actorTable, 1, -1 do + ---@type actor + local actorObject = actorTable[o] + if (not actorObject.grupo and not actorObject.boss and not actorObject.boss_fight_component and not bIsBossEncounter and not actorObject.pvp_component and not actorObject.fight_component) then + Details:DestroyActor(actorObject, actorContainer, combatObject) + end + end + + --find orphans + for o = #actorTable, 1, -1 do + ---@type actor + local actorObject = actorTable[o] + if (actorObject.owner) then + if (not actorObject.owner.serial) then + Details:DestroyActor(actorObject, actorContainer, combatObject) + end + end + end + end + end + end + end + + --panic mode (in case the player disconnets during a boss encounter, drop all tables to speedup the login and login back process) + if (Details.segments_panic_mode and Details.can_panic_mode) then + if (Details.tabela_vigente.is_boss) then + Details.tabela_historico = Details.historico:NovoHistorico() + end + end + + --clear all segments on logoff + if (Details.data_cleanup_logout) then + Details.tabela_historico = Details.historico:NovoHistorico() + Details.tabela_overall = nil + _detalhes_database.tabela_overall = nil + end + + --clear customs + Details.clear:c_atributo_custom() + + --clear owners + Details:DoOwnerCleanup() + + --clear container indexes + Details:DoContainerIndexCleanup() + end + function Details:reset_window(instancia) if (instancia.segmento == -1) then instancia.showing[instancia.atributo].need_refresh = true @@ -720,7 +707,7 @@ Details:ResetSpecCache() --cleanup the shield cache - wipe(Details.ShieldCache) + Details:Destroy(Details.ShieldCache) --set the time of the last run Details222.GarbageCollector.lastCollectTime = Details._tempo diff --git a/core/parser.lua b/core/parser.lua index 184ec612..e204b91e 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -4459,7 +4459,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 local schedule_table, schedule_id = unpack(Details.capture_schedules[i]) Details:CancelTimer(schedule_table) end - wipe(Details.capture_schedules) + Details:Destroy(Details.capture_schedules) end function Details:CaptureTimeout (table) @@ -4870,7 +4870,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end --reset spec cache if broadcaster requested if (_detalhes.streamer_config.reset_spec_cache) then - wipe (_detalhes.cached_specs) + Details:Destroy (_detalhes.cached_specs) end end @@ -4972,7 +4972,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes.boss1_health_percent = 1 local dbm_mod, dbm_time = _detalhes.encounter_table.DBM_Mod, _detalhes.encounter_table.DBM_ModTime - wipe(_detalhes.encounter_table) + Details:Destroy(_detalhes.encounter_table) _detalhes.encounter_table.phase = 1 @@ -5100,10 +5100,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes:SendEvent("COMBAT_ENCOUNTER_END", nil, ...) - wipe(_detalhes.encounter_table) - wipe(dk_pets_cache.army) - wipe(dk_pets_cache.apoc) - wipe(empower_cache) + Details:Destroy(_detalhes.encounter_table) + Details:Destroy(dk_pets_cache.army) + Details:Destroy(dk_pets_cache.apoc) + Details:Destroy(empower_cache) return true end @@ -5285,8 +5285,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end if (not OnRegenEnabled) then - wipe(bitfield_swap_cache) - wipe(empower_cache) + Details:Destroy(bitfield_swap_cache) + Details:Destroy(empower_cache) _detalhes:DispatchAutoRunCode("on_leavecombat") end @@ -5601,7 +5601,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details:DispatchAutoRunCode("on_groupchange") - wipe (Details.trusted_characters) + Details:Destroy (Details.trusted_characters) C_Timer.After(5, Details.ScheduleSyncPlayerActorData) end @@ -5613,12 +5613,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details222.GarbageCollector.RestartInternalGarbageCollector(true) Details:WipePets() Details:SchedulePetUpdate(1) - wipe(Details.details_users) + Details:Destroy(Details.details_users) Details:InstanceCall(Details.AdjustAlphaByContext) Details:CheckSwitchOnLogon() Details:SendEvent("GROUP_ONLEAVE") Details:DispatchAutoRunCode("on_groupchange") - wipe(Details.trusted_characters) + Details:Destroy(Details.trusted_characters) else --player is still in a group _detalhes:SchedulePetUpdate(2) @@ -5716,8 +5716,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details.faction_id = 1 end - local startLoadTime = debugprofilestop() - --this function applies the Details.default_profile to Details object, this isn't yet the player profile which will load later Details222.LoadSavedVariables.DefaultProfile() @@ -5739,11 +5737,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details:StartAutoRun() Details.isLoaded = true - - local endLoadTime = debugprofilestop() - startLoadTime - if (Details.version_alpha_id and Details.version_alpha_id > 0 or true) then - Details:Msg("load time: " .. math.floor(endLoadTime) .. "ms", "alpha:", Details.version_alpha_id) - end end function Details.IsLoaded() @@ -5807,33 +5800,39 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes.listener:SetScript("OnEvent", _detalhes.OnEvent) --logout function ~save ~logout - local saver = CreateFrame("frame", nil, UIParent) - saver:RegisterEvent("PLAYER_LOGOUT") - saver:SetScript("OnEvent", function(...) + ---@type frame + local databaseSaver = CreateFrame("frame") + databaseSaver:RegisterEvent("PLAYER_LOGOUT") + databaseSaver:SetScript("OnEvent", function(...) + --safe guard logs and user settings __details_backup = __details_backup or { _exit_error = {}, _instance_backup = {}, } + + ---@type table local exitErrors = __details_backup._exit_error + ---@param text string the error to be logged local addToExitErrors = function(text) table.insert(exitErrors, 1, date() .. "|" .. text) table.remove(exitErrors, 10) end + ---@type string current step of the logout process, used to log which is the current step when an error happens local currentStep = "" --save the time played on this class, run protected - local savePlayTimeClass, savePlayTimeError = pcall(function() - Details.SavePlayTimeOnClass() - end) + local savePlayTimeClass, savePlayTimeErrorText = pcall(function() Details.SavePlayTimeOnClass() end) if (not savePlayTimeClass) then - addToExitErrors("Saving Play Time: " .. savePlayTimeError) + addToExitErrors("Saving Play Time: " .. savePlayTimeErrorText) end - --SAVINGDATA = true + ---@type table record a log of events that happened during the logout process _detalhes_global.exit_log = {} + + ---@type table record errors that happened during the logout process _detalhes_global.exit_errors = _detalhes_global.exit_errors or {} currentStep = "Checking the framework integrity" @@ -5845,8 +5844,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 return end - local saver_error = function(errortext) - --if the error log cause an error? + local logSaverError = function(errortext) local writeLog = function() _detalhes_global = _detalhes_global or {} tinsert(_detalhes_global.exit_errors, 1, currentStep .. "|" .. date() .. "|" .. _detalhes.userversion .. "|" .. errortext .. "|" .. debugstack()) @@ -5856,52 +5854,54 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 xpcall(writeLog, addToExitErrors) end - _detalhes.saver_error_func = saver_error + _detalhes.saver_error_func = logSaverError _detalhes.logoff_saving_data = true - --close info window + --close breakdown window if (_detalhes.CloseBreakdownWindow) then - tinsert(_detalhes_global.exit_log, "1 - Closing Janela Info.") - currentStep = "Fecha Janela Info" - xpcall(_detalhes.CloseBreakdownWindow, saver_error) + tinsert(_detalhes_global.exit_log, "1 - Closing Breakdown Window.") + currentStep = "Closing Breakdown Window" + xpcall(_detalhes.CloseBreakdownWindow, logSaverError) end --do not save window pos if (_detalhes.tabela_instancias) then local clearInstances = function() currentStep = "Dealing With Instances" - tinsert(_detalhes_global.exit_log, "2 - Clearing user place from instances.") + tinsert(_detalhes_global.exit_log, "2 - Clearing user placed position from instance windows.") for id, instance in _detalhes:ListInstances() do if (id) then tinsert(_detalhes_global.exit_log, " - " .. id .. " has baseFrame: " .. (instance.baseframe and "yes" or "no") .. ".") if (instance.baseframe) then - instance.baseframe:SetUserPlaced (false) - instance.baseframe:SetDontSavePosition (true) + instance.baseframe:SetUserPlaced(false) + instance.baseframe:SetDontSavePosition(true) end end end end - xpcall(clearInstances, saver_error) + xpcall(clearInstances, logSaverError) else tinsert(_detalhes_global.exit_errors, 1, "not _detalhes.tabela_instancias") tremove(_detalhes_global.exit_errors, 6) addToExitErrors("not _detalhes.tabela_instancias") end - --leave combat start save tables + --if is in combat during the logout, stop the combat if (_detalhes.in_combat and _detalhes.tabela_vigente) then tinsert(_detalhes_global.exit_log, "3 - Leaving current combat.") currentStep = "Leaving Current Combat" - xpcall(_detalhes.SairDoCombate, saver_error) + xpcall(_detalhes.SairDoCombate, logSaverError) _detalhes.can_panic_mode = true end + --switch back to default, settings changed by automation if (_detalhes.CheckSwitchOnLogon and _detalhes.tabela_instancias and _detalhes.tabela_instancias[1] and getmetatable(_detalhes.tabela_instancias[1])) then tinsert(_detalhes_global.exit_log, "4 - Reversing switches.") currentStep = "Check Switch on Logon" - xpcall(_detalhes.CheckSwitchOnLogon, saver_error) + xpcall(_detalhes.CheckSwitchOnLogon, logSaverError) end + --user requested a wipe of the full configuration if (_detalhes.wipe_full_config) then tinsert(_detalhes_global.exit_log, "5 - Is a full config wipe.") addToExitErrors("true: _detalhes.wipe_full_config") @@ -5910,22 +5910,22 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 return end - --save the config + --save the config tinsert(_detalhes_global.exit_log, "6 - Saving Config.") currentStep = "Saving Config" - xpcall(_detalhes.SaveConfig, saver_error) + xpcall(_detalhes.SaveConfig, logSaverError) tinsert(_detalhes_global.exit_log, "7 - Saving Profiles.") currentStep = "Saving Profile" - xpcall(_detalhes.SaveProfile, saver_error) + xpcall(_detalhes.SaveProfile, logSaverError) - --save the nicktag cache + --save the nicktag cache tinsert(_detalhes_global.exit_log, "8 - Saving nicktag cache.") local saveNicktabCache = function() _detalhes_database.nick_tag_cache = Details.CopyTable(_detalhes_database.nick_tag_cache) end - xpcall(saveNicktabCache, saver_error) + xpcall(saveNicktabCache, logSaverError) end) local eraNamedSpellsToID = {} @@ -6052,30 +6052,30 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end function _detalhes:ClearParserCache() --~wipe - wipe(damage_cache) - wipe(damage_cache_pets) - wipe(damage_cache_petsOwners) - wipe(healing_cache) - wipe(energy_cache) - wipe(misc_cache) - wipe(misc_cache_pets) - wipe(misc_cache_petsOwners) - wipe(npcid_cache) - wipe(enemy_cast_cache) - wipe(empower_cache) + Details:Destroy(damage_cache) + Details:Destroy(damage_cache_pets) + Details:Destroy(damage_cache_petsOwners) + Details:Destroy(healing_cache) + Details:Destroy(energy_cache) + Details:Destroy(misc_cache) + Details:Destroy(misc_cache_pets) + Details:Destroy(misc_cache_petsOwners) + Details:Destroy(npcid_cache) + Details:Destroy(enemy_cast_cache) + Details:Destroy(empower_cache) - wipe(ignore_death_cache) + Details:Destroy(ignore_death_cache) - wipe(reflection_damage) - wipe(reflection_debuffs) - wipe(reflection_events) - wipe(reflection_auras) - wipe(reflection_dispels) + Details:Destroy(reflection_damage) + Details:Destroy(reflection_debuffs) + Details:Destroy(reflection_events) + Details:Destroy(reflection_auras) + Details:Destroy(reflection_dispels) - wipe(dk_pets_cache.army) - wipe(dk_pets_cache.apoc) + Details:Destroy(dk_pets_cache.army) + Details:Destroy(dk_pets_cache.apoc) - wipe(cacheAnything.paladin_vivaldi_blessings) + Details:Destroy(cacheAnything.paladin_vivaldi_blessings) cacheAnything.track_hunter_frenzy = Details.combat_log.track_hunter_frenzy @@ -6175,11 +6175,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end function _detalhes:UptadeRaidMembersCache() - wipe(raid_members_cache) - wipe(tanks_members_cache) - wipe(auto_regen_cache) - wipe(bitfield_swap_cache) - wipe(empower_cache) + Details:Destroy(raid_members_cache) + Details:Destroy(tanks_members_cache) + Details:Destroy(auto_regen_cache) + Details:Destroy(bitfield_swap_cache) + Details:Destroy(empower_cache) local groupRoster = _detalhes.tabela_vigente.raid_roster @@ -6332,7 +6332,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 --_recording_ability_with_buffs = _detalhes.RecordPlayerAbilityWithBuffs --can be deprecated _in_combat = _detalhes.in_combat - wipe(ignored_npcids) + Details:Destroy(ignored_npcids) --fill it with the default npcs ignored for npcId in pairs(_detalhes.default_ignored_npcs) do diff --git a/core/timemachine.lua b/core/timemachine.lua index f6e2cb75..69aa97d2 100644 --- a/core/timemachine.lua +++ b/core/timemachine.lua @@ -107,8 +107,8 @@ end function timeMachine:Reiniciar() - table.wipe(self.tabelas[1]) - table.wipe(self.tabelas[2]) + Details:Destroy(self.tabelas[1]) + Details:Destroy(self.tabelas[2]) self.tabelas = {{}, {}} --1 dano 2 cura end diff --git a/core/util.lua b/core/util.lua index 257cbfdd..de52f4ee 100644 --- a/core/util.lua +++ b/core/util.lua @@ -354,7 +354,7 @@ for key, value in pairs(_table) do temptable [string.lower(key)] = value end - temptable, _table = table.wipe(_table), temptable + temptable, _table = Details:Destroy(_table), temptable return _table end @@ -526,7 +526,7 @@ return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - wipe (_detalhes.ToKFunctions) + Details:Destroy (_detalhes.ToKFunctions) tinsert(_detalhes.ToKFunctions, _detalhes.NoToK) tinsert(_detalhes.ToKFunctions, _detalhes.ToK) @@ -659,7 +659,7 @@ return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - wipe (_detalhes.ToKFunctions) + Details:Destroy (_detalhes.ToKFunctions) tinsert(_detalhes.ToKFunctions, _detalhes.NoToK) tinsert(_detalhes.ToKFunctions, _detalhes.ToK) diff --git a/frames/window_aura_tracker.lua b/frames/window_aura_tracker.lua index b1330f9b..8450f6fb 100644 --- a/frames/window_aura_tracker.lua +++ b/frames/window_aura_tracker.lua @@ -27,8 +27,8 @@ function Details.AuraTracker.AddAura(auraType, spellid) end local doFullAuraUpdate = function() - wipe(Details.AuraTracker.buff) - wipe(Details.AuraTracker.debuff) + Details:Destroy(Details.AuraTracker.buff) + Details:Destroy(Details.AuraTracker.debuff) local unitId = "player" diff --git a/frames/window_cdtracker.lua b/frames/window_cdtracker.lua index 240eb7e0..9bb7764b 100644 --- a/frames/window_cdtracker.lua +++ b/frames/window_cdtracker.lua @@ -328,7 +328,7 @@ end end cooldownFrame.scheduleRosterUpdate = nil - wipe(cooldownFrame.playerCache) + Details:Destroy(cooldownFrame.playerCache) cooldownFrame.nextLineId = 1 if (Details.ocd_tracker.show_conditions.only_in_group) then diff --git a/frames/window_currentdps.lua b/frames/window_currentdps.lua index 80079735..2637a08b 100644 --- a/frames/window_currentdps.lua +++ b/frames/window_currentdps.lua @@ -583,8 +583,8 @@ function Details:CreateCurrentDpsFrame(parent, name) DF:SetFontOutline (labelYellowTeam_DPS, Details.realtime_dps_meter.font_shadow) --wipe current data for arena - wipe (f.PlayerTeamBuffer) - wipe (f.YellowTeamBuffer) + Details:Destroy (f.PlayerTeamBuffer) + Details:Destroy (f.YellowTeamBuffer) --reset damage f.PlayerTeamDamage = 0 @@ -902,9 +902,9 @@ function Details:CreateCurrentDpsFrame(parent, name) function eventListener:ResetBuffer() if (f:IsShown()) then - wipe (f.PlayerTeamBuffer) - wipe (f.YellowTeamBuffer) - wipe (f.GroupBuffer) + Details:Destroy (f.PlayerTeamBuffer) + Details:Destroy (f.YellowTeamBuffer) + Details:Destroy (f.GroupBuffer) f.GroupTotalDamage = 0 f.PlayerTeamDamage = 0 f.YellowDamage = 0 diff --git a/frames/window_forge.lua b/frames/window_forge.lua index 3438fa61..15cb59e7 100644 --- a/frames/window_forge.lua +++ b/frames/window_forge.lua @@ -105,10 +105,10 @@ function Details:OpenForge() f:SetScript("OnHide", function() for _, module in ipairs(all_modules) do if (module.data) then - wipe (module.data) + Details:Destroy (module.data) end end - wipe (spell_already_added) + Details:Destroy (spell_already_added) end) f.bg1 = f:CreateTexture(nil, "background") @@ -438,7 +438,7 @@ function Details:OpenForge() local filter_name = DetailsForgeAllSpellsNameFilter:GetText() local lower_FilterCaster = lower (filter_caster) local lower_FilterSpellName = lower (filter_name) - wipe (spell_already_added) + Details:Destroy (spell_already_added) local SpellPoll = Details.spell_pool for spellID, className in pairs(SpellPoll) do @@ -582,7 +582,7 @@ function Details:OpenForge() local lower_FilterSpellName = lower (filter_name) local lower_FilterEncounterName = lower (filter_encounter) - wipe (spell_already_added) + Details:Destroy (spell_already_added) local SpellPoll = Details.encounter_spell_pool for spellID, spellTable in pairs(SpellPoll) do diff --git a/frames/window_main.lua b/frames/window_main.lua index 3a11a9fd..deba6ffc 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -2302,7 +2302,7 @@ function icon_frame_events:EnterCombat() anim.icon_frame.icon_animation = nil anim.icon_frame = nil end - wipe (Details.icon_animations.load.in_use) + Details:Destroy (Details.icon_animations.load.in_use) end icon_frame_events:RegisterEvent("COMBAT_PLAYER_ENTER", "EnterCombat") @@ -3060,7 +3060,7 @@ function Details:InstanceAlert (msg, icon, timeInSeconds, clickfunc, doflash, fo end self.alert.button.func = nil - wipe (self.alert.button.func_param) + Details:Destroy (self.alert.button.func_param) if (clickfunc) then self.alert.button.func = clickfunc[1] @@ -5609,7 +5609,7 @@ function Details:SetIconAlpha(alpha, hide, noAnimations) end end - table.wipe(SetIconAlphaCacheButtonsTable) + Details:Destroy(SetIconAlphaCacheButtonsTable) SetIconAlphaCacheButtonsTable[1] = self.baseframe.cabecalho.modo_selecao SetIconAlphaCacheButtonsTable[2] = self.baseframe.cabecalho.segmento SetIconAlphaCacheButtonsTable[3] = self.baseframe.cabecalho.atributo @@ -5703,7 +5703,7 @@ function Details:ToolbarMenuSetButtons(_mode, _segment, _attributes, _report, _r self.menu_icons[5] = _reset self.menu_icons[6] = _close - table.wipe(tbuttons) + Details:Destroy(tbuttons) tbuttons[1] = self.baseframe.cabecalho.modo_selecao tbuttons[2] = self.baseframe.cabecalho.segmento diff --git a/frames/window_playerbreakdown.lua b/frames/window_playerbreakdown.lua index 8de2a0f3..e93b9732 100644 --- a/frames/window_playerbreakdown.lua +++ b/frames/window_playerbreakdown.lua @@ -15,7 +15,6 @@ local type = type local unpack = _G.unpack local PixelUtil = PixelUtil local UISpecialFrames = UISpecialFrames -local wipe = wipe local CreateFrame = _G.CreateFrame local detailsFramework = DetailsFramework @@ -248,7 +247,7 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute local tabsReplaced = {} local tabReplacedAmount = 0 - wipe(breakdownWindow.currentTabsInUse) + Details:Destroy(breakdownWindow.currentTabsInUse) for index = 1, #Details.player_details_tabs do local tab = Details.player_details_tabs[index] diff --git a/frames/window_playerbreakdown_charts b/frames/window_playerbreakdown_charts index 803a12a3..cf368f10 100644 --- a/frames/window_playerbreakdown_charts +++ b/frames/window_playerbreakdown_charts @@ -225,7 +225,7 @@ end --called when Details! reset the data function chartsObject.ResetSegmentData() - wipe(chartsObject.SegmentsData) + Details:Destroy(chartsObject.SegmentsData) --stop the ticker chartsObject.StopCombatDataTicker() diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua index 3091a444..bc7dae3a 100644 --- a/frames/window_playerbreakdown_spells.lua +++ b/frames/window_playerbreakdown_spells.lua @@ -7,7 +7,6 @@ local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") local unpack = unpack local GetTime = GetTime -local wipe = wipe local CreateFrame = CreateFrame local GetSpellLink = GetSpellLink local GetSpellInfo = GetSpellInfo @@ -2515,7 +2514,7 @@ local getSpellBar = function(scrollFrame, lineIndex) spellBar.bIsExpandedSpell = false - wipe(spellBar.ExpandedChildren) + Details:Destroy(spellBar.ExpandedChildren) --reset header alignment spellBar:ResetFramesToHeaderAlignment() diff --git a/frames/window_scrolldamage.lua b/frames/window_scrolldamage.lua index 259a55b7..deea3c04 100644 --- a/frames/window_scrolldamage.lua +++ b/frames/window_scrolldamage.lua @@ -239,7 +239,7 @@ function Details:ScrollDamage() DetailsScrollDamage.Data.Started = time() end tinsert(DetailsScrollDamage.Data, 1, {timew, token, hidding, sourceSerial, sourceName, sourceFlag, sourceFlag2, targetSerial, targetName, targetFlag, targetFlag2, spellID, spellName, spellType, amount, overKill or 0, school or 1, resisted or 0, blocked or 0, absorbed or 0, isCritical}) - wipe(DetailsScrollDamage.searchCache) + Details:Destroy(DetailsScrollDamage.searchCache) damageScroll:RefreshScroll() elseif (token == "SWING_DAMAGE") then @@ -251,7 +251,7 @@ function Details:ScrollDamage() end) DetailsScrollDamage:SetScript("OnShow", function() - wipe(DetailsScrollDamage.Data) + Details:Destroy(DetailsScrollDamage.Data) damageScroll:RefreshScroll() combatLogReader:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end) diff --git a/frames/window_statistics.lua b/frames/window_statistics.lua index 653c72c3..d265c4ba 100644 --- a/frames/window_statistics.lua +++ b/frames/window_statistics.lua @@ -453,10 +453,10 @@ function Details:OpenRaidHistoryWindow(raidName, bossEncounterId, difficultyId, local currentGuild = guildDropdown.value --wipe data - wipe(difficultyList) - wipe(bossList) - wipe(raidList) - wipe(guildList) + Details:Destroy(difficultyList) + Details:Destroy(bossList) + Details:Destroy(raidList) + Details:Destroy(guildList) local bossRepeated = {} local raidRepeated = {} @@ -618,8 +618,8 @@ function Details:OpenRaidHistoryWindow(raidName, bossEncounterId, difficultyId, local raidSelected = DetailsRaidHistoryWindow.select_raid:GetValue() local bossRepeated = {} - wipe(bossList) - wipe(difficultyList) + Details:Destroy(bossList) + Details:Destroy(difficultyList) for difficulty, encounterIdTable in pairs(db) do if (type(difficulty) == "number" and allowedKeysForDifficulty[difficulty]) then diff --git a/frames/window_wa.lua b/frames/window_wa.lua index f8baf2f9..35e4cd61 100644 --- a/frames/window_wa.lua +++ b/frames/window_wa.lua @@ -1961,7 +1961,7 @@ function _detalhes:OpenAuraPanel (spellid, spellname, spellicon, encounterid, tr spellname = select(1, GetSpellInfo(spellid)) end - wipe (empty_other_values) + Details:Destroy (empty_other_values) other_values = other_values or empty_other_values if (not DetailsAuraPanel or not DetailsAuraPanel.Initialized) then diff --git a/functions/bossmods.lua b/functions/bossmods.lua index e4a33830..5372dde6 100644 --- a/functions/bossmods.lua +++ b/functions/bossmods.lua @@ -133,8 +133,8 @@ function Details:CreateCallbackListeners() end current_encounter = false - wipe (current_table_dbm) - wipe (current_table_bigwigs) + Details:Destroy (current_table_dbm) + Details:Destroy (current_table_bigwigs) end end) event_frame:RegisterEvent("ENCOUNTER_START") diff --git a/functions/currentdps.lua b/functions/currentdps.lua index aa5b987e..89a4b972 100644 --- a/functions/currentdps.lua +++ b/functions/currentdps.lua @@ -74,8 +74,8 @@ end --start the proccess of updating the current dps and hps for each player function Details.CurrentDps.StartCurrentDpsTracker() Details.CurrentDps.CombatObject = Details:GetCurrentCombat() - wipe(Details.CurrentDps.Dps) - wipe(Details.CurrentDps.Hps) + Details:Destroy(Details.CurrentDps.Dps) + Details:Destroy(Details.CurrentDps.Hps) currentDpsFrame:SetScript("OnUpdate", currentDpsFrame.OnUpdateFunc) end --stop what the function above started diff --git a/functions/loaddata.lua b/functions/loaddata.lua index 97ad563d..809b067b 100644 --- a/functions/loaddata.lua +++ b/functions/loaddata.lua @@ -3,7 +3,7 @@ local Details = _G.Details local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local _ local addonName, Details222 = ... -local C_Timer +local C_Timer = C_Timer local UnitName = UnitName --On Details! Load load default keys into the main object @@ -22,7 +22,7 @@ function Details222.LoadSavedVariables.CharacterData() local currentCharacterData = _detalhes_database --check if the player data exists, if not, load from default - if (not currentCharacterData) then + if (not currentCharacterData) then --NOT EXISTS currentCharacterData = Details.CopyTable(defaultCharacterData) --[[GLOBAL]] _detalhes_database = currentCharacterData end @@ -106,71 +106,91 @@ end --load previous saved combat data function Details222.LoadSavedVariables.CombatSegments() local currentCharacterData = _G["_detalhes_database"] --no need to check if it exists, it's already checked + if (currentCharacterData == nil) then + currentCharacterData = {} + end - --if isn't nothing saved, build a new one and quit - if (not currentCharacterData.tabela_historico) then + --custom displays - if there's no saved custom display, they will be filled from the StartMeUp() when a new version is installed + if (_detalhes_global.custom) then + Details.custom = _detalhes_global.custom + Details.refresh:r_atributo_custom() + end + + local bShouldClearAndExit = not currentCharacterData.tabela_historico + + --check integrity of the sub table 'tabelas' and its first index 'current segment' + if (not bShouldClearAndExit) then + if (not currentCharacterData.tabela_historico.tabelas or not currentCharacterData.tabela_historico.tabelas[1]) then + bShouldClearAndExit = true + end + end + + --check if is a major version upgrade (usualy API or low level changes) + if (not bShouldClearAndExit) then + bShouldClearAndExit = currentCharacterData.last_realversion and currentCharacterData.last_realversion < Details.realversion + end + + --if can just clear all data and exit + if (bShouldClearAndExit) then Details.tabela_historico = Details.historico:NovoHistorico() Details.tabela_overall = Details.combate:NovaTabela() Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall) Details.tabela_pets = Details.container_pets:NovoContainer() Details:UpdateContainerCombatentes() + + if (currentCharacterData.tabela_pets) then + Details:Destroy(currentCharacterData.tabela_pets) --saved pet data + currentCharacterData.tabela_pets = nil + end + if (currentCharacterData.tabela_overall) then --saved overall data + Details:Destroy(currentCharacterData.tabela_overall) + currentCharacterData.tabela_overall = nil + end + if (currentCharacterData.tabela_historico) then + Details:Destroy(currentCharacterData.tabela_historico) + currentCharacterData.tabela_historico = nil + end + return else - Details.tabela_historico = Details.CopyTable(currentCharacterData.tabela_historico) - Details.tabela_overall = Details.combate:NovaTabela() - Details.tabela_pets = Details.container_pets:NovoContainer() - if (currentCharacterData.tabela_pets) then - Details.tabela_pets.pets = Details.CopyTable(currentCharacterData.tabela_pets) - end - Details:UpdateContainerCombatentes() - - --if the core revision was incremented, reset all combat data to avoid incompatible data - if (currentCharacterData.last_realversion and currentCharacterData.last_realversion < Details.realversion) then - --details was been hard upgraded - Details.tabela_historico = Details.historico:NovoHistorico() - Details.tabela_overall = Details.combate:NovaTabela() - Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall) + --pet owners cache saved on logout + do Details.tabela_pets = Details.container_pets:NovoContainer() - Details:UpdateContainerCombatentes() + if (currentCharacterData.tabela_pets) then + --pet ownership table only exists if the player logoff inside a raid or dungeon + Details.tabela_pets.pets = Details.CopyTable(currentCharacterData.tabela_pets) + Details:Destroy(currentCharacterData.tabela_pets) + currentCharacterData.tabela_pets = nil + end + end - currentCharacterData.tabela_historico = nil - currentCharacterData.tabela_overall = nil - else - --check integrity - local combat = Details.tabela_historico.tabelas[1] - if (combat) then - if (not combat[1] or not combat[2] or not combat[3] or not combat[4]) then - --something went wrong in last logon, let's just reset and we are good to go - Details.tabela_historico = Details.historico:NovoHistorico() - Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall) - Details.tabela_pets = Details.container_pets:NovoContainer() - Details:UpdateContainerCombatentes() + --restore saved overall data + do + if (not Details.overall_clear_logout) then + if (currentCharacterData.tabela_overall) then + Details.tabela_overall = Details.CopyTable(currentCharacterData.tabela_overall) + Details:RestoreOverallMetatables() end + else + Details.tabela_overall = Details.combate:NovaTabela() end - end - if (not Details.overall_clear_logout) then if (currentCharacterData.tabela_overall) then - Details.tabela_overall = currentCharacterData.tabela_overall - Details:RestoreOverallMetatables() + Details:Destroy(currentCharacterData.tabela_overall) + currentCharacterData.tabela_overall = nil end - else - Details.tabela_overall = Details.combate:NovaTabela() end - --re-build all indexes and metatables - Details:RestoreMetatables() - - --get lastest combat the player participated - ---@type combat - local firstSegment = Details.tabela_historico.tabelas[1] - - if (firstSegment) then - Details.tabela_vigente = firstSegment - else - Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall) + --restore saved segments + do + Details.tabela_historico = Details.CopyTable(currentCharacterData.tabela_historico) + Details:Destroy(currentCharacterData.tabela_historico) + currentCharacterData.tabela_historico = nil end + --get the first segment saved and use it as current segment + Details.tabela_vigente = Details.tabela_historico.tabelas[1] + --need refresh for all containers for _, actorContainer in ipairs(Details.tabela_overall) do actorContainer.need_refresh = true @@ -179,19 +199,8 @@ function Details222.LoadSavedVariables.CombatSegments() actorContainer.need_refresh = true end - --erase combat data from the database - if (currentCharacterData.tabela_historico) then - Details:Destroy(currentCharacterData.tabela_historico) - end - if (currentCharacterData.tabela_pets) then - Details:Destroy(currentCharacterData.tabela_pets) - end - - --double check for pet container - if (not Details.tabela_pets or not Details.tabela_pets.pets) then - Details.tabela_pets = Details.container_pets:NovoContainer() - end Details:UpdateContainerCombatentes() + Details:RestoreMetatables() end end @@ -348,14 +357,6 @@ function Details:LoadConfig() --apply the profile Details:ApplyProfile(current_profile_name, true) - - --custom - Details.custom = _detalhes_global.custom - if (_detalhes_global.custom and _detalhes_global.custom[1] and _detalhes_global.custom[1].__index and _detalhes_global.custom[1].__index._InstanceLastCombatShown) then - C_Timer.After(5, function() print("|cFFFFAA00Details!|r error 0x8487, report on discord") end) - end - Details.refresh:r_atributo_custom() - end --On Details! Load count logons, tutorials, etc diff --git a/functions/mythicdungeon.lua b/functions/mythicdungeon.lua index b139feb4..4651eae7 100644 --- a/functions/mythicdungeon.lua +++ b/functions/mythicdungeon.lua @@ -809,7 +809,7 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even --reset spec cache if broadcaster requested if (Details.streamer_config.reset_spec_cache) then - wipe (Details.cached_specs) + Details:Destroy (Details.cached_specs) end C_Timer.After(0.5, DetailsMythicPlusFrame.OnChallengeModeStart) diff --git a/functions/pack.lua b/functions/pack.lua index 94a2e745..21fbfb07 100644 --- a/functions/pack.lua +++ b/functions/pack.lua @@ -80,11 +80,11 @@ function Details.packFunctions.PackCombatData(combatObject, flags) --0x8 misc --0x10 no combat header - table.wipe(actorInformation) - table.wipe(actorInformationIndexes) - table.wipe(actorDamageInfo) - table.wipe(actorHealInfo) - table.wipe(actorUtilityInfo) + Details:Destroy(actorInformation) + Details:Destroy(actorInformationIndexes) + Details:Destroy(actorDamageInfo) + Details:Destroy(actorHealInfo) + Details:Destroy(actorUtilityInfo) --reset the serial counter entitySerialCounter = 0 diff --git a/functions/plater.lua b/functions/plater.lua index d5253a09..9ecff4bb 100644 --- a/functions/plater.lua +++ b/functions/plater.lua @@ -114,7 +114,7 @@ function Details:RefreshPlaterIntegration() if (Plater and Details.plater.realtime_dps_enabled or Details.plater.realtime_dps_player_enabled or Details.plater.damage_taken_enabled) then --wipe the cache - wipe (plater_integration_frame.DamageTaken) + Details:Destroy (plater_integration_frame.DamageTaken) --read cleu events plater_integration_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") diff --git a/functions/profiles.lua b/functions/profiles.lua index 90155bf3..78cc6e1a 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -144,7 +144,7 @@ function Details:ResetProfile (profile_name) end --reset the profile - table.wipe(profile.instances) + Details:Destroy(profile.instances) --export first instance local instance = Details:GetInstance(1) @@ -529,7 +529,7 @@ function Details:SaveProfile (saveas) --save skins if (not Details.do_not_save_skins) then - table.wipe(profile.instances) + Details:Destroy(profile.instances) for index, instance in ipairs(Details.tabela_instancias) do local exported = instance:ExportSkin() exported.__was_opened = instance:IsEnabled() @@ -1668,7 +1668,7 @@ function Details:SaveProfileSpecial() end --save skins - table.wipe(profile.instances) + Details:Destroy(profile.instances) if (Details.tabela_instancias) then for index, instance in ipairs(Details.tabela_instancias) do diff --git a/functions/savedata.lua b/functions/savedata.lua index bfcd0cfc..6abc9cae 100644 --- a/functions/savedata.lua +++ b/functions/savedata.lua @@ -1,14 +1,14 @@ --[[this file save the data when player leave the game]] -local _detalhes = _G.Details +local Details = _G.Details local addonName, Details222 = ... -function _detalhes:WipeConfig() +function Details:WipeConfig() local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local wipeButton = CreateFrame("button", "DetailsResetConfigButton", UIParent, "BackdropTemplate") wipeButton:SetSize(270, 40) - wipeButton:SetScript("OnClick", function() _detalhes.wipe_full_config = true; ReloadUI(); end) + wipeButton:SetScript("OnClick", function() Details.wipe_full_config = true; ReloadUI(); end) wipeButton:SetPoint("center", UIParent, "center", 0, 0) tinsert(UISpecialFrames, "DetailsResetConfigButton") @@ -30,18 +30,17 @@ local is_exception = { ["nick_tag_cache"] = true } -function _detalhes:SaveLocalInstanceConfig() - - for index, instance in _detalhes:ListInstances() do +function Details:SaveLocalInstanceConfig() + for index, instance in Details:ListInstances() do --check for the max size toggle, don't save it if (instance.is_in_max_size) then instance.is_in_max_size = false instance:SetSize(instance.original_width, instance.original_height) end - + --save local instance data local a1, a2 = instance:GetDisplay() - + local t = { pos = Details.CopyTable(instance:GetPosition()), is_open = instance:IsEnabled(), @@ -57,13 +56,13 @@ function _detalhes:SaveLocalInstanceConfig() isLocked = instance.isLocked, last_raid_plugin = instance.last_raid_plugin } - + if (t.isLocked == nil) then t.isLocked = false end - - if (_detalhes.profile_save_pos) then - local cprofile = _detalhes:GetProfile() + + if (Details.profile_save_pos) then + local cprofile = Details:GetProfile() local skin = cprofile.instances [instance:GetId()] if (skin) then t.pos = Details.CopyTable(skin.__pos) @@ -74,76 +73,80 @@ function _detalhes:SaveLocalInstanceConfig() t.isLocked = skin.__locked end end - - _detalhes.local_instances_config [index] = t + + Details.local_instances_config [index] = t end end -function _detalhes:SaveConfig() +function Details:SaveConfig() + --save character instance settings, e.g. which attribute is selected, position, etc + Details:SaveLocalInstanceConfig() - --save instance configs localy - _detalhes:SaveLocalInstanceConfig() - --cleanup - - _detalhes:PrepareTablesForSave() + Details:PrepareTablesForSave() - _detalhes_database.tabela_instancias = {} --_detalhes.tabela_instancias --[[instances now saves only inside the profile --]] - _detalhes_database.tabela_historico = _detalhes.tabela_historico - - if (not _detalhes.overall_clear_logout) then - _detalhes_database.tabela_overall = _detalhes.tabela_overall + _detalhes_database.tabela_instancias = {} --Details.tabela_instancias --[[instances now saves only inside the profile --]] + _detalhes_database.tabela_historico = Details.tabela_historico + + if (Details.overall_clear_logout) then + if (_detalhes_database.tabela_overall) then + Details:Destroy(_detalhes_database.tabela_overall) + _detalhes_database.tabela_overall = nil end - - local name, ttype, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo() - if (ttype == "party" or ttype == "raid") then - --salvar container de pet - _detalhes_database.tabela_pets = _detalhes.tabela_pets.pets - end - - xpcall(_detalhes.TimeDataCleanUpTemporary, _detalhes.saver_error_func) - - --buffs - xpcall(_detalhes.Buffs.SaveBuffs, _detalhes.saver_error_func) - + else + _detalhes_database.tabela_overall = Details.tabela_overall + --did it prepared the overall table for save? + end + + local name, instanceType = GetInstanceInfo() + if (instanceType == "party" or instanceType == "raid") then + --save pet ownership information + _detalhes_database.tabela_pets = Details.tabela_pets.pets + end + + --clear temporarly time data (charts) + xpcall(Details.TimeDataCleanUpTemporary, Details.saver_error_func) + + --buffs - feature lost in time + xpcall(Details.Buffs.SaveBuffs, Details.saver_error_func) + --date - _detalhes.last_day = date ("%d") - - --salva o container do personagem - for key, value in pairs(_detalhes.default_player_data) do - if (not is_exception [key]) then - _detalhes_database [key] = _detalhes [key] - end - end - - --salva o container das globais - for key, value in pairs(_detalhes.default_global_data) do - if (key ~= "__profiles") then - _detalhes_global [key] = _detalhes [key] - end - end + Details.last_day = date("%d") - --solo e raid mode - if (_detalhes.SoloTables.Mode) then - _detalhes_database.SoloTablesSaved = {} - _detalhes_database.SoloTablesSaved.Mode = _detalhes.SoloTables.Mode - if (_detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode]) then - _detalhes_database.SoloTablesSaved.LastSelected = _detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode].real_name - end + --save character data (unique for each character) + for key in pairs(Details.default_player_data) do + if (not is_exception[key]) then + _detalhes_database[key] = Details[key] end - - _detalhes_database.RaidTablesSaved = nil - - --salva switch tables - _detalhes_global.switchSaved.slots = _detalhes.switch.slots - _detalhes_global.switchSaved.table = _detalhes.switch.table - - --last boss - _detalhes_database.last_encounter = _detalhes.last_encounter - - --last versions - _detalhes_database.last_realversion = _detalhes.realversion --core number - _detalhes_database.last_version = _detalhes.userversion --version - _detalhes_global.got_first_run = true - + end + + --save shared data (shared among all characters) + for key in pairs(Details.default_global_data) do + if (key ~= "__profiles") then + _detalhes_global[key] = Details[key] + end + end + + --plugin for solo mode (currently none exists) + if (Details.SoloTables.Mode) then + _detalhes_database.SoloTablesSaved = {} + _detalhes_database.SoloTablesSaved.Mode = Details.SoloTables.Mode + if (Details.SoloTables.Plugins[Details.SoloTables.Mode]) then + _detalhes_database.SoloTablesSaved.LastSelected = Details.SoloTables.Plugins[Details.SoloTables.Mode].real_name + end + end + + _detalhes_database.RaidTablesSaved = nil + + --save bookmark tables + _detalhes_global.switchSaved.slots = Details.switch.slots + _detalhes_global.switchSaved.table = Details.switch.table + + --last boss (boss name) + _detalhes_database.last_encounter = Details.last_encounter + + --save the details version of the last time the user logged out + _detalhes_database.last_realversion = Details.realversion --core number + _detalhes_database.last_version = Details.userversion --version + _detalhes_global.got_first_run = true end diff --git a/functions/skins.lua b/functions/skins.lua index dde93311..9d31e9c0 100644 --- a/functions/skins.lua +++ b/functions/skins.lua @@ -1056,7 +1056,8 @@ local addonName, Details222 = ... end - table.wipe(instance1.snap); table.wipe(instance2.snap) + Details:Destroy(instance1.snap) + Details:Destroy(instance2.snap) instance1.snap [3] = 2; instance2.snap [1] = 1; instance1.horizontalSnap = true; instance2.horizontalSnap = true diff --git a/functions/slash.lua b/functions/slash.lua index 11742e5b..1754f73e 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -1,6 +1,6 @@ -local _detalhes = _G.Details +local Details = _G.Details local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local _ local addonName, Details222 = ... @@ -35,54 +35,49 @@ local lowerCase_SLASH_OPTIONS = string.lower(Loc ["STRING_SLASH_OPTIONS"]) local lowerCase_SLASH_WORLDBOSS = string.lower(Loc ["STRING_SLASH_WORLDBOSS"]) function SlashCmdList.DETAILS (msg, editbox) - local command, rest = msg:match("^(%S*)%s*(.-)$") command = string.lower(command) if (command == Loc ["STRING_SLASH_WIPE"] or command == "wipe") then elseif (command == "api") then - _detalhes.OpenAPI() - - + Details.OpenAPI() elseif (command == Loc ["STRING_SLASH_NEW"] or command == "new") then - _detalhes:CriarInstancia(nil, true) + Details:CriarInstancia(nil, true) - elseif (command == Loc ["STRING_SLASH_HISTORY"] or - command == "history" or - command == "score" or - command == "rank" or - command == "ranking" or - command == "statistics" or - command == lowerCase_SLASH_HISTORY or - command == "stats") then - _detalhes:OpenRaidHistoryWindow() + elseif (command == Loc ["STRING_SLASH_HISTORY"] or + command == "history" or + command == "score" or + command == "rank" or + command == "ranking" or + command == "statistics" or + command == lowerCase_SLASH_HISTORY or + command == "stats") then + Details:OpenRaidHistoryWindow() elseif (command == Loc ["STRING_SLASH_TOGGLE"] or command == "toggle") then - local instance = rest:match ("^(%S*)%s*(.-)$") instance = tonumber(instance) if (instance) then - _detalhes:ToggleWindow (instance) + Details:ToggleWindow (instance) else - _detalhes:ToggleWindows() + Details:ToggleWindows() end elseif (command == Loc ["STRING_SLASH_HIDE"] or command == Loc ["STRING_SLASH_HIDE_ALIAS1"] or command == "hide") then - local instance = rest:match ("^(%S*)%s*(.-)$") instance = tonumber(instance) if (instance) then - local this_instance = _detalhes:GetInstance(instance) + local this_instance = Details:GetInstance(instance) if (not this_instance) then - return _detalhes:Msg(Loc ["STRING_WINDOW_NOTFOUND"]) + return Details:Msg(Loc ["STRING_WINDOW_NOTFOUND"]) end if (this_instance:IsEnabled() and this_instance.baseframe) then this_instance:ShutDown() end else - _detalhes:ShutDownAllInstances() + Details:ShutDownAllInstances() end elseif (command == "classtime" or command == "playedclass") then @@ -127,12 +122,12 @@ function SlashCmdList.DETAILS (msg, editbox) dumpt(returnTable) - elseif (command == "mergepetspells") then + elseif (command == "mergepetspells") then --deprecated Details.merge_pet_abilities = not Details.merge_pet_abilities Details:Msg("Merging pet spells:", Details.merge_pet_abilities or "false") elseif (command == "softhide") then - for instanceID, instance in _detalhes:ListInstances() do + for instanceID, instance in Details:ListInstances() do if (instance:IsEnabled()) then if (instance.hide_in_combat_type > 1) then instance:SetWindowAlphaForCombat(true) @@ -141,7 +136,7 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (command == "softshow") then - for instanceID, instance in _detalhes:ListInstances() do + for instanceID, instance in Details:ListInstances() do if (instance:IsEnabled()) then if (instance.hide_in_combat_type > 1) then instance:SetWindowAlphaForCombat(false) @@ -150,7 +145,7 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (command == "softtoggle") then - for instanceID, instance in _detalhes:ListInstances() do + for instanceID, instance in Details:ListInstances() do if (instance:IsEnabled()) then if (instance.hide_in_combat_type > 1) then if (instance.baseframe:GetAlpha() > 0.1) then @@ -165,75 +160,70 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (command == Loc ["STRING_SLASH_SHOW"] or command == Loc ["STRING_SLASH_SHOW_ALIAS1"] or command == "show") then - - _detalhes.LastShowCommand = GetTime() - local instance = rest:match ("^(%S*)%s*(.-)$") - instance = tonumber(instance) - if (instance) then - local this_instance = _detalhes:GetInstance(instance) - if (not this_instance) then - return _detalhes:Msg(Loc ["STRING_WINDOW_NOTFOUND"]) + Details.LastShowCommand = GetTime() + local instanceId = rest:match("^(%S*)%s*(.-)$") + instanceId = tonumber(instanceId) + if (instanceId) then + ---@type instance + local instanceObject = Details:GetInstance(instanceId) + if (not instanceObject) then + return Details:Msg(Loc ["STRING_WINDOW_NOTFOUND"]) end - if (not this_instance:IsEnabled() and this_instance.baseframe) then - this_instance:EnableInstance() + if (not instanceObject:IsEnabled() and instanceObject.baseframe) then + instanceObject:EnableInstance() end else - _detalhes:ReabrirTodasInstancias() + Details:ReabrirTodasInstancias() end elseif (command == Loc ["STRING_SLASH_WIPECONFIG"] or command == "reinstall") then - _detalhes:WipeConfig() + Details:WipeConfig() elseif (command == Loc ["STRING_SLASH_RESET"] or command == Loc ["STRING_SLASH_RESET_ALIAS1"] or command == "reset") then - _detalhes.tabela_historico:resetar() + Details.tabela_historico:resetar() elseif (command == Loc ["STRING_SLASH_DISABLE"] or command == "disable") then - - _detalhes:CaptureSet (false, "damage", true) - _detalhes:CaptureSet (false, "heal", true) - _detalhes:CaptureSet (false, "energy", true) - _detalhes:CaptureSet (false, "miscdata", true) - _detalhes:CaptureSet (false, "aura", true) - _detalhes:CaptureSet (false, "spellcast", true) - + Details:CaptureSet(false, "damage", true) + Details:CaptureSet(false, "heal", true) + Details:CaptureSet(false, "energy", true) + Details:CaptureSet(false, "miscdata", true) + Details:CaptureSet(false, "aura", true) + Details:CaptureSet(false, "spellcast", true) print(Loc ["STRING_DETAILS1"] .. Loc ["STRING_SLASH_CAPTUREOFF"]) elseif (command == Loc ["STRING_SLASH_ENABLE"] or command == "enable") then - - _detalhes:CaptureSet (true, "damage", true) - _detalhes:CaptureSet (true, "heal", true) - _detalhes:CaptureSet (true, "energy", true) - _detalhes:CaptureSet (true, "miscdata", true) - _detalhes:CaptureSet (true, "aura", true) - _detalhes:CaptureSet (true, "spellcast", true) - + Details:CaptureSet(true, "damage", true) + Details:CaptureSet(true, "heal", true) + Details:CaptureSet(true, "energy", true) + Details:CaptureSet(true, "miscdata", true) + Details:CaptureSet(true, "aura", true) + Details:CaptureSet(true, "spellcast", true) print(Loc ["STRING_DETAILS1"] .. Loc ["STRING_SLASH_CAPTUREON"]) elseif (command == Loc ["STRING_SLASH_OPTIONS"] or - command == "options" or - command == lowerCase_SLASH_OPTIONS or - command == "config") then + command == "options" or + command == lowerCase_SLASH_OPTIONS or + command == "config") then if (rest and tonumber(rest)) then local instanceN = tonumber(rest) - if (instanceN > 0 and instanceN <= #_detalhes.tabela_instancias) then - local instance = _detalhes:GetInstance(instanceN) - _detalhes:OpenOptionsWindow (instance) + if (instanceN > 0 and instanceN <= #Details.tabela_instancias) then + local instance = Details:GetInstance(instanceN) + Details:OpenOptionsWindow (instance) end else - local lower_instance = _detalhes:GetLowerInstanceNumber() + local lower_instance = Details:GetLowerInstanceNumber() if (not lower_instance) then - local instance = _detalhes:GetInstance(1) - _detalhes.CriarInstancia (_, _, 1) - _detalhes:OpenOptionsWindow (instance) + local instance = Details:GetInstance(1) + Details.CriarInstancia (_, _, 1) + Details:OpenOptionsWindow (instance) else - _detalhes:OpenOptionsWindow (_detalhes:GetInstance(lower_instance)) + Details:OpenOptionsWindow (Details:GetInstance(lower_instance)) end end - elseif (command == Loc ["STRING_SLASH_WORLDBOSS"] or command == "worldboss" or command == lowerCase_SLASH_WORLDBOSS) then - + elseif (command == Loc ["STRING_SLASH_WORLDBOSS"] or command == "worldboss" or command == lowerCase_SLASH_WORLDBOSS) then --deprecated local questIds = {{"Tarlna the Ageless", 81535}, {"Drov the Ruiner ", 87437}, {"Rukhmar", 87493}} for _, _table in pairs(questIds) do print(format("%s: \124cff%s\124r", _table [1], IsQuestFlaggedCompleted (_table [2]) and "ff0000"..Loc ["STRING_KILLED"] or "00ff00"..Loc ["STRING_ALIVE"])) @@ -248,66 +238,53 @@ function SlashCmdList.DETAILS (msg, editbox) command == Loc ["STRING_SLASH_CHANGES_ALIAS2"] or command == "news" or command == "updates") then - _detalhes:OpenNewsWindow() + Details:OpenNewsWindow() elseif (command == "discord") then - _detalhes:CopyPaste ("https://discord.gg/AGSzAZX") + Details:CopyPaste ("https://discord.gg/AGSzAZX") elseif (command == "m+log") then Details:Dump(Details.mythic_plus_log) elseif (command == "exitlog") then - local newT = {} + local resultLog = {} for _, str in ipairs(_detalhes_global.exit_log) do - newT [#newT+1] = str + resultLog[#resultLog+1] = str end - newT [#newT+1] = "" + resultLog[#resultLog+1] = "" for _, str in ipairs(_detalhes_global.exit_errors) do - newT [#newT+1] = str + resultLog[#resultLog+1] = str end - newT [#newT+1] = "" + resultLog[#resultLog+1] = "" if (__details_backup._exit_error) then for _, str in ipairs(__details_backup._exit_error) do - newT [#newT+1] = str + resultLog[#resultLog+1] = str end end - Details:Dump(newT) + Details:Dump(resultLog) - - elseif (command == "debugwindow") then - - local window1 = Details:GetWindow(1) - if (window1) then - local state = { - ParentName = window1.baseframe:GetParent():GetName(), - Alpha = window1.baseframe:GetAlpha(), - IsShown = window1.baseframe:IsShown(), - IsOpen = window1:IsEnabled() and true or false, - NumPoints = window1.baseframe:GetNumPoints(), - } - - for i = 1, window1.baseframe:GetNumPoints() do - state ["Point" .. i] = {window1.baseframe:GetPoint(i)} + elseif (command == "erasesegment") then + local segmentId = rest and tonumber(rest) + if (segmentId and segmentId ~= 1) then + local segmentToErase = tonumber(segmentId) + local combatObject = tremove(Details.tabela_historico.tabelas, segmentToErase) + if (combatObject) then + Details:Destroy(combatObject) + Details:Msg("segment removed.") + collectgarbage() + else + Details:Msg("segment not found.") end - - local parent = window1.baseframe:GetParent() - - state ["ParentInfo"] = { - Alpha = parent:GetAlpha(), - IsShown = parent:IsShown(), - NumPoints = parent:GetNumPoints(), - } - - Details:Dump (state) else - Details:Msg("Window 1 not found.") + Details:Msg("segment ID invalid.") end + return elseif (command == "bosstimers" or command == "bosstimer" or command == "timer" or command == "timers") then Details.OpenForge() @@ -322,52 +299,31 @@ function SlashCmdList.DETAILS (msg, editbox) _G.DetailsAuraPanel.RefreshWindow() elseif (command == "feedback") then - _detalhes.OpenFeedbackWindow() + Details.OpenFeedbackWindow() elseif (command == "profile") then - if (rest and rest ~= "") then + local profileName = rest + if (profileName and profileName ~= "") then - local profile = _detalhes:GetProfile (rest) + local profile = Details:GetProfile(profileName) if (not profile) then - return _detalhes:Msg("Profile Not Found.") + return Details:Msg("Profile Not Found.") end - if (not _detalhes:ApplyProfile (rest)) then + if (not Details:ApplyProfile(profileName)) then return end - _detalhes:Msg(Loc ["STRING_OPTIONS_PROFILE_LOADED"], rest) + Details:Msg(Loc ["STRING_OPTIONS_PROFILE_LOADED"], profileName) if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then _G.DetailsOptionsWindow:Hide() GameCooltip:Close() end else - _detalhes:Msg("/details profile ") - end - --------- debug --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - - elseif (msg == "exitlog") then - - local exitlog = _detalhes_global.exit_log - local exiterrors = _detalhes_global.exit_errors - - print("EXIT LOG:") - for index, text in ipairs(exitlog) do - print(text) - end - print("ERRORS:") - if (exiterrors) then - for index, text in ipairs(exiterrors) do - print(text) - end - else - print("|cFF00FF00No error occured!|r") + Details:Msg("/details profile ") end elseif (msg == "tr") then - local f = CreateFrame("frame", nil, UIParent) f:SetSize(300, 300) f:SetPoint("center") @@ -387,52 +343,21 @@ function SlashCmdList.DETAILS (msg, editbox) texture:SetTexCoord(math.random(), math.random(), math.random(), math.random(), math.random(), math.random(), math.random(), math.random()) end) - - elseif (msg == "realmsync") then - - _detalhes.realm_sync = not _detalhes.realm_sync - _detalhes:Msg("Realm Sync: ", _detalhes.realm_sync and "Enabled" or "Disabled") - - if (not _detalhes.realm_sync) then - LeaveChannelByName ("Details") - else - _detalhes:CheckChatOnLeaveGroup() - end - elseif (msg == "load") then - print(DetailsDataStorage) - local loaded, reason = LoadAddOn ("Details_DataStorage") print(loaded, reason, DetailsDataStorage) - - elseif (msg == "owner2") then - - local tip = CreateFrame('GameTooltip', 'GuardianOwnerTooltip', nil, 'GameTooltipTemplate') - function GetGuardianOwner(guid) - tip:SetOwner(WorldFrame, 'ANCHOR_NONE') - tip:SetHyperlink('unit:' .. guid or '') - local text = GuardianOwnerTooltipTextLeft2 - --return strmatch(text and text:GetText() or '', "^([^%s']+)'") - return text:GetText() - end - - print(GetGuardianOwner(UnitGUID("target"))) - - elseif (msg == "chat") then - - elseif (msg == "chaticon") then - _detalhes:Msg("|TInterface\\AddOns\\Details\\images\\icones_barra:" .. 14 .. ":" .. 14 .. ":0:0:256:32:0:32:0:32|tteste") + Details:Msg("|TInterface\\AddOns\\Details\\images\\icones_barra:" .. 14 .. ":" .. 14 .. ":0:0:256:32:0:32:0:32|tteste") elseif (msg == "align") then local c = RightChatPanel local w,h = c:GetSize() print(w,h) - local instance1 = _detalhes.tabela_instancias [1] - local instance2 = _detalhes.tabela_instancias [2] + local instance1 = Details.tabela_instancias [1] + local instance2 = Details.tabela_instancias [2] instance1.baseframe:ClearAllPoints() instance2.baseframe:ClearAllPoints() @@ -444,12 +369,12 @@ function SlashCmdList.DETAILS (msg, editbox) instance2.baseframe:SetPoint("bottomright", RightChatToggleButton, "topright", -1, 1) elseif (msg == "pets") then - local f = _detalhes:CreateListPanel() + local f = Details:CreateListPanel() local i = 1 - for k, v in pairs(_detalhes.tabela_pets.pets) do + for k, v in pairs(Details.tabela_pets.pets) do if (v[6] == "Guardian of Ancient Kings") then - _detalhes.ListPanel:add ( k.. ": " .. v[1] .. " | " .. v[2] .. " | " .. v[3] .. " | " .. v[6], i) + Details.ListPanel:add ( k.. ": " .. v[1] .. " | " .. v[2] .. " | " .. v[3] .. " | " .. v[6], i) i = i + 1 end end @@ -457,23 +382,13 @@ function SlashCmdList.DETAILS (msg, editbox) f:Show() elseif (msg == "savepets") then + Details.tabela_vigente.saved_pets = {} - _detalhes.tabela_vigente.saved_pets = {} - - for k, v in pairs(_detalhes.tabela_pets.pets) do - _detalhes.tabela_vigente.saved_pets [k] = {v[1], v[2], v[3]} + for k, v in pairs(Details.tabela_pets.pets) do + Details.tabela_vigente.saved_pets[k] = {v[1], v[2], v[3]} end - _detalhes:Msg("pet table has been saved on current combat.") - - elseif (msg == "move") then - - print("moving...") - - local instance = _detalhes.tabela_instancias [1] - instance.baseframe:ClearAllPoints() - --instance.baseframe:SetPoint("CENTER", UIParent, "CENTER", 300, 100) - instance.baseframe:SetPoint("left", DetailsWelcomeWindow, "right", 10, 0) + Details:Msg("pet table has been saved on current combat.") elseif (msg == "model") then local frame = CreateFrame("PlayerModel"); @@ -482,27 +397,6 @@ function SlashCmdList.DETAILS (msg, editbox) frame:SetWidth(300); frame:SetDisplayInfo (49585); - elseif (msg == "ej2") then - - --[[ get the EJ_ raid id - local wantRaids = true -- set false to get 5-man list - for i=1,1000 do - instanceID,name,description,bgImage,buttonImage,loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceByIndex(i,wantRaids) - if not instanceID then break end - DEFAULT_CHAT_FRAME:AddMessage( instanceID.." "..name ,1,0.7,0.5) - end - --]] - - local iid=362 - - for i=1, 100 do - local name, description, encounterID, rootSectionID, link = DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, iid) - - if not encounterID then break end - local msg = encounterID .. " , " .. name .. ", ".. rootSectionID.. ", "..link - DEFAULT_CHAT_FRAME:AddMessage(msg, 1,0.7,0.5) - end - elseif (msg == "time") then print("GetTime()", GetTime()) print("time()", time()) @@ -512,16 +406,8 @@ function SlashCmdList.DETAILS (msg, editbox) _G.DetailsCopy.MyObject.text:HighlightText() _G.DetailsCopy.MyObject.text:SetFocus() - elseif (msg == "garbage") then - local a = {} - for i = 1, 10000 do - a [i] = {math.random(50000)} - end - table.wipe(a) - elseif (msg == "unitname") then - - local nome, realm = UnitName ("target") + local nome, realm = UnitName("target") if (realm) then nome = nome.."-"..realm end @@ -540,7 +426,7 @@ function SlashCmdList.DETAILS (msg, editbox) print(actorName) - local guid = _detalhes:FindGUIDFromName ("Ditador") + local guid = Details:FindGUIDFromName ("Ditador") print(guid) for i = 1, GetNumGroupMembers()-1, 1 do @@ -549,15 +435,15 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (msg == "cacheparser") then - _detalhes:PrintParserCacheIndexes() + Details:PrintParserCacheIndexes() elseif (msg == "parsercache") then - _detalhes:PrintParserCacheIndexes() + Details:PrintParserCacheIndexes() elseif (msg == "captures") then - for k, v in pairs(_detalhes.capture_real) do + for k, v in pairs(Details.capture_real) do print("real -",k,":",v) end - for k, v in pairs(_detalhes.capture_current) do + for k, v in pairs(Details.capture_current) do print("current -",k,":",v) end @@ -591,19 +477,19 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "bcollor") then --local instancia = _detalhes.tabela_instancias [1] - _detalhes.ResetButton.Middle:SetVertexColor(1, 1, 0, 1) + Details.ResetButton.Middle:SetVertexColor(1, 1, 0, 1) --print(_detalhes.ResetButton:GetHighlightTexture()) - local t = _detalhes.ResetButton:GetHighlightTexture() + local t = Details.ResetButton:GetHighlightTexture() t:SetVertexColor(0, 1, 0, 1) --print(t:GetObjectType()) --_detalhes.ResetButton:SetHighlightTexture(t) - _detalhes.ResetButton:SetNormalTexture(t) + Details.ResetButton:SetNormalTexture(t) - print("backdrop", _detalhes.ResetButton:GetBackdrop()) + print("backdrop", Details.ResetButton:GetBackdrop()) - _detalhes.ResetButton:SetBackdropColor(0, 0, 1, 1) + Details.ResetButton:SetBackdropColor(0, 0, 1, 1) --Details.VarDump (_detalhes.ResetButton) @@ -633,7 +519,7 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (command == "mini") then - local instance = _detalhes.tabela_instancias [1] + local instance = Details.tabela_instancias [1] --Details.VarDump () --print(instance, instance.StatusBar.options, instance.StatusBar.left) print(instance.StatusBar.options [instance.StatusBar.left.mainPlugin.real_name].textSize) @@ -677,13 +563,13 @@ function SlashCmdList.DETAILS (msg, editbox) segment = tonumber(segment or 0) print("dumping buffs of ", playername, segment) - local c = _detalhes:GetCombat("current") + local c = Details:GetCombat("current") if (c) then local playerActor if (segment and segment ~= 0) then - local c = _detalhes:GetCombat(segment) + local c = Details:GetCombat(segment) playerActor = c (4, playername) print("using segment", segment, c, "player actor:", playerActor) else @@ -709,7 +595,7 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "teste") then - local a, b = _detalhes:GetEncounterEnd (1098, 3) + local a, b = Details:GetEncounterEnd (1098, 3) print(a, unpack(b)) elseif (msg == "yesno") then @@ -723,7 +609,7 @@ function SlashCmdList.DETAILS (msg, editbox) print("crop: ", unpack(texCoords)) end - _detalhes.gump:ImageEditor (callback, "Interface\\TALENTFRAME\\bg-paladin-holy", nil, {1, 1, 1, 1}) -- {0.25, 0.25, 0.25, 0.25} + Details.gump:ImageEditor (callback, "Interface\\TALENTFRAME\\bg-paladin-holy", nil, {1, 1, 1, 1}) -- {0.25, 0.25, 0.25, 0.25} elseif (msg == "chat") then @@ -738,15 +624,15 @@ function SlashCmdList.DETAILS (msg, editbox) --debug elseif (command == "resetcapture") then - _detalhes.capture_real = { + Details.capture_real = { ["damage"] = true, ["heal"] = true, ["energy"] = true, ["miscdata"] = true, ["aura"] = true, } - _detalhes.capture_current = _detalhes.capture_real - _detalhes:CaptureRefresh() + Details.capture_current = Details.capture_real + Details:CaptureRefresh() print(Loc ["STRING_DETAILS1"] .. "capture has been reseted.") --debug @@ -754,7 +640,7 @@ function SlashCmdList.DETAILS (msg, editbox) local whichRowLine = rest and tonumber(rest) or 1 - local instancia = _detalhes.tabela_instancias [1] + local instancia = Details.tabela_instancias [1] local barra = instancia.barras [whichRowLine] for i = 1, barra:GetNumPoints() do @@ -763,7 +649,7 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (msg == "opened") then - print("Instances opened: " .. _detalhes.opened_windows) + print("Instances opened: " .. Details.opened_windows) --debug, get a guid of something elseif (command == "backdrop") then --localize-me @@ -906,7 +792,7 @@ function SlashCmdList.DETAILS (msg, editbox) print("Force apply profile: ", profile) - _detalhes:ApplyProfile (profile, false) + Details:ApplyProfile (profile, false) elseif (msg == "version") then Details.ShowCopyValueFrame(Details.GetVersionString()) @@ -952,12 +838,12 @@ function SlashCmdList.DETAILS (msg, editbox) return print("not T found.") end - local f = _detalhes.ListPanel + local f = Details.ListPanel if (not f) then - f = _detalhes:CreateListPanel() + f = Details:CreateListPanel() end - local container = _detalhes.tabela_vigente [t]._NameIndexTable + local container = Details.tabela_vigente [t]._NameIndexTable local i = 0 for name, _ in pairs(container) do @@ -978,12 +864,12 @@ function SlashCmdList.DETAILS (msg, editbox) return print("not T found.") end - local f = _detalhes.ListPanel + local f = Details.ListPanel if (not f) then - f = _detalhes:CreateListPanel() + f = Details:CreateListPanel() end - local container = _detalhes.tabela_vigente [t]._ActorTable + local container = Details.tabela_vigente [t]._ActorTable print(#container, "actors found.") for index, actor in ipairs(container) do f:add (actor.nome, index, filter) @@ -994,7 +880,7 @@ function SlashCmdList.DETAILS (msg, editbox) --debug elseif (msg == "save") then print("running... this is a debug command, details wont work until next /reload.") - _detalhes:PrepareTablesForSave() + Details:PrepareTablesForSave() elseif (msg == "buffs") then for i = 1, 40 do @@ -1016,22 +902,22 @@ function SlashCmdList.DETAILS (msg, editbox) --debug elseif (command == "debugnet") then - if (_detalhes.debugnet) then - _detalhes.debugnet = false + if (Details.debugnet) then + Details.debugnet = false print(Loc["STRING_DETAILS1"] .. "net diagnostic mode has been turned off.") return else - _detalhes.debugnet = true + Details.debugnet = true print(Loc["STRING_DETAILS1"] .. "net diagnostic mode has been turned on.") end elseif (command == "debug") then - if (_detalhes.debug) then - _detalhes.debug = false + if (Details.debug) then + Details.debug = false print(Loc ["STRING_DETAILS1"] .. "diagnostic mode has been turned off.") return else - _detalhes.debug = true + Details.debug = true print(Loc ["STRING_DETAILS1"] .. "diagnostic mode has been turned on.") if (rest and rest ~= "") then @@ -1040,7 +926,7 @@ function SlashCmdList.DETAILS (msg, editbox) print(Loc ["STRING_DETAILS1"] .. "log for characters has been wiped.") return end - _detalhes.debug_chr = rest + Details.debug_chr = rest _detalhes_global.debug_chr_log = _detalhes_global.debug_chr_log or "" print(Loc ["STRING_DETAILS1"] .. "diagnostic for character " .. rest .. " turned on.") return @@ -1049,18 +935,18 @@ function SlashCmdList.DETAILS (msg, editbox) --debug combat log elseif (msg == "combatlog") then - if (_detalhes.isLoggingCombat) then + if (Details.isLoggingCombat) then LoggingCombat (false) print("Wow combatlog record turned OFF.") - _detalhes.isLoggingCombat = nil + Details.isLoggingCombat = nil else LoggingCombat (true) print("Wow combatlog record turned ON.") - _detalhes.isLoggingCombat = true + Details.isLoggingCombat = true end elseif (msg == "gs") then - _detalhes:teste_grayscale() + Details:teste_grayscale() elseif (msg == "bwload") then if not BigWigs then LoadAddOn("BigWigs_Core") end @@ -1089,7 +975,7 @@ function SlashCmdList.DETAILS (msg, editbox) local x, y = GetPlayerMapPosition ("player") if (not DetailsPosBox) then - _detalhes.gump:CreateTextEntry(UIParent, function()end, 200, 20, nil, "DetailsPosBox") + Details.gump:CreateTextEntry(UIParent, function()end, 200, 20, nil, "DetailsPosBox") DetailsPosBox:SetPoint("center", UIParent, "center") end @@ -1104,7 +990,7 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "outline") then - local instancia = _detalhes.tabela_instancias [1] + local instancia = Details.tabela_instancias [1] for _, barra in ipairs(instancia.barras) do local _, _, flags = barra.lineText1:GetFont() print("outline:",flags) @@ -1147,11 +1033,11 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (msg == "forge") then - _detalhes:OpenForge() + Details:OpenForge() elseif (msg == "parser") then - _detalhes:OnParserEvent ( + Details:OnParserEvent ( "COMBAT_LOG_EVENT_UNFILTERED", --evento = 1548754114, --time = "SPELL_DAMAGE", --token = @@ -1209,7 +1095,7 @@ function SlashCmdList.DETAILS (msg, editbox) ["INVTYPE_RANGEDRIGHT"] = true, } - _detalhes:Msg("======== Item Level Debug ========") + Details:Msg("======== Item Level Debug ========") for equip_id = 1, 17 do if (equip_id ~= 4) then --shirt slot @@ -1236,13 +1122,13 @@ function SlashCmdList.DETAILS (msg, editbox) end local average = item_level / item_amount - _detalhes:Msg("gear score: " .. item_level, "| item amount:", item_amount, "| ilvl:", average) + Details:Msg("gear score: " .. item_level, "| item amount:", item_amount, "| ilvl:", average) - _detalhes.ilevel:CalcItemLevel ("player", UnitGUID("player"), true) + Details.ilevel:CalcItemLevel ("player", UnitGUID("player"), true) elseif (msg == "score") then - _detalhes:OpenRaidHistoryWindow ("Hellfire Citadel", 1800, 15, "DAMAGER", "Rock Lobster", 2, "Keyspell") + Details:OpenRaidHistoryWindow ("Hellfire Citadel", 1800, 15, "DAMAGER", "Rock Lobster", 2, "Keyspell") elseif (msg == "bar") then local bar = _G.DetailsTestBar @@ -1293,7 +1179,7 @@ function SlashCmdList.DETAILS (msg, editbox) local y = -50 local allspecs = {} - for a, b in pairs(_detalhes.class_specs_coords) do + for a, b in pairs(Details.class_specs_coords) do tinsert(allspecs, a) end @@ -1337,28 +1223,28 @@ function SlashCmdList.DETAILS (msg, editbox) local f = function(a, b, c, d, e, f, g) print(a, b, c, d, e, f, g) end --instancia:InstanceAlert (Loc ["STRING_PLEASE_WAIT"], {[[Interface\COMMON\StreamCircle]], 22, 22, true}, 5, {f, 1, 2, 3, 4, 5}) - local lower_instance = _detalhes:GetLowerInstanceNumber() + local lower_instance = Details:GetLowerInstanceNumber() if (lower_instance) then - local instance = _detalhes:GetInstance(lower_instance) + local instance = Details:GetInstance(lower_instance) if (instance) then - local func = {_detalhes.OpenRaidHistoryWindow, _detalhes, "Hellfire Citadel", 1800, 15, "DAMAGER", "Rock Lobster", 2, "Keyspell"} + local func = {Details.OpenRaidHistoryWindow, Details, "Hellfire Citadel", 1800, 15, "DAMAGER", "Rock Lobster", 2, "Keyspell"} instance:InstanceAlert ("Boss Defeated, Open History! ", {[[Interface\AddOns\Details\images\icons]], 16, 16, false, 434/512, 466/512, 243/512, 273/512}, 40, func, true) end end elseif (msg == "teste1") then -- /de teste1 - _detalhes:OpenRaidHistoryWindow (1530, 1886, 15, "damage", "Rock Lobster", 2, "Keyspell") --, _role, _guild, _player_base, _player_name) + Details:OpenRaidHistoryWindow (1530, 1886, 15, "damage", "Rock Lobster", 2, "Keyspell") --, _role, _guild, _player_base, _player_name) elseif (msg == "qq") then local my_role = "DAMAGER" local raid_name = "Tomb of Sargeras" local guildName = "Rock Lobster" - local func = {_detalhes.OpenRaidHistoryWindow, _detalhes, raid_name, 2050, 15, my_role, guildName} --, 2, UnitName ("player") + local func = {Details.OpenRaidHistoryWindow, Details, raid_name, 2050, 15, my_role, guildName} --, 2, UnitName ("player") --local icon = {[[Interface\AddOns\Details\images\icons]], 16, 16, false, 434/512, 466/512, 243/512, 273/512} local icon = {[[Interface\PvPRankBadges\PvPRank08]], 16, 16, false, 0, 1, 0, 1} - local lower_instance = _detalhes:GetLowerInstanceNumber() - local instance = _detalhes:GetInstance(lower_instance) + local lower_instance = Details:GetLowerInstanceNumber() + local instance = Details:GetInstance(lower_instance) instance:InstanceAlert ("Boss Defeated! Show Ranking", icon, 10, func, true) @@ -1386,7 +1272,7 @@ function SlashCmdList.DETAILS (msg, editbox) end elseif (msg == "senditemlevel") then - _detalhes:SendCharacterData() + Details:SendCharacterData() print("Item level dispatched.") elseif (msg == "talents") then @@ -1409,17 +1295,17 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "merge") then --at this point, details! should not be in combat - if (_detalhes.in_combat) then - _detalhes:Msg("already in combat, closing current segment.") - _detalhes:SairDoCombate() + if (Details.in_combat) then + Details:Msg("already in combat, closing current segment.") + Details:SairDoCombate() end --create a new combat to be the overall for the mythic run - _detalhes:EntrarEmCombate() + Details:EntrarEmCombate() --get the current combat just created and the table with all past segments - local newCombat = _detalhes:GetCurrentCombat() - local segmentHistory = _detalhes:GetCombatSegments() + local newCombat = Details:GetCurrentCombat() + local segmentHistory = Details:GetCombatSegments() local totalTime = 0 local startDate, endDate = "", "" local lastSegment @@ -1445,7 +1331,7 @@ function SlashCmdList.DETAILS (msg, editbox) end newCombat.is_trash = false - _detalhes:Msg("done merging, segments: " .. segmentsAdded .. ", total time: " .. DetailsFramework:IntegerToTimer(totalTime)) + Details:Msg("done merging, segments: " .. segmentsAdded .. ", total time: " .. DetailsFramework:IntegerToTimer(totalTime)) --[[ --mythic+ debug --tag the segment as mythic overall segment @@ -1469,13 +1355,13 @@ function SlashCmdList.DETAILS (msg, editbox) newCombat.data_fim = endDate --immediatly finishes the segment just started - _detalhes:SairDoCombate() + Details:SairDoCombate() --cleanup the past segments table for i = 25, 1, -1 do local pastCombat = segmentHistory [i] if (pastCombat and pastCombat ~= newCombat) then - wipe (pastCombat) + Details:Destroy(pastCombat) segmentHistory [i] = nil end end @@ -1483,11 +1369,11 @@ function SlashCmdList.DETAILS (msg, editbox) --clear memory collectgarbage() - _detalhes:InstanciaCallFunction(Details.FadeHandler.Fader, "in", nil, "barras") - _detalhes:InstanciaCallFunction(_detalhes.AtualizaSegmentos) - _detalhes:InstanciaCallFunction(_detalhes.AtualizaSoloMode_AfertReset) - _detalhes:InstanciaCallFunction(_detalhes.ResetaGump) - _detalhes:RefreshMainWindow(-1, true) + Details:InstanciaCallFunction(Details.FadeHandler.Fader, "in", nil, "barras") + Details:InstanciaCallFunction(Details.AtualizaSegmentos) + Details:InstanciaCallFunction(Details.AtualizaSoloMode_AfertReset) + Details:InstanciaCallFunction(Details.ResetaGump) + Details:RefreshMainWindow(-1, true) elseif (msg == "ej") then @@ -1572,7 +1458,7 @@ function SlashCmdList.DETAILS (msg, editbox) local t = DetailsFramework:SplitTextInLines(data) local a = {} - local parser = _detalhes.LogParserEvent + local parser = Details.LogParserEvent for i = 1, #t do print("line:", i) @@ -1644,18 +1530,18 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "9") then print("skin:", Details.skin) - print("current profile:", _detalhes:GetCurrentProfileName()) - print("always use profile:", _detalhes.always_use_profile) - print("profile name:", _detalhes.always_use_profile_name) - print("version:", _detalhes.build_counter >= _detalhes.alpha_build_counter and _detalhes.build_counter or _detalhes.alpha_build_counter) + print("current profile:", Details:GetCurrentProfileName()) + print("always use profile:", Details.always_use_profile) + print("profile name:", Details.always_use_profile_name) + print("version:", Details.build_counter >= Details.alpha_build_counter and Details.build_counter or Details.alpha_build_counter) elseif (msg == "record") then - _detalhes.ScheduleLoadStorage() - _detalhes.TellDamageRecord = C_Timer.NewTimer(0.6, _detalhes.PrintEncounterRecord) - _detalhes.TellDamageRecord.Boss = 2032 - _detalhes.TellDamageRecord.Diff = 16 + Details.ScheduleLoadStorage() + Details.TellDamageRecord = C_Timer.NewTimer(0.6, Details.PrintEncounterRecord) + Details.TellDamageRecord.Boss = 2032 + Details.TellDamageRecord.Diff = 16 elseif (msg == "recordtest") then @@ -1680,14 +1566,6 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "auras") then Details.AuraTracker.Open() - elseif (msg == "ec") then - if (rest and tonumber(rest)) then - local combatToErase = tonumber(rest) - tremove(_detalhes.tabela_historico.tabelas, combatToErase) - Details:Msg("combat erased.") - end - return - elseif (msg == "generatespelllist") then Details.GenerateSpecSpellList() @@ -1747,7 +1625,7 @@ function SlashCmdList.DETAILS (msg, editbox) end --local copySegment = f.copy({}, _detalhes.tabela_vigente) - local copySegment = f.copy({}, _detalhes.tabela_historico.tabelas [2]) + local copySegment = f.copy({}, Details.tabela_historico.tabelas [2]) --the segment received is raw and does not have metatables, need to refresh them local zipData = Details:CompressData (copySegment, "print") @@ -1763,15 +1641,15 @@ function SlashCmdList.DETAILS (msg, editbox) if (command) then --check if the line passed is a parameters in the default profile - if (_detalhes.default_profile [command]) then + if (Details.default_profile [command]) then if (rest and (rest ~= "" and rest ~= " ")) then - local whichType = type(_detalhes.default_profile [command]) + local whichType = type(Details.default_profile [command]) --attempt to cast the passed value to the same value as the type in the profile if (whichType == "number") then rest = tonumber(rest) if (rest) then - _detalhes [command] = rest + Details [command] = rest print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' set to " .. rest) else print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' expects a number") @@ -1780,7 +1658,7 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (whichType == "string") then rest = tostring(rest) if (rest) then - _detalhes [command] = rest + Details [command] = rest print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' set to " .. rest) else print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' expects a string") @@ -1788,11 +1666,11 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (whichType == "boolean") then if (rest == "true") then - _detalhes [command] = true + Details [command] = true print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' set to true") elseif (rest == "false") then - _detalhes [command] = false + Details [command] = false print(Loc ["STRING_DETAILS1"] .. "config '" .. command .. "' set to false") else @@ -1801,7 +1679,7 @@ function SlashCmdList.DETAILS (msg, editbox) end else - local value = _detalhes [command] + local value = Details [command] if (type(value) == "boolean") then value = value and "true" or "false" end @@ -1832,7 +1710,7 @@ function Details.RefreshUserList (ignoreIfHidden) return end - local newList = DetailsFramework.table.copy({}, _detalhes.users or {}) + local newList = DetailsFramework.table.copy({}, Details.users or {}) table.sort (newList, function(t1, t2) return t1[3] > t2[3] @@ -2001,20 +1879,20 @@ function Details:UpdateUserPanel(usersTable) DetailsUserPanel:Show() end -function _detalhes:CreateListPanel() - _detalhes.ListPanel = _detalhes.gump:NewPanel(UIParent, nil, "DetailsActorsFrame", nil, 300, 600) - _detalhes.ListPanel:SetPoint("center", UIParent, "center", 300, 0) - _detalhes.ListPanel.barras = {} +function Details:CreateListPanel() + Details.ListPanel = Details.gump:NewPanel(UIParent, nil, "DetailsActorsFrame", nil, 300, 600) + Details.ListPanel:SetPoint("center", UIParent, "center", 300, 0) + Details.ListPanel.barras = {} tinsert(UISpecialFrames, "DetailsActorsFrame") - _detalhes.ListPanel.close_with_right = true + Details.ListPanel.close_with_right = true - local container_barras_window = CreateFrame("ScrollFrame", "Details_ActorsBarrasScroll", _detalhes.ListPanel.widget) + local container_barras_window = CreateFrame("ScrollFrame", "Details_ActorsBarrasScroll", Details.ListPanel.widget) local container_barras = CreateFrame("Frame", "Details_ActorsBarras", container_barras_window) - _detalhes.ListPanel.container = container_barras + Details.ListPanel.container = container_barras - _detalhes.ListPanel.width = 500 - _detalhes.ListPanel.locked = false + Details.ListPanel.width = 500 + Details.ListPanel.locked = false container_barras_window:SetBackdrop({ edgeFile = "Interface\\DialogFrame\\UI-DialogBox-gold-Border", tile = true, tileSize = 16, edgeSize = 5, @@ -2036,9 +1914,9 @@ function _detalhes:CreateListPanel() container_barras_window:SetWidth(460) container_barras_window:SetHeight(550) container_barras_window:SetScrollChild(container_barras) - container_barras_window:SetPoint("TOPLEFT", _detalhes.ListPanel.widget, "TOPLEFT", 21, -10) + container_barras_window:SetPoint("TOPLEFT", Details.ListPanel.widget, "TOPLEFT", 21, -10) - _detalhes.gump:NewScrollBar (container_barras_window, container_barras, -10, -17) + Details.gump:NewScrollBar (container_barras_window, container_barras, -10, -17) container_barras_window.slider:Altura (560) container_barras_window.slider:cimaPoint (0, 1) container_barras_window.slider:baixoPoint (0, -3) @@ -2048,12 +1926,12 @@ function _detalhes:CreateListPanel() container_barras_window.gump = container_barras - function _detalhes.ListPanel:add (text, index, filter) - local row = _detalhes.ListPanel.barras [index] + function Details.ListPanel:add (text, index, filter) + local row = Details.ListPanel.barras [index] if (not row) then - row = {text = _detalhes.ListPanel.container:CreateFontString(nil, "overlay", "GameFontNormal")} - _detalhes.ListPanel.barras [index] = row - row.text:SetPoint("topleft", _detalhes.ListPanel.container, "topleft", 0, -index * 15) + row = {text = Details.ListPanel.container:CreateFontString(nil, "overlay", "GameFontNormal")} + Details.ListPanel.barras [index] = row + row.text:SetPoint("topleft", Details.ListPanel.container, "topleft", 0, -index * 15) end if (filter and text:find(filter)) then @@ -2065,7 +1943,7 @@ function _detalhes:CreateListPanel() row.text:SetText(text) end - return _detalhes.ListPanel + return Details.ListPanel end diff --git a/functions/textures.lua b/functions/textures.lua index 663dc5b4..2b2149ee 100644 --- a/functions/textures.lua +++ b/functions/textures.lua @@ -74,7 +74,7 @@ local texture = portraitPool.inUse[i] releaseTextureForPortraitPool(texture) end - table.wipe(portraitPool.npcIdToTexture) + Details:Destroy(portraitPool.npcIdToTexture) end) eventListener:RegisterEvent("COMBAT_ENCOUNTER_START", function() diff --git a/functions/timedata.lua b/functions/timedata.lua index 0fd0832b..8b171edc 100644 --- a/functions/timedata.lua +++ b/functions/timedata.lua @@ -1,6 +1,6 @@ local _ - local _detalhes = _G.Details + local Details = _G.Details local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local addonName, Details222 = ... @@ -8,9 +8,9 @@ Details222.TimeCapture = {} --mantain the enabled time captures - _detalhes.timeContainer = {} - _detalhes.timeContainer.Exec = {} - + Details.timeContainer = {} + Details.timeContainer.Exec = {} + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --local pointers local ipairs = ipairs @@ -28,121 +28,121 @@ local INDEX_VERSION = 5 local INDEX_ICON = 6 local INDEX_ENABLED = 7 - + local DEFAULT_USER_MATRIX = {max_value = 0, last_value = 0} - + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --register and unregister captures - function _detalhes:TimeDataUpdate (index_or_name, name, func, matrix, author, version, icon, is_enabled) - + function Details:TimeDataUpdate (index_or_name, name, func, matrix, author, version, icon, is_enabled) + local this_capture if (type(index_or_name) == "number") then - this_capture = _detalhes.savedTimeCaptures [index_or_name] + this_capture = Details.savedTimeCaptures [index_or_name] else - for index, t in ipairs(_detalhes.savedTimeCaptures) do + for index, t in ipairs(Details.savedTimeCaptures) do if (t [INDEX_NAME] == index_or_name) then this_capture = t end end end - + if (not this_capture) then return false end - + if (this_capture.do_not_save) then - return _detalhes:Msg("This capture belongs to a plugin and cannot be edited.") + return Details:Msg("This capture belongs to a plugin and cannot be edited.") end - + this_capture [INDEX_NAME] = name or this_capture [INDEX_NAME] this_capture [INDEX_FUNCTION] = func or this_capture [INDEX_FUNCTION] this_capture [INDEX_MATRIX] = matrix or this_capture [INDEX_MATRIX] this_capture [INDEX_AUTHOR] = author or this_capture [INDEX_AUTHOR] this_capture [INDEX_VERSION] = version or this_capture [INDEX_VERSION] this_capture [INDEX_ICON] = icon or this_capture [INDEX_ICON] - + if (is_enabled ~= nil) then this_capture [INDEX_ENABLED] = is_enabled else this_capture [INDEX_ENABLED] = this_capture [INDEX_ENABLED] end - + if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh() end - + return true - + end --matrix = table containing {max_value = 0, last_value = 0} - function _detalhes:TimeDataRegister (name, func, matrix, author, version, icon, is_enabled, force_no_save) - + function Details:TimeDataRegister (name, func, matrix, author, version, icon, is_enabled, force_no_save) + --check name if (not name) then return "Couldn't register the time capture, name was nil." end - + --check if the name already exists - for index, t in ipairs(_detalhes.savedTimeCaptures) do + for index, t in ipairs(Details.savedTimeCaptures) do if (t [INDEX_NAME] == name) then return "Couldn't register the time capture, name already registred." end end - + --check function if (not func) then return "Couldn't register the time capture, invalid function." end - + local no_save = nil --passed a function means that this isn't came from a user --so the plugin register the capture every time it loads. if (type(func) == "function") then no_save = true - + --this a custom capture from a user, so we register a default user table for matrix elseif (type(func) == "string") then matrix = DEFAULT_USER_MATRIX - + end - + if (not no_save and force_no_save) then no_save = true end - + --check matrix if (not matrix or type(matrix) ~= "table") then return "Couldn't register the time capture, matrix was invalid." end - + author = author or "Unknown" version = version or "v1.0" icon = icon or [[Interface\InventoryItems\WoWUnknownItem01]] - - tinsert(_detalhes.savedTimeCaptures, {name, func, matrix, author, version, icon, is_enabled, do_not_save = no_save}) - + + tinsert(Details.savedTimeCaptures, {name, func, matrix, author, version, icon, is_enabled, do_not_save = no_save}) + if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh() end - + return true - + end - + --unregister - function _detalhes:TimeDataUnregister (name) + function Details:TimeDataUnregister (name) if (type(name) == "number") then - tremove(_detalhes.savedTimeCaptures, name) + tremove(Details.savedTimeCaptures, name) if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh() end else - for index, t in ipairs(_detalhes.savedTimeCaptures) do + for index, t in ipairs(Details.savedTimeCaptures) do if (t [INDEX_NAME] == name) then - tremove(_detalhes.savedTimeCaptures, index) + tremove(Details.savedTimeCaptures, index) if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh() end @@ -152,39 +152,39 @@ return false end end - + --cleanup when logout - function _detalhes:TimeDataCleanUpTemporary() - local new_table = {} - for index, t in ipairs(_detalhes.savedTimeCaptures) do + function Details:TimeDataCleanUpTemporary() + local newData = {} + for index, t in ipairs(Details.savedTimeCaptures) do if (not t.do_not_save) then - tinsert(new_table, t) + tinsert(newData, t) end end - _detalhes.savedTimeCaptures = new_table + Details.savedTimeCaptures = newData end local tick_time = 0 - + --starting a combat - function _detalhes:TimeDataCreateCombatTables() - + function Details:TimeDataCreateCombatTables() + --create capture table local data_captured = {} - + --drop the last capture exec table without wiping local exec = {} - _detalhes.timeContainer.Exec = exec - - _detalhes:SendEvent("COMBAT_CHARTTABLES_CREATING") - + Details.timeContainer.Exec = exec + + Details:SendEvent("COMBAT_CHARTTABLES_CREATING") + --build the exec table - for index, t in ipairs(_detalhes.savedTimeCaptures) do + for index, t in ipairs(Details.savedTimeCaptures) do if (t [INDEX_ENABLED]) then - + local data = {} data_captured [t [INDEX_NAME]] = data - + if (type(t [INDEX_FUNCTION]) == "string") then --user local func, errortext = loadstring (t [INDEX_FUNCTION]) @@ -192,7 +192,7 @@ DetailsFramework:SetEnvironment(func) tinsert(exec, { func = func, data = data, attributes = Details.CopyTable(t [INDEX_MATRIX]), is_user = true }) else - _detalhes:Msg("|cFFFF9900error compiling script for time data (charts)|r: ", errortext) + Details:Msg("|cFFFF9900error compiling script for time data (charts)|r: ", errortext) end else --plugin @@ -200,134 +200,134 @@ DetailsFramework:SetEnvironment(func) tinsert(exec, { func = func, data = data, attributes = Details.CopyTable(t [INDEX_MATRIX]) }) end - + end end - - _detalhes:SendEvent("COMBAT_CHARTTABLES_CREATED") - + + Details:SendEvent("COMBAT_CHARTTABLES_CREATED") + tick_time = 0 - + --return the capture table the to combat object return data_captured end - + local exec_user_func = function(func, attributes, data, this_second) - + local okey, result = _pcall (func, attributes) if (not okey) then - _detalhes:Msg("|cFFFF9900error on chart script function|r:", result) + Details:Msg("|cFFFF9900error on chart script function|r:", result) result = 0 end - + local current = result - attributes.last_value data [this_second] = current - + if (current > attributes.max_value) then attributes.max_value = current data.max_value = current end - + attributes.last_value = result - + end - - function _detalhes:TimeDataTick() - + + function Details:TimeDataTick() + tick_time = tick_time + 1 - - for index, t in ipairs(_detalhes.timeContainer.Exec) do - + + for index, t in ipairs(Details.timeContainer.Exec) do + if (t.is_user) then --by a user exec_user_func (t.func, t.attributes, t.data, tick_time) - + else --by a plugin t.func (t.attributes, t.data, tick_time) - + end - + end - + end - + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --broker dps stuff - local ToKFunctions = _detalhes.ToKFunctions + local ToKFunctions = Details.ToKFunctions local broker_functions = { -- raid dps [1] function() - local combat = _detalhes.tabela_vigente + local combat = Details.tabela_vigente local combatTime = combat:GetCombatTime() if (not combatTime or combatTime == 0) then return 0 else - return ToKFunctions [_detalhes.minimap.text_format] (_, combat.totals_grupo[1] / combatTime) + return ToKFunctions [Details.minimap.text_format] (_, combat.totals_grupo[1] / combatTime) end end, -- raid hps [2] function() - local combat = _detalhes.tabela_vigente + local combat = Details.tabela_vigente local combatTime = combat:GetCombatTime() if (not combatTime or combatTime == 0) then return 0 else - return ToKFunctions [_detalhes.minimap.text_format] (_, combat.totals_grupo[2] / combatTime) + return ToKFunctions [Details.minimap.text_format] (_, combat.totals_grupo[2] / combatTime) end end } - + local get_combat_time = function() - local combat_time = _detalhes.tabela_vigente:GetCombatTime() + local combat_time = Details.tabela_vigente:GetCombatTime() local minutos, segundos = _math_floor(combat_time / 60), _math_floor(combat_time % 60) if (segundos < 10) then segundos = "0" .. segundos end return minutos .. "m " .. segundos .. "s" end - + local get_damage_position = function() - local damage_container = _detalhes.tabela_vigente [1] + local damage_container = Details.tabela_vigente [1] damage_container:SortByKey ("total") - + local pos = 1 for index, actor in ipairs(damage_container._ActorTable) do if (actor.grupo) then - if (actor.nome == _detalhes.playername) then + if (actor.nome == Details.playername) then return pos end pos = pos + 1 end end - + return 0 end - + local get_heal_position = function() - local heal_container = _detalhes.tabela_vigente [2] + local heal_container = Details.tabela_vigente [2] heal_container:SortByKey ("total") local pos = 1 for index, actor in ipairs(heal_container._ActorTable) do if (actor.grupo) then - if (actor.nome == _detalhes.playername) then + if (actor.nome == Details.playername) then return pos end pos = pos + 1 end end - + return 0 end - + local get_damage_diff = function() - local damage_container = _detalhes.tabela_vigente [1] + local damage_container = Details.tabela_vigente [1] damage_container:SortByKey ("total") - + local first local first_index for index, actor in ipairs(damage_container._ActorTable) do @@ -339,7 +339,7 @@ end if (first) then - if (first.nome == _detalhes.playername) then + if (first.nome == Details.playername) then local second local container = damage_container._ActorTable for i = first_index+1, #container do @@ -348,32 +348,32 @@ break end end - + if (second) then local diff = first.total - second.total - return "+" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff) + return "+" .. ToKFunctions [Details.minimap.text_format] (_, diff) else return "0" end else - local player = damage_container._NameIndexTable [_detalhes.playername] + local player = damage_container._NameIndexTable [Details.playername] if (player) then player = damage_container._ActorTable [player] local diff = first.total - player.total - return "-" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff) + return "-" .. ToKFunctions [Details.minimap.text_format] (_, diff) else - return ToKFunctions [_detalhes.minimap.text_format] (_, first.total) + return ToKFunctions [Details.minimap.text_format] (_, first.total) end end else return "0" end end - + local get_heal_diff = function() - local heal_container = _detalhes.tabela_vigente [2] + local heal_container = Details.tabela_vigente [2] heal_container:SortByKey ("total") - + local first local first_index for index, actor in ipairs(heal_container._ActorTable) do @@ -383,9 +383,9 @@ break end end - + if (first) then - if (first.nome == _detalhes.playername) then + if (first.nome == Details.playername) then local second local container = heal_container._ActorTable for i = first_index+1, #container do @@ -394,42 +394,42 @@ break end end - + if (second) then local diff = first.total - second.total - return "+" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff) + return "+" .. ToKFunctions [Details.minimap.text_format] (_, diff) else return "0" end else - local player = heal_container._NameIndexTable [_detalhes.playername] + local player = heal_container._NameIndexTable [Details.playername] if (player) then player = heal_container._ActorTable [player] local diff = first.total - player.total - return "-" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff) + return "-" .. ToKFunctions [Details.minimap.text_format] (_, diff) else - return ToKFunctions [_detalhes.minimap.text_format] (_, first.total) + return ToKFunctions [Details.minimap.text_format] (_, first.total) end end else return "0" end end - + local get_player_dps = function() - local damage_player = _detalhes.tabela_vigente(1, _detalhes.playername) + local damage_player = Details.tabela_vigente(1, Details.playername) if (damage_player) then - if (_detalhes.time_type == 1) then --activity time + if (Details.time_type == 1) then --activity time local combat_time = damage_player:Tempo() if (combat_time > 0) then - return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total / combat_time) + return ToKFunctions [Details.minimap.text_format] (_, damage_player.total / combat_time) else return 0 end else --effective time - local combat_time = _detalhes.tabela_vigente:GetCombatTime() + local combat_time = Details.tabela_vigente:GetCombatTime() if (combat_time > 0) then - return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total / combat_time) + return ToKFunctions [Details.minimap.text_format] (_, damage_player.total / combat_time) else return 0 end @@ -439,21 +439,21 @@ return 0 end end - + local get_player_hps = function() - local heal_player = _detalhes.tabela_vigente(2, _detalhes.playername) + local heal_player = Details.tabela_vigente(2, Details.playername) if (heal_player) then - if (_detalhes.time_type == 1) then --activity time + if (Details.time_type == 1) then --activity time local combat_time = heal_player:Tempo() if (combat_time > 0) then - return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total / combat_time) + return ToKFunctions [Details.minimap.text_format] (_, heal_player.total / combat_time) else return 0 end else --effective time - local combat_time = _detalhes.tabela_vigente:GetCombatTime() + local combat_time = Details.tabela_vigente:GetCombatTime() if (combat_time > 0) then - return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total / combat_time) + return ToKFunctions [Details.minimap.text_format] (_, heal_player.total / combat_time) else return 0 end @@ -463,49 +463,49 @@ return 0 end end - + local get_raid_dps = function() - local damage_raid = _detalhes.tabela_vigente and _detalhes.tabela_vigente.totals [1] + local damage_raid = Details.tabela_vigente and Details.tabela_vigente.totals [1] if (damage_raid ) then - return ToKFunctions [_detalhes.minimap.text_format] (_, damage_raid / _detalhes.tabela_vigente:GetCombatTime()) + return ToKFunctions [Details.minimap.text_format] (_, damage_raid / Details.tabela_vigente:GetCombatTime()) else return 0 end end - + local get_raid_hps = function() - local healing_raid = _detalhes.tabela_vigente and _detalhes.tabela_vigente.totals [2] + local healing_raid = Details.tabela_vigente and Details.tabela_vigente.totals [2] if (healing_raid ) then - return ToKFunctions [_detalhes.minimap.text_format] (_, healing_raid / _detalhes.tabela_vigente:GetCombatTime()) + return ToKFunctions [Details.minimap.text_format] (_, healing_raid / Details.tabela_vigente:GetCombatTime()) else return 0 end - end - + end + local get_player_damage = function() - local damage_player = _detalhes.tabela_vigente(1, _detalhes.playername) + local damage_player = Details.tabela_vigente(1, Details.playername) if (damage_player) then - return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total) + return ToKFunctions [Details.minimap.text_format] (_, damage_player.total) else return 0 end end - + local get_player_heal = function() - local heal_player = _detalhes.tabela_vigente(2, _detalhes.playername) + local heal_player = Details.tabela_vigente(2, Details.playername) if (heal_player) then - return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total) + return ToKFunctions [Details.minimap.text_format] (_, heal_player.total) else return 0 end end - + local parse_broker_text = function() - local text = _detalhes.data_broker_text + local text = Details.data_broker_text if (text == "") then return end - + text = text:gsub("{dmg}", get_player_damage) text = text:gsub("{rdps}", get_raid_dps) text = text:gsub("{rhps}", get_raid_hps) @@ -520,21 +520,21 @@ return text end - - function _detalhes:BrokerTick() - _detalhes.databroker.text = parse_broker_text() + + function Details:BrokerTick() + Details.databroker.text = parse_broker_text() end - - function _detalhes:SetDataBrokerText (text) + + function Details:SetDataBrokerText (text) if (type(text) == "string") then - _detalhes.data_broker_text = text - _detalhes:BrokerTick() + Details.data_broker_text = text + Details:BrokerTick() elseif (text == nil or (type(text) == "boolean" and not text)) then - _detalhes.data_broker_text = "" - _detalhes:BrokerTick() + Details.data_broker_text = "" + Details:BrokerTick() end end - + ------------------------------------------------------------------------------------------------------ @@ -605,7 +605,7 @@ function Details222.TimeCapture.StopAllUnitTimers() end Details222.TimeCapture.Stop(unitName) end - wipe(Details222.TimeCapture.Timers) + Details:Destroy(Details222.TimeCapture.Timers) end --can be a manual stop or from the stop all unit frames (function above) diff --git a/startup.lua b/startup.lua index a4808ad8..1f257957 100644 --- a/startup.lua +++ b/startup.lua @@ -510,8 +510,8 @@ function Details:StartMeUp() --dailly reset of the cache for talents and specs local today = date("%d") if (Details.last_day ~= today) then - wipe(Details.cached_specs) - wipe(Details.cached_talents) + Details:Destroy(Details.cached_specs) + Details:Destroy(Details.cached_talents) end --get the player spec @@ -568,12 +568,12 @@ function Details:StartMeUp() if (GetExpansionLevel() == 9) then if (not Details.data_wipes_exp["10"]) then - wipe(Details.encounter_spell_pool or {}) - wipe(Details.boss_mods_timers or {}) - wipe(Details.spell_school_cache or {}) - wipe(Details.spell_pool or {}) - wipe(Details.npcid_pool or {}) - wipe(Details.current_exp_raid_encounters or {}) + Details:Destroy(Details.encounter_spell_pool or {}) + Details:Destroy(Details.boss_mods_timers or {}) + Details:Destroy(Details.spell_school_cache or {}) + Details:Destroy(Details.spell_pool or {}) + Details:Destroy(Details.npcid_pool or {}) + Details:Destroy(Details.current_exp_raid_encounters or {}) Details.data_wipes_exp["10"] = true end end @@ -582,9 +582,9 @@ function Details:StartMeUp() Details.boss_mods_timers.encounter_timers_bw = Details.boss_mods_timers.encounter_timers_bw or {} --clear overall data on new session - if (Details.overall_clear_logout) then - Details.tabela_overall = Details.combate:NovaTabela() - end + --if (Details.overall_clear_logout) then --this is suppose to be in the load data file + -- Details.tabela_overall = Details.combate:NovaTabela() + --end if (not DetailsFramework.IsTimewalkWoW()) then --wipe overall on torghast - REMOVE ON 10.0