Core/Unit: Fixed race condition when loot recipient is in different map (#25312)

This commit is contained in:
robinsch
2020-08-22 23:09:13 +02:00
committed by GitHub
parent 2b98a3e889
commit aaa089ab7f

View File

@@ -10853,8 +10853,30 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
creature->SetLootRecipient(nullptr);
}
if (isRewardAllowed && creature && creature->GetLootRecipient())
player = creature->GetLootRecipient();
if (isRewardAllowed && creature)
{
if (Player* lootRecipient = creature->GetLootRecipient())
{
// Loot recipient can be in a different map
if (!creature->IsInMap(lootRecipient))
{
if (Group* group = creature->GetLootRecipientGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member || !creature->IsInMap(member))
continue;
player = member;
break;
}
}
}
else
player = creature->GetLootRecipient();
}
}
// Exploit fix
if (creature && creature->IsPet() && creature->GetOwnerGUID().IsPlayer())