More progress on caching stuff; journal links; cooltip hotfixes; code cleanups

This commit is contained in:
Tercio Jose
2022-12-23 20:33:29 -03:00
parent ce9a3b875b
commit 7d5d80073b
10 changed files with 416 additions and 161 deletions
+51 -59
View File
@@ -17,10 +17,10 @@
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 classDamage = _detalhes.atributo_damage --details local
local classHeal = _detalhes.atributo_heal --details local
local classEnergy = _detalhes.atributo_energy --details local
local classUtility = _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
@@ -216,30 +216,30 @@
if (class_type == class_type_dano) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_damage:r_connect_shadow (esta_classe)
shadow = classDamage:r_connect_shadow (esta_classe)
else
shadow = atributo_damage:r_onlyrefresh_shadow (esta_classe)
shadow = classDamage: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)
shadow = classHeal:r_connect_shadow (esta_classe)
else
shadow = atributo_heal:r_onlyrefresh_shadow (esta_classe)
shadow = classHeal: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)
shadow = classEnergy:r_connect_shadow (esta_classe)
else
shadow = atributo_energy:r_onlyrefresh_shadow (esta_classe)
shadow = classEnergy: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)
shadow = classUtility:r_connect_shadow (esta_classe)
else
shadow = atributo_misc:r_onlyrefresh_shadow (esta_classe)
shadow = classUtility:r_onlyrefresh_shadow (esta_classe)
end
end
@@ -262,14 +262,14 @@
--restaura last_events_table
local primeiro_combate = tabelas_do_historico [1] --primeiro combate
if (primeiro_combate) then
primeiro_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
primeiro_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
primeiro_combate [1]:ActorCallFunction (classDamage.r_last_events_table)
primeiro_combate [2]:ActorCallFunction (classHeal.r_last_events_table)
end
local segundo_combate = tabelas_do_historico [2] --segundo combate
if (segundo_combate) then
segundo_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
segundo_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
segundo_combate [1]:ActorCallFunction (classDamage.r_last_events_table)
segundo_combate [2]:ActorCallFunction (classHeal.r_last_events_table)
end
end
@@ -748,7 +748,7 @@
UpdateAddOnMemoryUsage()
local memory = GetAddOnMemoryUsage ("Details")
if (memory > _detalhes.memory_ram) then
_detalhes:IniciarColetaDeLixo (true, 60) --sending true doesn't check anythink
_detalhes:RestartInternalGarbageCollector (true, 60) --sending true doesn't check anythink
end
end
end
@@ -762,25 +762,25 @@
_detalhes:Msg("(debug) checking memory periodically. Using: ",math.floor(memory))
end
if (memory > _detalhes.memory_ram * 1000) then
_detalhes:IniciarColetaDeLixo (1, 60) --sending 1 only check for combat and ignore garbage collect cooldown
_detalhes:RestartInternalGarbageCollector (1, 60) --sending 1 only check for combat and ignore garbage collect cooldown
end
end
end
function _detalhes:IniciarColetaDeLixo (forcar, lastevent)
if (not forcar) then
function _detalhes:RestartInternalGarbageCollector(bShouldForceCollect, lastEvent)
if (not bShouldForceCollect) then
if (_detalhes.ultima_coleta + _detalhes.intervalo_coleta > _detalhes._tempo + 1) then
return
elseif (_detalhes.in_combat or _InCombatLockdown() or _detalhes:IsInInstance()) then
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5)
_detalhes:ScheduleTimer("RestartInternalGarbageCollector", 5)
return
end
else
if (type(forcar) ~= "boolean") then
if (forcar == 1) then
if (type(bShouldForceCollect) ~= "boolean") then
if (bShouldForceCollect == 1) then
if (_detalhes.in_combat or _InCombatLockdown()) then
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5, forcar)
_detalhes:ScheduleTimer("RestartInternalGarbageCollector", 5, bShouldForceCollect)
return
end
end
@@ -788,70 +788,62 @@
end
if (_detalhes.debug) then
if (forcar) then
_detalhes:Msg("(debug) collecting garbage with forced state: ", forcar)
if (bShouldForceCollect) then
_detalhes:Msg("(debug) collecting garbage with forced state:", bShouldForceCollect)
else
_detalhes:Msg("(debug) collecting garbage.")
end
end
local memory = GetAddOnMemoryUsage ("Details")
--cleanup all the parser caches
Details:ClearParserCache()
--reseta o cache do parser
_detalhes:ClearParserCache()
--limpa barras que no esto sendo usadas nas instncias.
for index, instancia in ipairs(_detalhes.tabela_instancias) do
if (instancia.barras and instancia.barras [1]) then
for i, barra in ipairs(instancia.barras) do
if (not barra:IsShown()) then
barra.minha_tabela = nil
--cleanup all the window lines (bars) which isn't in use
for index, instanceObject in ipairs(Details.tabela_instancias) do
if (instanceObject.barras and instanceObject.barras[1]) then
for i, lineRow in ipairs(instanceObject.barras) do
if (not lineRow:IsShown()) then
lineRow.minha_tabela = nil
end
end
end
end
--faz a coleta nos 4 atributos
local damage = atributo_damage:ColetarLixo (lastevent)
local heal = atributo_heal:ColetarLixo (lastevent)
local energy = atributo_energy:ColetarLixo (lastevent)
local misc = atributo_misc:ColetarLixo (lastevent)
--do garbage collection on the handler for each actor class
local damage = classDamage:ColetarLixo(lastEvent)
local heal = classHeal:ColetarLixo(lastEvent)
local energy = classEnergy:ColetarLixo(lastEvent)
local misc = classUtility:ColetarLixo(lastEvent)
local limpados = damage + heal + energy + misc
--refresh nas janelas
if (limpados > 0) then
_detalhes:InstanciaCallFunction(_detalhes.reset_window)
Details:InstanciaCallFunction(_detalhes.reset_window)
end
_detalhes:ManutencaoTimeMachine()
Details:ManutencaoTimeMachine()
--print cache states
--if (_detalhes.debug) then
-- _detalhes:Msg("(debug) removed: damage "..damage.." heal "..heal.." energy "..energy.." misc "..misc)
--end
--elimina pets antigos
--cleanup backlisted pets within the handler of actor containers
_detalhes:LimparPets()
if (not _detalhes.in_combat) then
_detalhes:ClearCCPetsBlackList()
Details:ClearCCPetsBlackList()
end
--reseta cache de specs
_detalhes:ResetSpecCache()
--cleanup spec cache
Details:ResetSpecCache()
--wipa container de escudos
wipe(_detalhes.escudos)
--cleanup the shield cache
wipe(Details.escudos)
_detalhes.ultima_coleta = _detalhes._tempo
--set the time of the latest internal garbage collect
Details.ultima_coleta = _detalhes._tempo
if (_detalhes.debug) then
Details:Msg("(debug) executing: collectgarbage().")
collectgarbage()
UpdateAddOnMemoryUsage()
--local memory2 = GetAddOnMemoryUsage ("Details")
--_detalhes:Msg("(debug) memory before: "..memory.." memory after: "..memory2)
end
end
--combates Normais
+95 -82
View File
@@ -12,7 +12,6 @@
local UnitHealthMax = UnitHealthMax
local UnitGUID = UnitGUID
local IsInGroup = IsInGroup
--local GetNumGroupMembers = GetNumGroupMembers
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local GetTime = GetTime
local tonumber = tonumber
@@ -5583,7 +5582,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
--in case the player left the raid during the encounter
local check_for_encounter_end = function()
--this function clear the encounter_id from the cache
local checkIfEncounterIsDone = function()
if (not _current_encounter_id) then
return
end
@@ -5623,8 +5623,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--this function is guaranteed to run after a combat is done
--can also run when the player leaves combat state (regen enabled)
function _detalhes:RunScheduledEventsAfterCombat (OnRegenEnabled)
function _detalhes:RunScheduledEventsAfterCombat(OnRegenEnabled)
if (_detalhes.debug) then
_detalhes:Msg("(debug) running scheduled events after combat end.")
end
@@ -5777,13 +5776,13 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (_detalhes.debug) then
_detalhes:Msg("(debug) |cFFFFFF00PLAYER_REGEN_ENABLED|r event triggered.")
print("combat lockdown:", InCombatLockdown())
print("affecting combat:", UnitAffectingCombat("player"))
--print("combat lockdown:", InCombatLockdown())
--print("affecting combat:", UnitAffectingCombat("player"))
if (_current_encounter_id and IsInInstance()) then
print("has a encounter ID")
print("player is dead:", UnitHealth ("player") < 1)
end
--if (_current_encounter_id and IsInInstance()) then
--print("has a encounter ID")
--print("player is dead:", UnitHealth ("player") < 1)
--end
end
if (Details.auto_swap_to_dynamic_overall) then
@@ -5791,23 +5790,22 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
--elapsed combat time
_detalhes.LatestCombatDone = GetTime()
_detalhes.tabela_vigente.CombatEndedAt = GetTime()
_detalhes.tabela_vigente.TotalElapsedCombatTime = _detalhes.tabela_vigente.CombatEndedAt - (_detalhes.tabela_vigente.CombatStartedAt or 0)
Details.LatestCombatDone = GetTime()
C_Timer.After(10, check_for_encounter_end)
local currentCombat = Details:GetCurrentCombat()
currentCombat.CombatEndedAt = GetTime()
currentCombat.TotalElapsedCombatTime = currentCombat.CombatEndedAt - (currentCombat.CombatStartedAt or 0)
C_Timer.After(10, checkIfEncounterIsDone)
--playing alone, just finish the combat right now
if (not IsInGroup() and not IsInRaid()) then
_detalhes.tabela_vigente.playing_solo = true
_detalhes:SairDoCombate()
currentCombat.playing_solo = true
Details:SairDoCombate()
else
--is in a raid or party group
C_Timer.After(1, function()
local inCombat
if (IsInRaid()) then
--raid
local inCombat = false
for i = 1, GetNumGroupMembers() do
if (UnitAffectingCombat("raid" .. i)) then
@@ -5817,11 +5815,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
if (not inCombat) then
_detalhes:RunScheduledEventsAfterCombat (true)
Details:RunScheduledEventsAfterCombat(true)
end
elseif (IsInGroup()) then
--party (dungeon)
local inCombat = false
for i = 1, GetNumGroupMembers() -1 do
if (UnitAffectingCombat("party" .. i)) then
@@ -5831,7 +5828,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
if (not inCombat) then
_detalhes:RunScheduledEventsAfterCombat (true)
Details:RunScheduledEventsAfterCombat(true)
end
end
end)
@@ -5952,41 +5949,38 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_detalhes.in_group = IsInGroup() or IsInRaid()
if (_detalhes.in_group) then
--entrou num grupo
_detalhes:IniciarColetaDeLixo (true)
_detalhes:WipePets()
_detalhes:SchedulePetUpdate(1)
_detalhes:InstanceCall(_detalhes.AdjustAlphaByContext)
--player entered in a group, cleanup and set the new enviromnent
Details:RestartInternalGarbageCollector(true)
Details:WipePets()
Details:SchedulePetUpdate(1)
Details:InstanceCall(Details.AdjustAlphaByContext)
_detalhes:CheckSwitchOnLogon()
_detalhes:CheckVersion()
_detalhes:SendEvent("GROUP_ONENTER")
Details:CheckSwitchOnLogon()
Details:CheckVersion()
Details:SendEvent("GROUP_ONENTER")
_detalhes:DispatchAutoRunCode("on_groupchange")
Details:DispatchAutoRunCode("on_groupchange")
wipe (_detalhes.trusted_characters)
C_Timer.After(5, _detalhes.ScheduleSyncPlayerActorData)
wipe (Details.trusted_characters)
C_Timer.After(5, Details.ScheduleSyncPlayerActorData)
end
else
_detalhes.in_group = IsInGroup() or IsInRaid()
if (not _detalhes.in_group) then
--saiu do grupo
_detalhes:IniciarColetaDeLixo(true)
_detalhes:WipePets()
_detalhes:SchedulePetUpdate(1)
wipe(_detalhes.details_users)
_detalhes:InstanceCall(_detalhes.AdjustAlphaByContext)
_detalhes:CheckSwitchOnLogon()
_detalhes:SendEvent("GROUP_ONLEAVE")
_detalhes:DispatchAutoRunCode("on_groupchange")
wipe (_detalhes.trusted_characters)
--player left the group, run routines to cleanup the environment
Details:RestartInternalGarbageCollector(true)
Details:WipePets()
Details:SchedulePetUpdate(1)
wipe(Details.details_users)
Details:InstanceCall(Details.AdjustAlphaByContext)
Details:CheckSwitchOnLogon()
Details:SendEvent("GROUP_ONLEAVE")
Details:DispatchAutoRunCode("on_groupchange")
wipe(Details.trusted_characters)
else
--ainda esta no grupo
--player is still in a group
_detalhes:SchedulePetUpdate(2)
--send char data
@@ -6415,34 +6409,43 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
wipe(bitfield_swap_cache)
wipe(empower_cache)
local roster = _detalhes.tabela_vigente.raid_roster
local groupRoster = _detalhes.tabela_vigente.raid_roster
if (IsInRaid()) then
local unitIdCache = Details222.UnitIdCache.Raid
for i = 1, GetNumGroupMembers() do
local name = GetUnitName("raid"..i, true)
local unitId = unitIdCache[i]
local unitName = GetUnitName(unitId, true)
local unitGUID = UnitGUID(unitId)
local guid = UnitGUID("raid"..i)
raid_members_cache[guid] = name
roster[name] = guid
local _, unitClass = UnitClass(unitId)
Details222.ClassCache.ByName[unitName] = unitClass
Details222.ClassCache.ByGUID[unitGUID] = unitClass
local role = _UnitGroupRolesAssigned(name)
raid_members_cache[unitGUID] = unitName
groupRoster[unitName] = unitGUID
local role = _UnitGroupRolesAssigned(unitName)
if (role == "TANK") then
tanks_members_cache[UnitGUID("raid"..i)] = true
tanks_members_cache[unitGUID] = true
end
if (auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("raid" .. i)]]) then
auto_regen_cache[name] = auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("raid" .. i)]]
if (auto_regen_power_specs[_detalhes.cached_specs[unitGUID]]) then
auto_regen_cache[unitName] = auto_regen_power_specs[_detalhes.cached_specs[unitGUID]]
end
end
elseif (IsInGroup()) then
--party
local unitIdCache = Details222.UnitIdCache.Party
for i = 1, GetNumGroupMembers()-1 do
local name = GetUnitName("party"..i, true)
local unitId = unitIdCache[i]
local guid = UnitGUID("party"..i)
local name = GetUnitName(unitId, true)
local guid = UnitGUID(unitId)
raid_members_cache[guid] = name
roster[name] = guid
groupRoster[name] = guid
local role = _UnitGroupRolesAssigned(name)
if (role == "TANK") then
@@ -6455,44 +6458,46 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
--player
local name = GetUnitName("player", true)
local playerName = GetUnitName("player", true)
local playerGUID = UnitGUID("player")
raid_members_cache[UnitGUID("player")] = name
roster[name] = UnitGUID("player")
raid_members_cache[playerGUID] = playerName
groupRoster[playerName] = playerGUID
local role = _UnitGroupRolesAssigned(name)
local role = _UnitGroupRolesAssigned(playerName)
if (role == "TANK") then
tanks_members_cache[UnitGUID("player")] = true
tanks_members_cache[playerGUID] = true
end
if (auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("player")]]) then
auto_regen_cache[name] = auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("player")]]
if (auto_regen_power_specs[_detalhes.cached_specs[playerGUID]]) then
auto_regen_cache[playerName] = auto_regen_power_specs[_detalhes.cached_specs[playerGUID]]
end
else
local name = GetUnitName("player", true)
local playerName = GetUnitName("player", true)
local playerGUID = UnitGUID("player")
raid_members_cache[UnitGUID("player")] = name
roster[name] = UnitGUID("player")
raid_members_cache[playerGUID] = playerName
groupRoster[playerName] = playerGUID
local role = _UnitGroupRolesAssigned(name)
local role = _UnitGroupRolesAssigned(playerName)
if (role == "TANK") then
tanks_members_cache[UnitGUID("player")] = true
tanks_members_cache[playerGUID] = true
else
local spec = DetailsFramework.GetSpecialization()
if (spec and spec ~= 0) then
if (DetailsFramework.GetSpecializationRole (spec) == "TANK") then
tanks_members_cache[UnitGUID("player")] = true
tanks_members_cache[playerGUID] = true
end
end
end
if (auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("player")]]) then
auto_regen_cache[name] = auto_regen_power_specs[_detalhes.cached_specs[UnitGUID("player")]]
if (auto_regen_power_specs[_detalhes.cached_specs[playerGUID]]) then
auto_regen_cache[playerName] = auto_regen_power_specs[_detalhes.cached_specs[playerGUID]]
end
end
local orderNames = {}
for playerName in pairs(roster) do
for playerName in pairs(groupRoster) do
orderNames[#orderNames+1] = playerName
end
table.sort(orderNames, function(name1, name2)
@@ -6500,20 +6505,28 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end)
_detalhes.tabela_vigente.raid_roster_indexed = orderNames
if (_detalhes.iam_a_tank) then
tanks_members_cache[UnitGUID("player")] = true
end
end
function _detalhes:IsATank(playerguid)
return tanks_members_cache[playerguid]
---return true or false
---@param unitGUID string
---@return boolean
function Details:IsATank(unitGUID)
return tanks_members_cache[unitGUID] or false
end
function _detalhes:IsInCache(playerguid)
return raid_members_cache[playerguid]
---returns the unit name
---@param unitGUID string
---@return string
function Details:IsInCache(unitGUID)
return raid_members_cache[unitGUID]
end
function _detalhes:GetParserPlayerCache()
---return the internal raid members cache, containing the unitGUID as key and the unitName as value
---@return table
function Details:GetParserPlayerCache()
return raid_members_cache
end