Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  2. index 6874c6a1f7..9d9d673839 100644
  3. --- a/src/server/game/Entities/Player/Player.cpp
  4. +++ b/src/server/game/Entities/Player/Player.cpp
  5. @@ -26611,3 +26611,54 @@ void Player::RemoveSocial()
  6. sSocialMgr->RemovePlayerSocial(GetGUID());
  7. m_social = nullptr;
  8. }
  9. +
  10. +bool Player::isPetDeadFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool current)
  11. +{
  12. + ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter();
  13. +
  14. + PreparedStatement* stmt;
  15. + PreparedQueryResult result;
  16. +
  17. + if (petnumber)
  18. + {
  19. + // Known petnumber entry
  20. + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY);
  21. + stmt->setUInt32(0, ownerid);
  22. + stmt->setUInt32(1, petnumber);
  23. + }
  24. + else if (current)
  25. + {
  26. + // Current pet (slot 0)
  27. + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT);
  28. + stmt->setUInt32(0, ownerid);
  29. + stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
  30. + }
  31. + else if (petEntry)
  32. + {
  33. + // known petEntry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
  34. + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_2);
  35. + stmt->setUInt32(0, ownerid);
  36. + stmt->setUInt32(1, petEntry);
  37. + stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT));
  38. + stmt->setUInt8(3, uint8(PET_SAVE_LAST_STABLE_SLOT));
  39. + }
  40. + else
  41. + {
  42. + // Any current or other non-stabled pet (for hunter "call pet")
  43. + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_SLOT);
  44. + stmt->setUInt32(0, ownerid);
  45. + stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
  46. + stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
  47. + }
  48. +
  49. + result = CharacterDatabase.Query(stmt);
  50. +
  51. + if (!result)
  52. + {
  53. + return false;
  54. + }
  55. +
  56. + Field* fields = result->Fetch();
  57. +
  58. + return !(fields[10].GetUInt32() > 0);
  59. +}
  60. diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
  61. index e828bdb548..1e8e3e8c2a 100644
  62. --- a/src/server/game/Entities/Player/Player.h
  63. +++ b/src/server/game/Entities/Player/Player.h
  64. @@ -1301,6 +1301,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
  65. static uint32 GetZoneIdFromDB(ObjectGuid guid);
  66. static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid);
  67.  
  68. + static bool isPetDeadFromDB(Player* owner, uint32 petEntry = 0, uint32 petnumber = 0, bool current = false);
  69. +
  70. static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
  71. static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false);
  72.  
  73. diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
  74. index 9ea2928c42..8fe1fd2ed9 100644
  75. --- a/src/server/game/Spells/SpellEffects.cpp
  76. +++ b/src/server/game/Spells/SpellEffects.cpp
  77. @@ -2936,7 +2936,10 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
  78. {
  79. // pet in corpse state can't be summoned
  80. if (OldSummon->isDead())
  81. + {
  82. + SendCastResult(SPELL_FAILED_TARGETS_DEAD);
  83. return;
  84. + }
  85.  
  86. ASSERT(OldSummon->GetMap() == owner->GetMap());
  87.  
  88. @@ -2968,6 +2971,12 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
  89. return;
  90. }
  91.  
  92. + if (owner->isPetDeadFromDB(owner, petentry))
  93. + {
  94. + SendCastResult(SPELL_FAILED_TARGETS_DEAD);
  95. + return;
  96. + }
  97. +
  98. float x, y, z;
  99. owner->GetClosePoint(x, y, z, owner->GetCombatReach());
  100. Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0);
Add Comment
Please, Sign In to add comment