Replacing table.wipe with Details:Destroy()

This commit is contained in:
Tercio Jose
2023-05-22 15:31:29 -03:00
parent fa0d1e1d08
commit 0cdfa2b900
40 changed files with 1205 additions and 1322 deletions
+4 -4
View File
@@ -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()
+14 -14
View File
@@ -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
+5 -5
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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], "", "", ""}
+19 -1
View File
@@ -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
+2 -3
View File
@@ -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()
+174 -161
View File
@@ -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 histrico
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 --no 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 histrico
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 esto 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 funo que ir atualizar as instncias com segmentos no histrico
--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 recm 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 informaes 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) --forar
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