Skip to content

Commit

Permalink
Removed pet duplication bug and removed debug lines for no ownerName
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jun 15, 2024
1 parent ea71121 commit 7349c3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 10 additions & 7 deletions classes/container_actors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,13 @@ end
end

petContainer.AddPet(petGuid, petName, petFlags, ownerGuid, ownerName, ownerFlags)
local petNameWithOwner, ownerName, ownerGUID, ownerFlags = petContainer.GetOwner(petGuid, petName)
--hashName is "petName <ownerName>"
local hashName, ownerName, ownerGUID, ownerFlags = petContainer.GetOwner(petGuid, petName)

local petOwnerActorObject

if (petNameWithOwner and ownerName) then
petName = petNameWithOwner
if (hashName and ownerName) then
petName = hashName
petOwnerActorObject = self:PegarCombatente(ownerGUID, ownerName, ownerFlags, true)
end

Expand Down Expand Up @@ -757,17 +758,19 @@ end

--check if this actor is a pet and the pet is in the pet cache
if (petContainer.IsPetInCache(actorSerial)) then --this is a registered pet
local petName, ownerName, ownerGuid, ownerFlag = petContainer.GetOwner(actorSerial, actorName)
if (petName and ownerName and ownerGuid and ownerGuid ~= actorSerial and ownerFlag) then
actorName = petName
--hashName is "petName <ownerName>"
local hashName, ownerName, ownerGuid, ownerFlag = petContainer.GetOwner(actorSerial, actorName) --hashName, ownerName, ownerGuid, ownerFlags
if (hashName and ownerName and ownerGuid and ownerGuid ~= actorSerial and ownerFlag) then
actorName = hashName
petOwnerObject = self:PegarCombatente(ownerGuid, ownerName, ownerFlag, true)
end

--this actor isn't in the pet cache
elseif (not petBlackList[actorSerial]) then --check if is a pet
--try to find the owner
if (actorFlags and bitBand(actorFlags, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
local ownerName, ownerGuid, ownerFlags = petContainer.GetOwner(actorSerial, actorName)
--hashName is "petName <ownerName>"
local hashName, ownerName, ownerGuid, ownerFlags = petContainer.GetOwner(actorSerial, actorName) --hashName, ownerName, ownerGuid, ownerFlags
if (ownerName and ownerGuid) then
--don't pass ownerFlags just in case the cached owner happens to be an enemy from last combat, but ally now.
local newPetName, ownerObject = petOwnerFound(ownerName, actorSerial, actorName, actorFlags, self, ownerGuid)
Expand Down
7 changes: 5 additions & 2 deletions classes/container_pets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function petContainer.AddPet(petGuid, petName, petFlags, ownerGuid, ownerName, o
local bIsFriendly = petFlags and bitBand(petFlags, OBJECT_TYPE_PET) ~= 0 and bitBand(petFlags, OBJECT_IN_GROUP) ~= 0

if (not ownerName) then
print("NO OWNER NAME",petGuid, petName, petFlags, ownerGuid, ownerName, ownerFlags, summonSpellId)
--print("NO OWNER NAME",petGuid, petName, petFlags, ownerGuid, ownerName, ownerFlags, summonSpellId)
--NO OWNER NAME Creature-0-4218-2549-4490-61056-00006A5157 Primal Earth Elemental 2600 nil nil nil 118323 --spellId 118323: Earth Elemental
--NO OWNER NAME Pet-0-4218-2549-4490-26125-0102D77C2C Casketmuncher 4648 nil nil nil 52150 --spellId: 52150 raise dead
--NO OWNER NAME Creature-0-4214-2569-1456-202167-00006B35A1 Ray of Anguish 2632 nil nil nil 402191 --spellId: 402191 Ray of Anguish
Expand Down Expand Up @@ -281,7 +281,10 @@ end

---@param petGuid guid
---@param petName actorname
---@return actorname?, actorname?, guid?, number?
---@return actorname? petNameWithOwner
---@return actorname? ownerName
---@return guid? ownerGuid
---@return number? ownerFlags
function petContainer.GetOwner(petGuid, petName)
Details222.Profiling.ProfileStart("petContainer.GetOwner")

Expand Down

0 comments on commit 7349c3d

Please sign in to comment.