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