mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
fix(Core/Pets): fixed crash happening when current pet is forcibly removed (#10025)
This commit is contained in:
@@ -8656,7 +8656,7 @@ Pet* Player::GetPet() const
|
||||
if (!pet)
|
||||
return nullptr;
|
||||
|
||||
if (IsInWorld() && pet)
|
||||
if (IsInWorld())
|
||||
return pet;
|
||||
|
||||
//there may be a guardian in slot
|
||||
@@ -8712,11 +8712,40 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
}
|
||||
|
||||
if (!pet || pet->GetOwnerGUID() != GetGUID())
|
||||
if (!pet)
|
||||
{
|
||||
if (mode == PET_SAVE_NOT_IN_SLOT && m_petStable && m_petStable->CurrentPet)
|
||||
{
|
||||
// Handle removing pet while it is in "temporarily unsummoned" state, for example on mount
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PET_SAVE_NOT_IN_SLOT);
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, m_petStable->CurrentPet->PetNumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
m_petStable->UnslottedPets.push_back(std::move(*m_petStable->CurrentPet));
|
||||
m_petStable->CurrentPet.reset();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pet->CombatStop();
|
||||
|
||||
if (returnreagent)
|
||||
{
|
||||
switch (pet->GetEntry())
|
||||
{
|
||||
//warlock pets except imp are removed(?) when logging out
|
||||
case 1860:
|
||||
case 1863:
|
||||
case 417:
|
||||
case 17252:
|
||||
mode = PET_SAVE_NOT_IN_SLOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// only if current pet in slot
|
||||
pet->SavePetToDB(mode);
|
||||
|
||||
@@ -13337,7 +13366,7 @@ void Player::AddKnownCurrency(uint32 itemId)
|
||||
void Player::UnsummonPetTemporaryIfAny()
|
||||
{
|
||||
Pet* pet = GetPet();
|
||||
if (!pet || !pet->IsInWorld())
|
||||
if (!pet)
|
||||
return;
|
||||
|
||||
if (!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned())
|
||||
|
||||
Reference in New Issue
Block a user