fix(Core/Pet): fix Pet::resetTalentsForAllPetsOf for stabled pets (#15779)

This commit is contained in:
Axel Cocat
2023-04-02 14:48:03 +02:00
committed by GitHub
parent c0253d91a7
commit d028a6253a

View File

@@ -2101,34 +2101,52 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* onlinePet /*= nullptr*/)
{
// not need after this call
if (owner->ToPlayer()->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
{
owner->ToPlayer()->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS, true);
}
// reset for online
if (onlinePet)
{
onlinePet->resetTalents();
}
PetStable* petStable = owner->GetPetStable();
if (!petStable)
{
return;
}
std::unordered_set<uint32> petIds;
if (petStable->CurrentPet)
{
petIds.insert(petStable->CurrentPet->PetNumber);
}
for (Optional<PetStable::PetInfo> const& stabledPet : petStable->StabledPets)
{
if (stabledPet)
{
petIds.insert(stabledPet->PetNumber);
}
}
for (PetStable::PetInfo const& unslottedPet : petStable->UnslottedPets)
{
petIds.insert(unslottedPet.PetNumber);
}
// now need only reset for offline pets (all pets except online case)
if (onlinePet)
{
petIds.erase(onlinePet->GetCharmInfo()->GetPetNumber());
}
// no offline pets
if (!petIds.empty())
if (petIds.empty())
{
return;
}
bool need_comma = false;
std::ostringstream ss;
@@ -2137,7 +2155,9 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* onlinePet /*= nullptr*/)
for (uint32 id : petIds)
{
if (need_comma)
{
ss << ',';
}
ss << id;
@@ -2150,7 +2170,9 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* onlinePet /*= nullptr*/)
for (uint32 spell : sPetTalentSpells)
{
if (need_comma)
{
ss << ',';
}
ss << spell;