Code changes, see commit description
Combat Objects which has been discarded due to any reason will have the boolean member: __destroyed set to true. With this change, 3rd party code can see if the data cached is up to date or obsolete. - Removed several deprecated code from March 2023 and earlier. - Large amount of code cleanup and refactoring, some functions got renamed, they are listed below: * TravarTempos renamed to LockActivityTime. * ClearTempTables renamed to ClearCacheTables. * SpellIsDot renamed to SetAsDotSpell. * FlagCurrentCombat remamed to FlagNewCombat_PVPState. * UpdateContainerCombatentes renamed to UpdatePetCache. * segmentClass:AddCombat(combatObject) renamed to Details222.Combat.AddCombat(combatToBeAdded) - CurrentCombat.verifica_combate timer is now obsolete. - Details.last_closed_combat is now obsolete. - Details.EstaEmCombate is now obsolete. - Details.options is now obsolete. - Added: Details:RemoveSegmentByCombatObject(combatObject) - Spec Guess Timers are now stored within Details222.GuessSpecSchedules.Schedules, all timers are killed at the end of the combat or at a data reset. - Initial time to send startup signal reduced from 5 to 4 seconds. - Fixed some division by zero on ptr 10.1.5. - Fixed DETAILS_STARTED event not triggering in some cases due to 'event not registered'.
This commit is contained in:
+104
-104
@@ -1,97 +1,96 @@
|
||||
local _detalhes = _G.Details
|
||||
local gump = _detalhes.gump
|
||||
local container_pets = _detalhes.container_pets
|
||||
|
||||
local Details = _G.Details
|
||||
local container_pets = Details.container_pets
|
||||
local _
|
||||
local addonName, Details222 = ...
|
||||
|
||||
-- api locals
|
||||
local UnitGUID = _G.UnitGUID
|
||||
local _UnitName = _G.UnitName
|
||||
local _GetUnitName = _G.GetUnitName
|
||||
local UnitName = _G.UnitName
|
||||
local GetUnitName = _G.GetUnitName
|
||||
local IsInRaid = _G.IsInRaid
|
||||
local IsInGroup = _G.IsInGroup
|
||||
local GetNumGroupMembers = _G.GetNumGroupMembers
|
||||
|
||||
-- lua locals
|
||||
local setmetatable = setmetatable
|
||||
local _bit_band = bit.band --lua local
|
||||
local bitBand = bit.band --lua local
|
||||
local pairs = pairs
|
||||
|
||||
--details locals
|
||||
local is_ignored = _detalhes.pets_ignored
|
||||
local bIsIgnored = Details.pets_ignored
|
||||
|
||||
function container_pets:NovoContainer()
|
||||
local esta_tabela = {}
|
||||
setmetatable(esta_tabela, _detalhes.container_pets)
|
||||
esta_tabela.pets = {} --armazena a pool -> uma dictionary com o [serial do pet] -> nome do dono
|
||||
esta_tabela._ActorTable = {} --armazena os 15 ultimos pets do jogador -> [jogador nome] -> {nil, nil, nil, ...}
|
||||
return esta_tabela
|
||||
local newPetContainer = {}
|
||||
setmetatable(newPetContainer, Details.container_pets)
|
||||
|
||||
---@type petinfo
|
||||
local newPetCacheTable = {}
|
||||
newPetContainer.pets = newPetCacheTable
|
||||
|
||||
newPetContainer._ActorTable = {}
|
||||
return newPetContainer
|
||||
end
|
||||
|
||||
local OBJECT_TYPE_PET = 0x00001000
|
||||
local EM_GRUPO = 0x00000007
|
||||
local PET_EM_GRUPO = 0x00001007
|
||||
|
||||
function container_pets:PegaDono (pet_serial, pet_nome, pet_flags)
|
||||
local OBJECT_IN_GROUP = 0x00000007
|
||||
|
||||
function container_pets:PegaDono(petGUID, petName, petFlags)
|
||||
--sair se o pet estiver na ignore
|
||||
if (is_ignored [pet_serial]) then
|
||||
if (bIsIgnored[petGUID]) then
|
||||
return
|
||||
end
|
||||
|
||||
--buscar pelo pet no container de pets
|
||||
local busca = self.pets [pet_serial]
|
||||
local busca = self.pets[petGUID]
|
||||
if (busca) then
|
||||
--in merging operations, make sure to not add the owner name a second time in the name
|
||||
|
||||
|
||||
--check if the pet name already has the owner name in, if not, add it
|
||||
if (not pet_nome:find("<")) then
|
||||
if (not petName:find("<")) then
|
||||
--get the owner name
|
||||
local ownerName = busca[1]
|
||||
--add the owner name to the pet name
|
||||
pet_nome = pet_nome .. " <".. ownerName ..">"
|
||||
petName = petName .. " <".. ownerName ..">"
|
||||
end
|
||||
|
||||
|
||||
--return busca[6] or pet_nome, busca[1], busca[2], busca[3] --busca[6] poderia estar causando problemas
|
||||
return pet_nome, busca[1], busca[2], busca[3] --[1] dono nome [2] dono serial [3] dono flag
|
||||
return petName, busca[1], busca[2], busca[3] --[1] dono nome[2] dono serial[3] dono flag
|
||||
end
|
||||
|
||||
|
||||
--buscar pelo pet na raide
|
||||
local dono_nome, dono_serial, dono_flags
|
||||
|
||||
|
||||
if (IsInRaid()) then
|
||||
for i = 1, GetNumGroupMembers() do
|
||||
if (pet_serial == UnitGUID("raidpet"..i)) then
|
||||
for i = 1, GetNumGroupMembers() do
|
||||
if (petGUID == UnitGUID("raidpet"..i)) then
|
||||
dono_serial = UnitGUID("raid"..i)
|
||||
dono_flags = 0x00000417 --emulate sourceflag flag
|
||||
|
||||
local nome, realm = _UnitName ("raid"..i)
|
||||
|
||||
local nome, realm = UnitName("raid"..i)
|
||||
if (realm and realm ~= "") then
|
||||
nome = nome.."-"..realm
|
||||
end
|
||||
dono_nome = nome
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elseif (IsInGroup()) then
|
||||
for i = 1, GetNumGroupMembers()-1 do
|
||||
if (pet_serial == UnitGUID("partypet"..i)) then
|
||||
for i = 1, GetNumGroupMembers()-1 do
|
||||
if (petGUID == UnitGUID("partypet"..i)) then
|
||||
dono_serial = UnitGUID("party"..i)
|
||||
dono_flags = 0x00000417 --emulate sourceflag flag
|
||||
|
||||
local nome, realm = _UnitName ("party"..i)
|
||||
|
||||
local nome, realm = UnitName("party"..i)
|
||||
if (realm and realm ~= "") then
|
||||
nome = nome.."-"..realm
|
||||
end
|
||||
|
||||
|
||||
dono_nome = nome
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (not dono_nome) then
|
||||
if (pet_serial == UnitGUID("pet")) then
|
||||
dono_nome = _GetUnitName ("player")
|
||||
if (petGUID == UnitGUID("pet")) then
|
||||
dono_nome = GetUnitName("player")
|
||||
dono_serial = UnitGUID("player")
|
||||
if (IsInGroup() or IsInRaid()) then
|
||||
dono_flags = 0x00000417 --emulate sourceflag flag
|
||||
@@ -100,152 +99,153 @@ function container_pets:PegaDono (pet_serial, pet_nome, pet_flags)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (dono_nome) then
|
||||
self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, true, pet_nome, pet_serial} --adicionada a flag emulada
|
||||
|
||||
if (not pet_nome:find("<")) then
|
||||
pet_nome = pet_nome .. " <".. dono_nome ..">"
|
||||
self.pets[petGUID] = {dono_nome, dono_serial, dono_flags, Details._tempo, true, petName, petGUID} --adicionada a flag emulada
|
||||
|
||||
if (not petName:find("<")) then
|
||||
petName = petName .. " <".. dono_nome ..">"
|
||||
end
|
||||
|
||||
return pet_nome, dono_nome, dono_serial, dono_flags
|
||||
|
||||
return petName, dono_nome, dono_serial, dono_flags
|
||||
else
|
||||
|
||||
if (pet_flags and _bit_band (pet_flags, OBJECT_TYPE_PET) ~= 0) then --� um pet
|
||||
if (not _detalhes.pets_no_owner [pet_serial] and _bit_band (pet_flags, EM_GRUPO) ~= 0) then
|
||||
_detalhes.pets_no_owner [pet_serial] = {pet_nome, pet_flags}
|
||||
_detalhes:Msg("couldn't find the owner of the pet:", pet_nome)
|
||||
|
||||
if (petFlags and bitBand(petFlags, OBJECT_TYPE_PET) ~= 0) then --� um pet
|
||||
if (not Details.pets_no_owner[petGUID] and bitBand(petFlags, OBJECT_IN_GROUP) ~= 0) then
|
||||
Details.pets_no_owner[petGUID] = {petName, petFlags}
|
||||
Details:Msg("couldn't find the owner of the pet:", petName)
|
||||
end
|
||||
else
|
||||
is_ignored [pet_serial] = true
|
||||
bIsIgnored[petGUID] = true
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
function container_pets:Unpet (...)
|
||||
function container_pets:Unpet(...)
|
||||
local unitid = ...
|
||||
|
||||
local owner_serial = UnitGUID(unitid)
|
||||
|
||||
|
||||
if (owner_serial) then
|
||||
--tira o pet existente da tabela de pets e do cache do core
|
||||
local existing_pet_serial = _detalhes.pets_players [owner_serial]
|
||||
local existing_pet_serial = Details.pets_players[owner_serial]
|
||||
if (existing_pet_serial) then
|
||||
_detalhes.parser:RevomeActorFromCache (existing_pet_serial)
|
||||
container_pets:Remover (existing_pet_serial)
|
||||
_detalhes.pets_players [owner_serial] = nil
|
||||
Details.parser:RevomeActorFromCache(existing_pet_serial)
|
||||
container_pets:Remover(existing_pet_serial)
|
||||
Details.pets_players[owner_serial] = nil
|
||||
end
|
||||
--verifica se h� um pet novo deste jogador
|
||||
local pet_serial = UnitGUID(unitid .. "pet")
|
||||
if (pet_serial) then
|
||||
if (not _detalhes.tabela_pets.pets [pet_serial]) then
|
||||
local nome, realm = _UnitName (unitid)
|
||||
if (not Details.tabela_pets.pets[pet_serial]) then
|
||||
local nome, realm = UnitName(unitid)
|
||||
if (realm and realm ~= "") then
|
||||
nome = nome.."-"..realm
|
||||
end
|
||||
_detalhes.tabela_pets:Adicionar (pet_serial, _UnitName (unitid .. "pet"), 0x1114, owner_serial, nome, 0x514)
|
||||
Details.tabela_pets:Adicionar(pet_serial, UnitName(unitid .. "pet"), 0x1114, owner_serial, nome, 0x514)
|
||||
end
|
||||
_detalhes.parser:RevomeActorFromCache (pet_serial)
|
||||
container_pets:PlayerPet (owner_serial, pet_serial)
|
||||
Details.parser:RevomeActorFromCache(pet_serial)
|
||||
container_pets:PlayerPet(owner_serial, pet_serial)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function container_pets:PlayerPet (player_serial, pet_serial)
|
||||
_detalhes.pets_players [player_serial] = pet_serial
|
||||
function container_pets:PlayerPet(player_serial, pet_serial)
|
||||
Details.pets_players[player_serial] = pet_serial
|
||||
end
|
||||
|
||||
function container_pets:BuscarPets()
|
||||
if (IsInRaid()) then
|
||||
for i = 1, GetNumGroupMembers(), 1 do
|
||||
for i = 1, GetNumGroupMembers(), 1 do
|
||||
local pet_serial = UnitGUID("raidpet"..i)
|
||||
if (pet_serial) then
|
||||
if (not _detalhes.tabela_pets.pets [pet_serial]) then
|
||||
local nome, realm = _UnitName ("raid"..i)
|
||||
if (not Details.tabela_pets.pets[pet_serial]) then
|
||||
local nome, realm = UnitName("raid"..i)
|
||||
if (realm and realm ~= "") then
|
||||
nome = nome.."-"..realm
|
||||
end
|
||||
local owner_serial = UnitGUID("raid"..i)
|
||||
_detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("raidpet"..i), 0x1114, owner_serial, nome, 0x514)
|
||||
_detalhes.parser:RevomeActorFromCache (pet_serial)
|
||||
container_pets:PlayerPet (owner_serial, pet_serial)
|
||||
Details.tabela_pets:Adicionar(pet_serial, UnitName("raidpet"..i), 0x1114, owner_serial, nome, 0x514)
|
||||
Details.parser:RevomeActorFromCache(pet_serial)
|
||||
container_pets:PlayerPet(owner_serial, pet_serial)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elseif (IsInGroup()) then
|
||||
for i = 1, GetNumGroupMembers()-1, 1 do
|
||||
for i = 1, GetNumGroupMembers()-1, 1 do
|
||||
local pet_serial = UnitGUID("partypet"..i)
|
||||
if (pet_serial) then
|
||||
if (not _detalhes.tabela_pets.pets [pet_serial]) then
|
||||
local nome, realm = _UnitName ("party"..i)
|
||||
if (not Details.tabela_pets.pets[pet_serial]) then
|
||||
local nome, realm = UnitName("party"..i)
|
||||
|
||||
if (realm and realm ~= "") then
|
||||
nome = nome.."-"..realm
|
||||
end
|
||||
_detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("partypet"..i), 0x1114, UnitGUID("party"..i), nome, 0x514)
|
||||
Details.tabela_pets:Adicionar(pet_serial, UnitName("partypet"..i), 0x1114, UnitGUID("party"..i), nome, 0x514)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local pet_serial = UnitGUID("pet")
|
||||
if (pet_serial) then
|
||||
if (not _detalhes.tabela_pets.pets [pet_serial]) then
|
||||
_detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("pet"), 0x1114, UnitGUID("player"), _detalhes.playername, 0x514)
|
||||
if (not Details.tabela_pets.pets[pet_serial]) then
|
||||
Details.tabela_pets:Adicionar(pet_serial, UnitName("pet"), 0x1114, UnitGUID("player"), Details.playername, 0x514)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
local pet_serial = UnitGUID("pet")
|
||||
if (pet_serial) then
|
||||
if (not _detalhes.tabela_pets.pets [pet_serial]) then
|
||||
_detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("pet"), 0x1114, UnitGUID("player"), _detalhes.playername, 0x514)
|
||||
if (not Details.tabela_pets.pets[pet_serial]) then
|
||||
Details.tabela_pets:Adicionar(pet_serial, UnitName("pet"), 0x1114, UnitGUID("player"), Details.playername, 0x514)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function container_pets:Remover (pet_serial)
|
||||
if (_detalhes.tabela_pets.pets [pet_serial]) then
|
||||
Details:Destroy(_detalhes.tabela_pets.pets [pet_serial])
|
||||
function container_pets:Remover(pet_serial)
|
||||
if (Details.tabela_pets.pets[pet_serial]) then
|
||||
Details:Destroy(Details.tabela_pets.pets[pet_serial])
|
||||
end
|
||||
_detalhes.tabela_pets.pets [pet_serial] = nil
|
||||
Details.tabela_pets.pets[pet_serial] = nil
|
||||
end
|
||||
|
||||
function container_pets:Adicionar (pet_serial, pet_nome, pet_flags, dono_serial, dono_nome, dono_flags)
|
||||
if (pet_flags and _bit_band (pet_flags, OBJECT_TYPE_PET) ~= 0 and _bit_band (pet_flags, EM_GRUPO) ~= 0) then
|
||||
self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, true, pet_nome, pet_serial}
|
||||
function container_pets:Adicionar(pet_serial, pet_nome, pet_flags, dono_serial, dono_nome, dono_flags)
|
||||
if (pet_flags and bitBand(pet_flags, OBJECT_TYPE_PET) ~= 0 and bitBand(pet_flags, OBJECT_IN_GROUP) ~= 0) then
|
||||
self.pets[pet_serial] = {dono_nome, dono_serial, dono_flags, Details._tempo, true, pet_nome, pet_serial}
|
||||
else
|
||||
self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, false, pet_nome, pet_serial}
|
||||
self.pets[pet_serial] = {dono_nome, dono_serial, dono_flags, Details._tempo, false, pet_nome, pet_serial}
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:WipePets()
|
||||
return Details:Destroy(_detalhes.tabela_pets.pets)
|
||||
function Details:WipePets()
|
||||
return Details:Destroy(Details.tabela_pets.pets)
|
||||
end
|
||||
|
||||
function _detalhes:PetContainerCleanup()
|
||||
function Details222.Pets.PetContainerCleanup()
|
||||
--erase old pet table by creating a new one
|
||||
local newPetTable = {}
|
||||
|
||||
--minimum of 90 minutes to clean a pet from the pet table data
|
||||
for PetSerial, PetTable in pairs(_detalhes.tabela_pets.pets) do
|
||||
if ( (PetTable[4] + 5400 > _detalhes._tempo + 1) or (PetTable[5] and PetTable[4] + 43200 > _detalhes._tempo) ) then
|
||||
newPetTable [PetSerial] = PetTable
|
||||
for petGUID, petTable in pairs(Details.tabela_pets.pets) do
|
||||
if ((petTable[4] + 5400 > Details._tempo + 1) or (petTable[5] and petTable[4] + 43200 > Details._tempo)) then
|
||||
newPetTable[petGUID] = petTable
|
||||
end
|
||||
end
|
||||
_detalhes.tabela_pets.pets = newPetTable
|
||||
_detalhes:UpdateContainerCombatentes()
|
||||
|
||||
|
||||
Details.tabela_pets.pets = newPetTable
|
||||
Details:UpdatePetCache()
|
||||
end
|
||||
|
||||
local have_schedule = false
|
||||
function _detalhes:UpdatePets()
|
||||
function Details:UpdatePets()
|
||||
have_schedule = false
|
||||
return container_pets:BuscarPets()
|
||||
end
|
||||
function _detalhes:SchedulePetUpdate(seconds)
|
||||
function Details:SchedulePetUpdate(seconds)
|
||||
if (have_schedule) then
|
||||
return
|
||||
end
|
||||
@@ -255,7 +255,7 @@ function _detalhes:SchedulePetUpdate(seconds)
|
||||
Details.Schedules.NewTimer(seconds or 5, Details.UpdatePets, Details)
|
||||
end
|
||||
|
||||
function _detalhes.refresh:r_container_pets (container)
|
||||
function Details.refresh:r_container_pets(container)
|
||||
setmetatable(container, container_pets)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user