You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

996 lines
35 KiB

4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local _detalhes = _G._detalhes
local _tempo = time()
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--local pointers
4 years ago
local _
3 years ago
local pairs = pairs --lua local
local ipairs = ipairs --lua local
4 years ago
local _rawget = rawget --lua local
local _setmetatable = setmetatable --lua local
local _table_remove = table.remove --lua local
local _bit_band = bit.band --lua local
3 years ago
local wipe = table.wipe --lua local
4 years ago
local _time = time --lua local
local _InCombatLockdown = InCombatLockdown --wow api local
local atributo_damage = _detalhes.atributo_damage --details local
local atributo_heal = _detalhes.atributo_heal --details local
local atributo_energy = _detalhes.atributo_energy --details local
local atributo_misc = _detalhes.atributo_misc --details local
local alvo_da_habilidade = _detalhes.alvo_da_habilidade --details local
local habilidade_dano = _detalhes.habilidade_dano --details local
local habilidade_cura = _detalhes.habilidade_cura --details local
local container_habilidades = _detalhes.container_habilidades --details local
local container_combatentes = _detalhes.container_combatentes --details local
local container_damage_target = _detalhes.container_type.CONTAINER_DAMAGETARGET_CLASS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--constants
4 years ago
local class_type_dano = _detalhes.atributos.dano
local class_type_cura = _detalhes.atributos.cura
local class_type_e_energy = _detalhes.atributos.e_energy
local class_type_misc = _detalhes.atributos.misc
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--core
4 years ago
3 years ago
--reconstr�i o mapa do container
4 years ago
local function ReconstroiMapa (tabela)
local mapa = {}
for i = 1, #tabela._ActorTable do
mapa [tabela._ActorTable[i].nome] = i
end
tabela._NameIndexTable = mapa
end
3 years ago
--reaplica as tabelas no overall
4 years ago
function _detalhes:RestauraOverallMetaTables()
3 years ago
local is_in_instance = select(1, IsInInstance())
4 years ago
local combate = _detalhes.tabela_overall
combate.overall_refreshed = true
combate.hasSaved = true
combate.__call = _detalhes.call_combate
_detalhes.refresh:r_combate (combate)
_detalhes.refresh:r_container_combatentes (combate [class_type_dano])
_detalhes.refresh:r_container_combatentes (combate [class_type_cura])
_detalhes.refresh:r_container_combatentes (combate [class_type_e_energy])
_detalhes.refresh:r_container_combatentes (combate [class_type_misc])
_detalhes.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}
3 years ago
for class_type, atributo in ipairs(todos_atributos) do
for _, esta_classe in ipairs(atributo) do
4 years ago
local nome = esta_classe.nome
if (is_in_instance and _detalhes.remove_realm_from_name) then
3 years ago
esta_classe.displayName = nome:gsub(("%-.*"), "")
4 years ago
elseif (_detalhes.remove_realm_from_name) then
3 years ago
esta_classe.displayName = nome:gsub(("%-.*"), "") --"%*"
4 years ago
else
esta_classe.displayName = nome
end
if (class_type == class_type_dano) then
_detalhes.refresh:r_atributo_damage (esta_classe)
elseif (class_type == class_type_cura) then
_detalhes.refresh:r_atributo_heal (esta_classe)
elseif (class_type == class_type_e_energy) then
_detalhes.refresh:r_atributo_energy (esta_classe)
elseif (class_type == class_type_misc) then
_detalhes.refresh:r_atributo_misc (esta_classe)
end
end
end
3 years ago
for class_type, atributo in ipairs(todos_atributos) do
for _, esta_classe in ipairs(atributo) do
if (esta_classe.ownerName) then --nome do owner
4 years ago
esta_classe.owner = combate (class_type, esta_classe.ownerName)
end
end
end
end
3 years ago
--reaplica indexes e metatables
4 years ago
function _detalhes:RestauraMetaTables()
_detalhes.refresh:r_atributo_custom()
3 years ago
--container de pets e hist�rico
4 years ago
_detalhes.refresh:r_container_pets (_detalhes.tabela_pets)
_detalhes.refresh:r_historico (_detalhes.tabela_historico)
3 years ago
--tabelas dos combates
4 years ago
local combate_overall = _detalhes.tabela_overall
3 years ago
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
4 years ago
3 years ago
local tabelas_do_historico = _detalhes.tabela_historico.tabelas --atalho
4 years ago
3 years ago
--recupera meta function
for _, combat_table in ipairs(tabelas_do_historico) do
4 years ago
combat_table.__call = _detalhes.call_combate
end
for i = #tabelas_do_historico-1, 1, -1 do
local combat = tabelas_do_historico [i]
combat.previous_combat = tabelas_do_historico [i+1]
end
3 years ago
--tempo padrao do overall
4 years ago
local overall_saved = combate_overall.overall_refreshed
if (not overall_saved) then
combate_overall.start_time = GetTime()
combate_overall.end_time = GetTime()
end
3 years ago
local is_in_instance = select(1, IsInInstance())
4 years ago
3 years ago
--inicia a recupera��o das tabelas e montagem do overall
4 years ago
if (#tabelas_do_historico > 0) then
3 years ago
for index, combate in ipairs(tabelas_do_historico) do
4 years ago
combate.hasSaved = true
3 years ago
--recupera a meta e indexes da tabela do combate
4 years ago
_detalhes.refresh:r_combate (combate, combate_overall)
3 years ago
--aumenta o tempo do combate do overall, seta as datas e os combates armazenados
4 years ago
if (not overall_saved and combate.overall_added) then
if (combate.end_time and combate.start_time) then
combate_overall.start_time = combate_overall.start_time - (combate.end_time - combate.start_time)
end
--
if (combate_overall.data_inicio == 0) then
combate_overall.data_inicio = combate.data_inicio or 0
end
combate_overall.data_fim = combate.data_fim or combate_overall.data_fim
--
if (not _detalhes.tabela_overall.overall_enemy_name) then
_detalhes.tabela_overall.overall_enemy_name = combate.is_boss and combate.is_boss.name or combate.enemy
else
if (_detalhes.tabela_overall.overall_enemy_name ~= (combate.is_boss and combate.is_boss.name or combate.enemy)) then
_detalhes.tabela_overall.overall_enemy_name = "-- x -- x --"
end
end
combate_overall.segments_added =combate_overall.segments_added or {}
local date_start, date_end = combate:GetDate()
3 years ago
tinsert(combate_overall.segments_added, {name = combate:GetCombatName(true), elapsed = combate:GetCombatTime(), clock = date_start})
4 years ago
end
3 years ago
--recupera a meta e indexes dos 4 container
4 years ago
_detalhes.refresh:r_container_combatentes (combate [class_type_dano], overall_dano)
_detalhes.refresh:r_container_combatentes (combate [class_type_cura], overall_cura)
_detalhes.refresh:r_container_combatentes (combate [class_type_e_energy], overall_energy)
_detalhes.refresh:r_container_combatentes (combate [class_type_misc], overall_misc)
3 years ago
--ghost container
4 years ago
if (combate[5]) then
_detalhes.refresh:r_container_combatentes (combate [5], combate_overall [5])
end
3 years ago
--tabela com os 4 tabelas de jogadores
4 years ago
local todos_atributos = {combate [class_type_dano]._ActorTable, combate [class_type_cura]._ActorTable, combate [class_type_e_energy]._ActorTable, combate [class_type_misc]._ActorTable}
3 years ago
for class_type, atributo in ipairs(todos_atributos) do
for _, esta_classe in ipairs(atributo) do
4 years ago
local nome = esta_classe.nome
if (is_in_instance and _detalhes.remove_realm_from_name) then
3 years ago
esta_classe.displayName = nome:gsub(("%-.*"), "")
4 years ago
elseif (_detalhes.remove_realm_from_name) then
3 years ago
esta_classe.displayName = nome:gsub(("%-.*"), "") --%*
4 years ago
else
esta_classe.displayName = nome
end
local shadow
if (class_type == class_type_dano) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_damage:r_connect_shadow (esta_classe)
else
shadow = atributo_damage:r_onlyrefresh_shadow (esta_classe)
end
elseif (class_type == class_type_cura) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_heal:r_connect_shadow (esta_classe)
else
shadow = atributo_heal:r_onlyrefresh_shadow (esta_classe)
end
elseif (class_type == class_type_e_energy) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_energy:r_connect_shadow (esta_classe)
else
shadow = atributo_energy:r_onlyrefresh_shadow (esta_classe)
end
elseif (class_type == class_type_misc) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_misc:r_connect_shadow (esta_classe)
else
shadow = atributo_misc:r_onlyrefresh_shadow (esta_classe)
end
end
end
end
3 years ago
--reconstr�i a tabela dos pets
for class_type, atributo in ipairs(todos_atributos) do
for _, esta_classe in ipairs(atributo) do
if (esta_classe.ownerName) then --nome do owner
4 years ago
esta_classe.owner = combate (class_type, esta_classe.ownerName)
end
end
end
end
--fim
end
3 years ago
--restaura last_events_table
local primeiro_combate = tabelas_do_historico [1] --primeiro combate
4 years ago
if (primeiro_combate) then
primeiro_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
primeiro_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
end
3 years ago
local segundo_combate = tabelas_do_historico [2] --segundo combate
4 years ago
if (segundo_combate) then
segundo_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
segundo_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
end
end
function _detalhes:DoInstanceCleanup()
3 years ago
--normal instances
for _, esta_instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (esta_instancia.StatusBar.left) then
esta_instancia.StatusBarSaved = {
["left"] = esta_instancia.StatusBar.left.real_name or "NONE",
["center"] = esta_instancia.StatusBar.center.real_name or "NONE",
["right"] = esta_instancia.StatusBar.right.real_name or "NONE",
}
esta_instancia.StatusBarSaved.options = {
[esta_instancia.StatusBarSaved.left] = esta_instancia.StatusBar.left.options,
[esta_instancia.StatusBarSaved.center] = esta_instancia.StatusBar.center.options,
[esta_instancia.StatusBarSaved.right] = esta_instancia.StatusBar.right.options
}
end
3 years ago
--erase all widgets frames
4 years ago
esta_instancia.scroll = nil
esta_instancia.baseframe = nil
esta_instancia.bgframe = nil
esta_instancia.bgdisplay = nil
esta_instancia.freeze_icon = nil
esta_instancia.freeze_texto = nil
esta_instancia.barras = nil
esta_instancia.showing = nil
esta_instancia.agrupada_a = nil
esta_instancia.grupada_pos = nil
esta_instancia.agrupado = nil
esta_instancia._version = nil
esta_instancia.h_baixo = nil
esta_instancia.h_esquerda = nil
esta_instancia.h_direita = nil
esta_instancia.h_cima = nil
esta_instancia.break_snap_button = nil
esta_instancia.alert = nil
esta_instancia.StatusBar = nil
esta_instancia.consolidateFrame = nil
esta_instancia.consolidateButtonTexture = nil
esta_instancia.consolidateButton = nil
esta_instancia.lastIcon = nil
esta_instancia.firstIcon = nil
esta_instancia.menu_attribute_string = nil
esta_instancia.wait_for_plugin_created = nil
esta_instancia.waiting_raid_plugin = nil
esta_instancia.waiting_pid = nil
end
3 years ago
--unused instances
for _, esta_instancia in ipairs(_detalhes.unused_instances) do
4 years ago
if (esta_instancia.StatusBar.left) then
esta_instancia.StatusBarSaved = {
["left"] = esta_instancia.StatusBar.left.real_name or "NONE",
["center"] = esta_instancia.StatusBar.center.real_name or "NONE",
["right"] = esta_instancia.StatusBar.right.real_name or "NONE",
}
esta_instancia.StatusBarSaved.options = {
[esta_instancia.StatusBarSaved.left] = esta_instancia.StatusBar.left.options,
[esta_instancia.StatusBarSaved.center] = esta_instancia.StatusBar.center.options,
[esta_instancia.StatusBarSaved.right] = esta_instancia.StatusBar.right.options
}
end
3 years ago
--erase all widgets frames
4 years ago
esta_instancia.scroll = nil
esta_instancia.baseframe = nil
esta_instancia.bgframe = nil
esta_instancia.bgdisplay = nil
esta_instancia.freeze_icon = nil
esta_instancia.freeze_texto = nil
esta_instancia.barras = nil
esta_instancia.showing = nil
esta_instancia.agrupada_a = nil
esta_instancia.grupada_pos = nil
esta_instancia.agrupado = nil
esta_instancia._version = nil
esta_instancia.h_baixo = nil
esta_instancia.h_esquerda = nil
esta_instancia.h_direita = nil
esta_instancia.h_cima = nil
esta_instancia.break_snap_button = nil
esta_instancia.alert = nil
esta_instancia.StatusBar = nil
esta_instancia.consolidateFrame = nil
esta_instancia.consolidateButtonTexture = nil
esta_instancia.consolidateButton = nil
esta_instancia.lastIcon = nil
esta_instancia.firstIcon = nil
esta_instancia.menu_attribute_string = nil
esta_instancia.wait_for_plugin_created = nil
esta_instancia.waiting_raid_plugin = nil
esta_instancia.waiting_pid = nil
end
end
function _detalhes:DoOwnerCleanup()
local combats = _detalhes.tabela_historico.tabelas or {}
local overall_added
if (not _detalhes.overall_clear_logout) then
3 years ago
tinsert(combats, _detalhes.tabela_overall)
4 years ago
overall_added = true
end
3 years ago
for index, combat in ipairs(combats) do
for index, container in ipairs(combat) do
for index, esta_classe in ipairs(container._ActorTable) do
4 years ago
esta_classe.owner = nil
end
end
end
if (overall_added) then
3 years ago
tremove(combats, #combats)
4 years ago
end
end
function _detalhes:DoClassesCleanup()
local combats = _detalhes.tabela_historico.tabelas or {}
local overall_added
if (not _detalhes.overall_clear_logout) then
3 years ago
tinsert(combats, _detalhes.tabela_overall)
4 years ago
overall_added = true
end
3 years ago
for index, combat in ipairs(combats) do
for class_type, container in ipairs(combat) do
for index, esta_classe in ipairs(container._ActorTable) do
4 years ago
esta_classe.displayName = nil
esta_classe.minha_barra = nil
if (class_type == class_type_dano) then
_detalhes.clear:c_atributo_damage (esta_classe)
elseif (class_type == class_type_cura) then
_detalhes.clear:c_atributo_heal (esta_classe)
elseif (class_type == class_type_e_energy) then
_detalhes.clear:c_atributo_energy (esta_classe)
elseif (class_type == class_type_misc) then
_detalhes.clear:c_atributo_misc (esta_classe)
end
end
end
end
if (overall_added) then
3 years ago
tremove(combats, #combats)
4 years ago
end
end
function _detalhes:DoContainerCleanup()
local combats = _detalhes.tabela_historico.tabelas or {}
local overall_added
if (not _detalhes.overall_clear_logout) then
3 years ago
tinsert(combats, _detalhes.tabela_overall)
4 years ago
overall_added = true
end
3 years ago
for index, combat in ipairs(combats) do
4 years ago
_detalhes.clear:c_combate (combat)
3 years ago
for index, container in ipairs(combat) do
4 years ago
_detalhes.clear:c_container_combatentes (container)
end
end
if (overall_added) then
3 years ago
tremove(combats, #combats)
4 years ago
end
end
function _detalhes:DoContainerIndexCleanup()
local combats = _detalhes.tabela_historico.tabelas or {}
local overall_added
if (not _detalhes.overall_clear_logout) then
3 years ago
tinsert(combats, _detalhes.tabela_overall)
4 years ago
overall_added = true
end
3 years ago
for index, combat in ipairs(combats) do
for index, container in ipairs(combat) do
4 years ago
_detalhes.clear:c_container_combatentes_index (container)
end
end
if (overall_added) then
3 years ago
tremove(combats, #combats)
4 years ago
end
end
3 years ago
--limpa indexes, metatables e shadows
4 years ago
function _detalhes:PrepareTablesForSave()
_detalhes.clear_ungrouped = true
3 years ago
--clear instances
4 years ago
_detalhes:DoInstanceCleanup()
_detalhes:DoClassesCleanup() --aumentou 1 combat
_detalhes:DoContainerCleanup() --aumentou 1 combat
3 years ago
--clear combats
4 years ago
local tabelas_de_combate = {}
local historico_tabelas = _detalhes.tabela_historico.tabelas or {}
3 years ago
--remove os segmentos de trash
4 years ago
for i = #historico_tabelas, 1, -1 do
local combate = historico_tabelas [i]
if (combate:IsTrash()) then
table.remove (historico_tabelas, i)
end
end
3 years ago
--remove os segmentos > que o limite permitido para salvar
4 years ago
if (_detalhes.segments_amount_to_save and _detalhes.segments_amount_to_save < _detalhes.segments_amount) then
for i = _detalhes.segments_amount, _detalhes.segments_amount_to_save+1, -1 do
if (_detalhes.tabela_historico.tabelas [i]) then
table.remove (_detalhes.tabela_historico.tabelas, i)
end
end
end
3 years ago
--tabela do combate atual
4 years ago
local tabela_atual = _detalhes.tabela_vigente or _detalhes.combate:NovaTabela (_, _detalhes.tabela_overall)
3 years ago
--limpa a tabela overall
4 years ago
if (_detalhes.overall_clear_logout) then
_detalhes.tabela_overall = nil
_detalhes_database.tabela_overall = nil
else
local _combate = _detalhes.tabela_overall
_combate.previous_combat = nil
local todos_atributos = {_combate [class_type_dano] or {}, _combate [class_type_cura] or {}, _combate [class_type_e_energy] or {}, _combate [class_type_misc] or {}}
3 years ago
for class_type, _tabela in ipairs(todos_atributos) do
4 years ago
local conteudo = _tabela._ActorTable
3 years ago
--Limpa tabelas que n�o estejam em grupo
4 years ago
if (conteudo) then
if (_detalhes.clear_ungrouped) then
--if (not _detalhes.clear_ungrouped) then
3 years ago
local _iter = {index = 1, data = conteudo[1], cleaned = 0} --._ActorTable[1] para pegar o primeiro index
4 years ago
while (_iter.data) do --search key: ~deletar ~apagar
local can_erase = true
if (_iter.data.grupo or _iter.data.boss or _iter.data.boss_fight_component or _iter.data.pvp_component or _iter.data.fight_component) then
can_erase = false
else
local owner = _iter.data.owner
if (owner) then
local owner_actor = _combate [class_type]._NameIndexTable [owner.nome]
if (owner_actor) then
local owner_actor = _combate [class_type]._ActorTable [owner_actor]
if (owner_actor) then
if (owner.grupo or owner.boss or owner.boss_fight_component or owner.fight_component) then
can_erase = false
end
end
end
end
end
if (can_erase) then
3 years ago
_table_remove(conteudo, _iter.index)
4 years ago
_iter.cleaned = _iter.cleaned + 1
_iter.data = conteudo [_iter.index]
else
_iter.index = _iter.index + 1
_iter.data = conteudo [_iter.index]
end
end
if (_iter.cleaned > 0) then
ReconstroiMapa (_tabela)
end
end
end
end
end
3 years ago
for _, _tabela in ipairs(historico_tabelas) do
4 years ago
tabelas_de_combate [#tabelas_de_combate+1] = _tabela
end
3 years ago
for tabela_index, _combate in ipairs(tabelas_de_combate) do
4 years ago
3 years ago
--limpa a tabela do grafico
4 years ago
if (_detalhes.clear_graphic) then
_combate.TimeData = {}
end
3 years ago
--limpa a referencia do ultimo combate
4 years ago
_combate.previous_combat = nil
local container_dano = _combate [class_type_dano] or {}
local container_cura = _combate [class_type_cura] or {}
local container_e_energy = _combate [class_type_e_energy] or {}
local container_misc = _combate [class_type_misc] or {}
local todos_atributos = {container_dano, container_cura, container_e_energy, container_misc}
local IsBossEncounter = _combate.is_boss
if (IsBossEncounter) then
if (_combate.pvp) then
IsBossEncounter = false
end
end
if (not _combate.is_mythic_dungeon_segment) then
3 years ago
for class_type, _tabela in ipairs(todos_atributos) do
4 years ago
local conteudo = _tabela._ActorTable
3 years ago
--Limpa tabelas que n�o estejam em grupo
4 years ago
if (conteudo) then
if (_detalhes.clear_ungrouped) then
--n�o deleta dummies e actors de fora do grupo
--if (not _detalhes.clear_ungrouped) then
3 years ago
local _iter = {index = 1, data = conteudo[1], cleaned = 0} --._ActorTable[1] para pegar o primeiro index
4 years ago
while (_iter.data) do --search key: ~deletar ~apagar
local can_erase = true
if (_iter.data.grupo or _iter.data.boss or _iter.data.boss_fight_component or IsBossEncounter or _iter.data.pvp_component or _iter.data.fight_component) then
can_erase = false
else
local owner = _iter.data.owner
if (owner) then
local owner_actor = _combate [class_type]._NameIndexTable [owner.nome]
if (owner_actor) then
local owner_actor = _combate [class_type]._ActorTable [owner_actor]
if (owner_actor) then
if (owner.grupo or owner.boss or owner.boss_fight_component or owner.fight_component) then
can_erase = false
end
end
end
end
end
if (can_erase) then
3 years ago
if (not _iter.data.owner) then --pet
4 years ago
local myself = _iter.data
if (myself.tipo == class_type_dano or myself.tipo == class_type_cura) then
_combate.totals [myself.tipo] = _combate.totals [myself.tipo] - myself.total
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] = _combate.totals_grupo [myself.tipo] - myself.total
end
elseif (myself.tipo == class_type_e_energy) then
_combate.totals [myself.tipo] [myself.powertype] = _combate.totals [myself.tipo] [myself.powertype] - myself.total
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] [myself.powertype] = _combate.totals_grupo [myself.tipo] [myself.powertype] - myself.total
end
elseif (myself.tipo == class_type_misc) then
if (myself.cc_break) then
_combate.totals [myself.tipo] ["cc_break"] = _combate.totals [myself.tipo] ["cc_break"] - myself.cc_break
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["cc_break"] = _combate.totals_grupo [myself.tipo] ["cc_break"] - myself.cc_break
end
end
if (myself.ress) then
_combate.totals [myself.tipo] ["ress"] = _combate.totals [myself.tipo] ["ress"] - myself.ress
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["ress"] = _combate.totals_grupo [myself.tipo] ["ress"] - myself.ress
end
end
3 years ago
--n�o precisa diminuir o total dos buffs e debuffs
4 years ago
if (myself.cooldowns_defensive) then
_combate.totals [myself.tipo] ["cooldowns_defensive"] = _combate.totals [myself.tipo] ["cooldowns_defensive"] - myself.cooldowns_defensive
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["cooldowns_defensive"] = _combate.totals_grupo [myself.tipo] ["cooldowns_defensive"] - myself.cooldowns_defensive
end
end
if (myself.interrupt) then
_combate.totals [myself.tipo] ["interrupt"] = _combate.totals [myself.tipo] ["interrupt"] - myself.interrupt
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["interrupt"] = _combate.totals_grupo [myself.tipo] ["interrupt"] - myself.interrupt
end
end
if (myself.dispell) then
_combate.totals [myself.tipo] ["dispell"] = _combate.totals [myself.tipo] ["dispell"] - myself.dispell
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["dispell"] = _combate.totals_grupo [myself.tipo] ["dispell"] - myself.dispell
end
end
if (myself.dead) then
_combate.totals [myself.tipo] ["dead"] = _combate.totals [myself.tipo] ["dead"] - myself.dead
if (myself.grupo) then
_combate.totals_grupo [myself.tipo] ["dead"] = _combate.totals_grupo [myself.tipo] ["dead"] - myself.dead
end
end
end
end
3 years ago
_table_remove(conteudo, _iter.index)
4 years ago
_iter.cleaned = _iter.cleaned + 1
_iter.data = conteudo [_iter.index]
else
_iter.index = _iter.index + 1
_iter.data = conteudo [_iter.index]
end
end
if (_iter.cleaned > 0) then
ReconstroiMapa (_tabela)
end
end
end
end
end --end is mythic dungeon segment
end
3 years ago
--panic mode
4 years ago
if (_detalhes.segments_panic_mode and _detalhes.can_panic_mode) then
if (_detalhes.tabela_vigente.is_boss) then
_detalhes.tabela_historico = _detalhes.historico:NovoHistorico()
end
end
3 years ago
--clear all segments on logoff
4 years ago
if (_detalhes.data_cleanup_logout) then
_detalhes.tabela_historico = _detalhes.historico:NovoHistorico()
_detalhes.tabela_overall = nil
_detalhes_database.tabela_overall = nil
end
3 years ago
--clear customs
4 years ago
_detalhes.clear:c_atributo_custom()
3 years ago
--clear owners
4 years ago
_detalhes:DoOwnerCleanup()
3 years ago
--cleaer container indexes
4 years ago
_detalhes:DoContainerIndexCleanup()
end
function _detalhes:reset_window (instancia)
if (instancia.segmento == -1) then
instancia.showing[instancia.atributo].need_refresh = true
instancia.v_barras = true
instancia:ResetaGump()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
end
end
--desativado 7.2.5 veio com algum bug e a checagem de memoria esta sendo feita durante o combate
function _detalhes:CheckMemoryAfterCombat()
3 years ago
if (_detalhes.next_memory_check < time() and not InCombatLockdown() and not UnitAffectingCombat("player")) then
4 years ago
_detalhes.next_memory_check = time()+_detalhes.intervalo_memoria
UpdateAddOnMemoryUsage()
local memory = GetAddOnMemoryUsage ("Details")
if (memory > _detalhes.memory_ram) then
3 years ago
_detalhes:IniciarColetaDeLixo (true, 60) --sending true doesn't check anythink
4 years ago
end
end
end
function _detalhes:CheckMemoryPeriodically()
3 years ago
if (_detalhes.next_memory_check <= time() and not _InCombatLockdown() and not _detalhes.in_combat and not UnitAffectingCombat("player")) then
4 years ago
_detalhes.next_memory_check = time() + _detalhes.intervalo_memoria - 3
UpdateAddOnMemoryUsage()
local memory = GetAddOnMemoryUsage ("Details")
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) checking memory periodically. Using: ",math.floor(memory))
4 years ago
end
if (memory > _detalhes.memory_ram * 1000) then
3 years ago
_detalhes:IniciarColetaDeLixo (1, 60) --sending 1 only check for combat and ignore garbage collect cooldown
4 years ago
end
end
end
function _detalhes:IniciarColetaDeLixo (forcar, lastevent)
if (not forcar) then
if (_detalhes.ultima_coleta + _detalhes.intervalo_coleta > _detalhes._tempo + 1) then
return
elseif (_detalhes.in_combat or _InCombatLockdown() or _detalhes:IsInInstance()) then
3 years ago
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5)
4 years ago
return
end
else
3 years ago
if (type(forcar) ~= "boolean") then
4 years ago
if (forcar == 1) then
if (_detalhes.in_combat or _InCombatLockdown()) then
3 years ago
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5, forcar)
4 years ago
return
end
end
end
end
if (_detalhes.debug) then
if (forcar) then
3 years ago
_detalhes:Msg("(debug) collecting garbage with forced state: ", forcar)
4 years ago
else
3 years ago
_detalhes:Msg("(debug) collecting garbage.")
4 years ago
end
end
local memory = GetAddOnMemoryUsage ("Details")
3 years ago
--reseta o cache do parser
4 years ago
_detalhes:ClearParserCache()
3 years ago
--limpa barras que n�o est�o sendo usadas nas inst�ncias.
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instancia.barras and instancia.barras [1]) then
3 years ago
for i, barra in ipairs(instancia.barras) do
4 years ago
if (not barra:IsShown()) then
barra.minha_tabela = nil
end
end
end
end
3 years ago
--faz a coleta nos 4 atributos
4 years ago
local damage = atributo_damage:ColetarLixo (lastevent)
local heal = atributo_heal:ColetarLixo (lastevent)
local energy = atributo_energy:ColetarLixo (lastevent)
local misc = atributo_misc:ColetarLixo (lastevent)
local limpados = damage + heal + energy + misc
3 years ago
--refresh nas janelas
4 years ago
if (limpados > 0) then
3 years ago
_detalhes:InstanciaCallFunction(_detalhes.reset_window)
4 years ago
end
_detalhes:ManutencaoTimeMachine()
3 years ago
--print cache states
4 years ago
--if (_detalhes.debug) then
3 years ago
-- _detalhes:Msg("(debug) removed: damage "..damage.." heal "..heal.." energy "..energy.." misc "..misc)
4 years ago
--end
3 years ago
--elimina pets antigos
4 years ago
_detalhes:LimparPets()
if (not _detalhes.in_combat) then
_detalhes:ClearCCPetsBlackList()
end
3 years ago
--reseta cache de specs
4 years ago
_detalhes:ResetSpecCache()
3 years ago
--wipa container de escudos
wipe(_detalhes.escudos)
4 years ago
_detalhes.ultima_coleta = _detalhes._tempo
if (_detalhes.debug) then
collectgarbage()
UpdateAddOnMemoryUsage()
--local memory2 = GetAddOnMemoryUsage ("Details")
3 years ago
--_detalhes:Msg("(debug) memory before: "..memory.." memory after: "..memory2)
4 years ago
end
end
3 years ago
--combates Normais
4 years ago
local function FazColeta (_combate, tipo, intervalo_overwrite)
local conteudo = _combate [tipo]._ActorTable
local _iter = {index = 1, data = conteudo[1], cleaned = 0}
local _tempo = _time()
--local links_removed = 0
--do not collect things in a mythic+ dungeon segment
if (_combate.is_mythic_dungeon_trash or _combate.is_mythic_dungeon_run_id or _combate.is_mythic_dungeon_segment) then
return 0
end
while (_iter.data) do
local _actor = _iter.data
local can_garbage = false
local t
if (intervalo_overwrite) then
t = _actor.last_event + intervalo_overwrite
else
t = _actor.last_event + _detalhes.intervalo_coleta
end
if (t < _tempo and not _actor.grupo and not _actor.boss and not _actor.fight_component and not _actor.boss_fight_component) then
local owner = _actor.owner
if (owner) then
local owner_actor = _combate (tipo, owner.nome)
if (not owner.grupo and not owner.boss and not owner.boss_fight_component) then
can_garbage = true
end
else
can_garbage = true
end
end
if (can_garbage) then
3 years ago
if (not _actor.owner) then --pet
4 years ago
_actor:subtract_total (_combate)
end
_iter.cleaned = _iter.cleaned+1
if (_actor.tipo == 1 or _actor.tipo == 2) then
_actor:DesregistrarNaTimeMachine()
end
3 years ago
_table_remove(conteudo, _iter.index)
4 years ago
_iter.data = conteudo [_iter.index]
else
_iter.index = _iter.index + 1
_iter.data = conteudo [_iter.index]
end
end
--if (_detalhes.debug) then
3 years ago
-- _detalhes:Msg("- garbage collect:", tipo, "actors removed:",_iter.cleaned)
4 years ago
--end
if (_iter.cleaned > 0) then
ReconstroiMapa (_combate [tipo])
_combate [tipo].need_refresh = true
end
return _iter.cleaned
end
3 years ago
--Combate overall
4 years ago
function _detalhes:ColetarLixo (tipo, lastevent)
3 years ago
--print("fazendo coleta...")
4 years ago
local _tempo = _time()
local limpados = 0
3 years ago
--monta a lista de combates
4 years ago
local tabelas_de_combate = {}
3 years ago
for _, _tabela in ipairs(_detalhes.tabela_historico.tabelas) do
4 years ago
if (_tabela ~= _detalhes.tabela_vigente) then
tabelas_de_combate [#tabelas_de_combate+1] = _tabela
end
end
tabelas_de_combate [#tabelas_de_combate+1] = _detalhes.tabela_vigente
3 years ago
--faz a coleta em todos os combates para este atributo
for _, _combate in ipairs(tabelas_de_combate) do
4 years ago
limpados = limpados + FazColeta (_combate, tipo, lastevent)
end
3 years ago
--limpa a tabela overall para o atributo atual (limpa para os 4, um de cada vez atrav�s do ipairs)
4 years ago
local _overall_combat = _detalhes.tabela_overall
local conteudo = _overall_combat [tipo]._ActorTable
3 years ago
local _iter = {index = 1, data = conteudo[1], cleaned = 0} --._ActorTable[1] para pegar o primeiro index
4 years ago
while (_iter.data) do
local _actor = _iter.data
local can_garbage = false
if (not _actor.grupo and not _actor.owner and not _actor.boss_fight_component and not _actor.fight_component) then
can_garbage = true
end
3 years ago
if (can_garbage) then --n�o h� refer�ncias a este objeto
4 years ago
3 years ago
if (not _actor.owner) then --pet
4 years ago
_actor:subtract_total (_overall_combat)
end
3 years ago
--apaga a refer�ncia deste jogador na tabela overall
4 years ago
_iter.cleaned = _iter.cleaned+1
3 years ago
_table_remove(conteudo, _iter.index)
4 years ago
_iter.data = conteudo [_iter.index]
else
_iter.index = _iter.index + 1
_iter.data = conteudo [_iter.index]
end
end
3 years ago
--termina o coletor de lixo
4 years ago
if (_iter.cleaned > 0) then
_overall_combat[tipo].need_refresh = true
ReconstroiMapa (_overall_combat [tipo])
limpados = limpados + _iter.cleaned
end
if (limpados > 0) then
3 years ago
_detalhes:InstanciaCallFunction(_detalhes.ScheduleUpdate)
_detalhes:RefreshMainWindow(-1)
4 years ago
end
return limpados
end