Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
- index 6874c6a1f7..9d9d673839 100644
- --- a/src/server/game/Entities/Player/Player.cpp
- +++ b/src/server/game/Entities/Player/Player.cpp
- @@ -26611,3 +26611,54 @@ void Player::RemoveSocial()
- sSocialMgr->RemovePlayerSocial(GetGUID());
- m_social = nullptr;
- }
- +
- +bool Player::isPetDeadFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current)
- +{
- + ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter();
- +
- + PreparedStatement* stmt;
- + PreparedQueryResult result;
- +
- + if (petnumber)
- + {
- + // Known petnumber entry
- + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY);
- + stmt->setUInt32(0, ownerid);
- + stmt->setUInt32(1, petnumber);
- + }
- + else if (current)
- + {
- + // Current pet (slot 0)
- + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT);
- + stmt->setUInt32(0, ownerid);
- + stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
- + }
- + else if (petEntry)
- + {
- + // known petEntry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
- + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_2);
- + stmt->setUInt32(0, ownerid);
- + stmt->setUInt32(1, petEntry);
- + stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT));
- + stmt->setUInt8(3, uint8(PET_SAVE_LAST_STABLE_SLOT));
- + }
- + else
- + {
- + // Any current or other non-stabled pet (for hunter "call pet")
- + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_SLOT);
- + stmt->setUInt32(0, ownerid);
- + stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
- + stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
- + }
- +
- + result = CharacterDatabase.Query(stmt);
- +
- + if (!result)
- + {
- + return false;
- + }
- +
- + Field* fields = result->Fetch();
- +
- + return !(fields[10].GetUInt32() > 0);
- +}
- diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
- index e828bdb548..1e8e3e8c2a 100644
- --- a/src/server/game/Entities/Player/Player.h
- +++ b/src/server/game/Entities/Player/Player.h
- @@ -1301,6 +1301,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
- static uint32 GetZoneIdFromDB(ObjectGuid guid);
- static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid);
- + static bool isPetDeadFromDB(Player* owner, uint32 petEntry = 0, uint32 petnumber = 0, bool current = false);
- +
- static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
- static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false);
- diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
- index 9ea2928c42..8fe1fd2ed9 100644
- --- a/src/server/game/Spells/SpellEffects.cpp
- +++ b/src/server/game/Spells/SpellEffects.cpp
- @@ -2936,7 +2936,10 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
- {
- // pet in corpse state can't be summoned
- if (OldSummon->isDead())
- + {
- + SendCastResult(SPELL_FAILED_TARGETS_DEAD);
- return;
- + }
- ASSERT(OldSummon->GetMap() == owner->GetMap());
- @@ -2968,6 +2971,12 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
- return;
- }
- + if (owner->isPetDeadFromDB(owner, petentry))
- + {
- + SendCastResult(SPELL_FAILED_TARGETS_DEAD);
- + return;
- + }
- +
- float x, y, z;
- owner->GetClosePoint(x, y, z, owner->GetCombatReach());
- Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0);
Add Comment
Please, Sign In to add comment