mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/Pets: Fixed crash happening when current pet is forcibly removed while being temporarily unsummoned (like on a mount)
(cherry picked from commit d163735abd)
This commit is contained in:
@@ -21961,8 +21961,23 @@ 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->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->setUInt64(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();
|
||||
|
||||
|
||||
@@ -3604,7 +3604,7 @@ void Spell::EffectDismissPet()
|
||||
Pet* pet = unitTarget->ToPet();
|
||||
|
||||
ExecuteLogEffectUnsummonObject(SpellEffectName(effectInfo->Effect), pet);
|
||||
pet->GetOwner()->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
|
||||
pet->Remove(PET_SAVE_NOT_IN_SLOT);
|
||||
}
|
||||
|
||||
void Spell::EffectSummonObject()
|
||||
|
||||
Reference in New Issue
Block a user