diff --git a/Libs/DF/addon.lua b/Libs/DF/addon.lua index 2594e55b..9aea39b9 100644 --- a/Libs/DF/addon.lua +++ b/Libs/DF/addon.lua @@ -31,7 +31,7 @@ end --when the player logout or reloadUI local addonUnload = function(addonFrame, event, ...) --close saved tables - + DF.SavedVars.CloseSavedTable(addonFrame.db) end local addonEvents = { @@ -46,8 +46,8 @@ local addonOnEvent = function(addonFrame, event, ...) func(addonFrame, event, ...) else --might be a registered event from the user - if (addonFrame.event) then - DF:CoreDispatch(addonFrame.__name, addonFrame.event, addonFrame, event, ...) + if (addonFrame[event]) then + DF:CoreDispatch(addonFrame.__name, addonFrame[event], addonFrame, event, ...) end end end @@ -66,6 +66,7 @@ function DF:CreateNewAddOn(addonName, globalSavedVariablesName, savedVarsTemplat newAddon:RegisterEvent("ADDON_LOADED") newAddon:RegisterEvent("PLAYER_LOGIN") + newAddon:RegisterEvent("PLAYER_LOGOUT") newAddon:SetScript("OnEvent", addonOnEvent) return newAddon diff --git a/Libs/DF/savedvars.lua b/Libs/DF/savedvars.lua index b055736b..8aecc490 100644 --- a/Libs/DF/savedvars.lua +++ b/Libs/DF/savedvars.lua @@ -18,12 +18,19 @@ function DF.SavedVars.CreateNewSavedTable(dbTable, savedTableName) end function DF.SavedVars.GetOrCreateAddonSavedTablesPlayerList(addonFrame) - local addonGlobalSavedTable = _G[addonFrame.savedVarsName] + local addonGlobalSavedTable = _G[addonFrame.__savedVarsName] + + --player list local playerList = addonGlobalSavedTable.__savedVarsByGUID if (not playerList) then addonGlobalSavedTable.__savedVarsByGUID = {} end + --saved variables table + if (not addonGlobalSavedTable.__savedVars) then + addonGlobalSavedTable.__savedVars = {} + end + return addonGlobalSavedTable.__savedVarsByGUID end @@ -51,23 +58,50 @@ function DF.SavedVars.LoadSavedVarsForPlayer(addonFrame) savedTable = addonFrame.db:CreateNewSavedTable(playerSavedTableName) end - addonFrame.db.profile = savedTable - addonFrame.db.currentSavedTableName = playerSavedTableName - + DF.SavedVars.SetSavedTable(dbTable, playerSavedTableName, true, true) return savedTable end +function DF.SavedVars.TableCleanUpRecursive(t, default) + for key, value in pairs(t) do + if (type(value) == "table") then + DF.SavedVars.TableCleanUpRecursive(value, default[key]) + else + if (value == default[key]) then + t[key] = nil + end + end + end +end + +function DF.SavedVars.CloseSavedTable(dbTable) + local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName()) + + local default = dbTable.defaultSavedVars + if (type(currentSavedTable) == "table") then + DF.SavedVars.TableCleanUpRecursive(currentSavedTable, default) + + --save + local addonGlobalSavedTable = _G[dbTable.addonFrame.__savedVarsName] + addonGlobalSavedTable.__savedVars[dbTable:GetCurrentSavedTableName()] = currentSavedTable + end +end --base functions -function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant) +function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant, isFromInit) local savedTableToBeApplied = dbTable:GetSavedTable(savedTableName) if (savedTableToBeApplied) then - --callback unload profile table - local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName()) - dbTable:TriggerCallback("OnProfileUnload", currentSavedTable) + if (not isFromInit) then + --callback unload profile table + local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName()) + dbTable:TriggerCallback("OnProfileUnload", currentSavedTable) + DF.SavedVars.CloseSavedTable(dbTable, currentSavedTable) + end dbTable.profile = savedTableToBeApplied + dbTable.currentSavedTableName = savedTableName + dbTable:TriggerCallback("OnProfileLoad", savedTableToBeApplied) else @@ -77,10 +111,11 @@ function DF.SavedVars.SetSavedTable(dbTable, savedTableName, createIfNonExistant --callback unload profile table local currentSavedTable = dbTable:GetSavedTable(dbTable:GetCurrentSavedTableName()) dbTable:TriggerCallback("OnProfileUnload", currentSavedTable) + DF.SavedVars.CloseSavedTable(dbTable, currentSavedTable) dbTable.profile = newSavedTable + dbTable.currentSavedTableName = savedTableName dbTable:TriggerCallback("OnProfileLoad", newSavedTable) - else DF:Msg("profile does not exists", savedTableName) return diff --git a/classes/class_combat.lua b/classes/class_combat.lua index 3749c948..0e649e53 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -343,6 +343,9 @@ local actorTable = container._ActorTable + --store the index it was found + local indexToDelete + --get the object for the deleted actor local deletedActor = self(attribute, actorName) if (not deletedActor) then @@ -351,53 +354,63 @@ for i = 1, #actorTable do local actor = actorTable[i] if (actor.nome == actorName) then - print ("Details: found the actor: ", actorName, actor.nome, i) + --print ("Details: found the actor: ", actorName, actor.nome, i) + indexToDelete = i break end end end - --store the index it was found - local indexToDelete - for i = 1, #actorTable do - local actor = actorTable[i] + --is this not the actor we want to remove? + if (i ~= indexToDelete) then - --is this the actor we want to remove? - if (actor.nome == actorName or actor == deletedActor) then - indexToDelete = i - else - --get the damage dealt and remove - local damageDoneToRemovedActor = (actor.targets[actorName]) or 0 - actor.targets[actorName] = nil - actor.total = actor.total - damageDoneToRemovedActor - actor.total_without_pet = actor.total_without_pet - damageDoneToRemovedActor + local actor = actorTable[i] + if (not actor.isTank) then + --get the damage dealt and remove + local damageDoneToRemovedActor = (actor.targets[actorName]) or 0 + actor.targets[actorName] = nil + actor.total = actor.total - damageDoneToRemovedActor + actor.total_without_pet = actor.total_without_pet - damageDoneToRemovedActor - --damage taken - if (removeDamageTaken) then - local hadDamageTaken = actor.damage_from[actorName] - if (hadDamageTaken) then - --query the deleted actor to know how much damage it applied to this actor - local damageDoneToActor = (deletedActor.targets[actor.nome]) or 0 - actor.damage_taken = actor.damage_taken - damageDoneToActor + --damage taken + if (removeDamageTaken) then + local hadDamageTaken = actor.damage_from[actorName] + if (hadDamageTaken) then + --query the deleted actor to know how much damage it applied to this actor + local damageDoneToActor = (deletedActor.targets[actor.nome]) or 0 + actor.damage_taken = actor.damage_taken - damageDoneToActor + end end - end - --spells - local spellsTable = actor.spells._ActorTable - for spellId, spellTable in pairs(spellsTable) do - local damageDoneToRemovedActor = (spellTable.targets[actorName]) or 0 - spellTable.targets[actorName] = nil - spellTable.total = spellTable.total - damageDoneToRemovedActor + --spells + local spellsTable = actor.spells._ActorTable + for spellId, spellTable in pairs(spellsTable) do + local damageDoneToRemovedActor = (spellTable.targets[actorName]) or 0 + spellTable.targets[actorName] = nil + spellTable.total = spellTable.total - damageDoneToRemovedActor + end end end end if (indexToDelete) then - tremove(container._ActorTable, indexToDelete) - print("Details: damage done to ".. actorName .." removed.") - else - print("Details: index of the " .. actorName .. " not found on map index.") + local actorToDelete = self(attribute, actorName) + local actorToDelete2 = container._ActorTable[indexToDelete] + if (actorToDelete ~= actorToDelete2) then + Details:Msg("error 0xDE8745") + end + + local index = self._NameIndexTable[actorName] + if (indexToDelete ~= index) then + Details:Msg("error 0xDE8751") + end + + --remove actor + tremove(container._ActorTable, index) + + --remap + self:Remap() end end end diff --git a/core/parser.lua b/core/parser.lua index a6a83499..9f06e3f8 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -687,8 +687,8 @@ end if (not este_jogador) then - print ("no ente_jogador") - print (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, amount) + --print ("no ente_jogador") + --print (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, amount) return end @@ -1556,23 +1556,6 @@ return end - --> MOTHER encounter in Uldir is triggering the summon of the add as it was a pet from the player the crossed rooms REMOVE WHEN BFA IS DONE - if (spellid == 268871 or spellid == 267833) then - --print ("IGNORING summon of a Corrupted Blood Clone for player", who_name) - --5/17 18:16:48.886 SPELL_SUMMON,Creature-0-4028-1861-987-136949-00007DF137,"Corrupted Blood Clone",0xa18,0x0,Creature-0-4028-1861-987-136315-00007DF140,"Remnant of Corruption",0xa28,0x0,267833,"Defense Grid",0x1 - --5/17 18:16:49.601 SPELL_SUMMON,Player-970-000BDB1F,"Fhqwhgads-Anduin",0x514,0x2,Creature-0-4028-1861-987-136949-00007DF141,"Corrupted Blood Clone",0xa28,0x0,268871,"Corrupted Blood Clone",0x1 - --4/22 18:07:54.369 SPELL_SUMMON,Player-3296-009371B2,"Façade-Anasterian(US)",0x514,0x0,Creature-0-3198-1448-2131-90477-0000380DAA,"Blood Globule",0xa28,0x0,180410,"Heart Seeker",0x1 - --5/4 15:45:24.222 SPELL_SUMMON,Player-3296-009576DD,"Àlëx-Brill(EU)",0x40514,0x0,Creature-0-2083-1448-25606-90513-000047BE44,"Fel Blood Globule",0xa28,0x0,180413,"Heart Seeker",0x1 - return - end - - if (alvo_serial and type (alvo_serial) == "string") then - --Ice Block from Jaina encounter REMOVE WHEN BFA IS DONE - if (alvo_serial:match ("^Creature%-0%-%d+%-%d+%-%d+%-148522%-%w+$")) then - return - end - end - if (not who_name) then who_name = "[*] " .. spellName end @@ -1588,15 +1571,11 @@ who_name, who_serial, who_flags = alvo_pet[1], alvo_pet[2], alvo_pet[3] end - --print () --petTable:Add _detalhes.tabela_pets:Adicionar (alvo_serial, alvo_name, alvo_flags, who_serial, who_name, who_flags) - - --print ("SUMMON", alvo_name, _detalhes.tabela_pets.pets, _detalhes.tabela_pets.pets [alvo_serial], alvo_serial) --debug summons: --print("summon:", who_name, alvo_serial, alvo_name, alvo_flags, spellid, spellName) - return end @@ -2713,7 +2692,6 @@ --local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId = UnitAura (alvo_name, spellname, nil, "HARMFUL") --UnitAura ("Kastfall", "Gulp Frog Toxin", nil, "HARMFUL") - --print ("Hello World", spellname, name) --if (name) then --> record death log @@ -3039,12 +3017,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _current_energy_container.need_refresh = true ---print (who_name, spellid, spellname, spelltype, amount, powertype, p6, p7) powertype = 0 p6 = 17 ---4/27 13:45:54.903 SPELL_ENERGIZE, ---Player-3208-0A085522,"Licelystiri-Nemesis",0x511,0x0, ---Player-3208-0A085522,"Licelystiri-Nemesis",0x511,0x0, ---162243,"Demon's Bite",0x1,Player-3208-0A085522,0000000000000000,233158,242700,3555,662,17,70,100,0,1030.46,3134.93,660,28,0,17,100 - ------------------------------------------------------------------------------------------------ --> get actors @@ -3765,7 +3737,7 @@ spelltype = 1 --> outsider death while in combat --rules for specific encounters - if (_current_encounter_id == 2412) then --> The Council of Blood + if (_current_encounter_id == 2412) then --> The Council of Blood (REMOVE ON v10.0.1) if (not Details.exp90temp.delete_damage_TCOB) then return @@ -3773,9 +3745,6 @@ spelltype = 1 --what boss died local bossDeadNpcId = Details:GetNpcIdFromGuid(alvo_serial) - - print("Details: boss died:", bossDeadNpcId, alvo_name, alvo_serial) - if (bossDeadNpcId ~= 166969 and bossDeadNpcId ~= 166970 and bossDeadNpcId ~= 166971) then return end @@ -3787,7 +3756,7 @@ spelltype = 1 --]] if (bossDeadNpcId) then - --iterate among boss targets + --iterate among boss unit ids for i = 1, 5 do local unitId = "boss" .. i @@ -3800,7 +3769,6 @@ spelltype = 1 if (bossSerial) then local bossNpcId = Details:GetNpcIdFromGuid(bossSerial) if (bossNpcId and bossNpcId ~= bossDeadNpcId) then - print("Details: deleting boss:", bossName) --remove the damage done local currentCombat = Details:GetCurrentCombat() currentCombat:DeleteActor(DETAILS_ATTRIBUTE_DAMAGE, bossName, false)