fix(Core/Spells): Revive pet cannot be used on alive pets. (#8434)

Fixes #8315
This commit is contained in:
UltraNix
2021-10-15 00:54:18 +02:00
committed by GitHub
parent a8837b9de1
commit 8b70222ae2
3 changed files with 27 additions and 9 deletions

View File

@@ -115,7 +115,7 @@ void Pet::RemoveFromWorld()
}
}
SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/)
SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/, bool checkDead /*= false*/)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_SYNS);
stmt->setUInt32(0, owner->GetGUID().GetCounter());
@@ -151,10 +151,17 @@ SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetT
if (current && isTemporarySummoned)
return SPELL_FAILED_NO_PET;
if (!savedHealth)
if (!checkDead)
{
owner->ToPlayer()->SendTameFailure(PET_TAME_DEAD);
return SPELL_FAILED_TARGETS_DEAD;
if (!savedHealth)
{
owner->ToPlayer()->SendTameFailure(PET_TAME_DEAD);
return SPELL_FAILED_TARGETS_DEAD;
}
}
else if (savedHealth)
{
return SPELL_FAILED_TARGET_NOT_DEAD;
}
if (mandatoryPetType != MAX_PET_TYPE && petType != mandatoryPetType)

View File

@@ -73,7 +73,7 @@ public:
bool CreateBaseAtCreature(Creature* creature);
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE);
static SpellCastResult TryLoadFromDB(Player* owner, bool current = false, PetType mandatoryPetType = MAX_PET_TYPE, bool checkDead = false);
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = nullptr);
bool isBeingLoaded() const override { return m_loading;}
void SavePetToDB(PetSaveMode mode, bool logout);