Created
November 19, 2010 14:46
-
-
Save rsa/706597 to your computer and use it in GitHub Desktop.
use UNIT_FIELD_CRITTER for minipets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp | |
index 8d6975b..4c7410d 100644 | |
--- a/src/game/Pet.cpp | |
+++ b/src/game/Pet.cpp | |
@@ -720,7 +720,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) | |
{ | |
case MINI_PET: | |
if (p_owner) | |
- p_owner->_SetMiniPet(NULL); | |
+ p_owner->SetMiniPet(NULL); | |
break; | |
case PROTECTOR_PET: | |
case GUARDIAN_PET: | |
diff --git a/src/game/Player.cpp b/src/game/Player.cpp | |
index dfb2d32..1af09b4 100644 | |
--- a/src/game/Player.cpp | |
+++ b/src/game/Player.cpp | |
@@ -17784,20 +17784,6 @@ void Player::RemovePet(PetSaveMode mode) | |
pet->Unsummon(mode, this); | |
} | |
-void Player::RemoveMiniPet() | |
-{ | |
- if (Pet* pet = GetMiniPet()) | |
- pet->Unsummon(PET_SAVE_AS_DELETED); | |
-} | |
- | |
-Pet* Player::GetMiniPet() const | |
-{ | |
- if (m_miniPetGuid.IsEmpty()) | |
- return NULL; | |
- | |
- return GetMap()->GetPet(m_miniPetGuid); | |
-} | |
- | |
void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const | |
{ | |
*data << (uint8)msgtype; | |
diff --git a/src/game/Player.h b/src/game/Player.h | |
index 4c96c0f..5e17a1a 100644 | |
--- a/src/game/Player.h | |
+++ b/src/game/Player.h | |
@@ -1214,11 +1214,6 @@ class MANGOS_DLL_SPEC Player : public Unit | |
void UpdateInnerTime (time_t time) { time_inn_enter = time; } | |
void RemovePet(PetSaveMode mode); | |
- void RemoveMiniPet(); | |
- Pet* GetMiniPet() const; | |
- | |
- // use only in Pet::Unsummon/Spell::DoSummon | |
- void _SetMiniPet(Pet* pet) { m_miniPetGuid = pet ? pet->GetObjectGuid() : ObjectGuid(); } | |
template<typename Func> | |
void CallForAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet); | |
@@ -2626,8 +2621,6 @@ class MANGOS_DLL_SPEC Player : public Unit | |
uint32 m_groupUpdateMask; | |
uint64 m_auraUpdateMask; | |
- ObjectGuid m_miniPetGuid; | |
- | |
// Player summoning | |
time_t m_summon_expire; | |
uint32 m_summon_mapid; | |
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp | |
index a3b06d5..1167fb3 100644 | |
--- a/src/game/SpellEffects.cpp | |
+++ b/src/game/SpellEffects.cpp | |
@@ -7596,7 +7596,7 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction) | |
if(duration > 0) | |
critter->SetDuration(duration); | |
- player->_SetMiniPet(critter); | |
+ player->SetMiniPet(critter); | |
map->Add((Creature*)critter); | |
} | |
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp | |
index e4d1abc..fd4a422 100644 | |
--- a/src/game/Unit.cpp | |
+++ b/src/game/Unit.cpp | |
@@ -5849,6 +5849,22 @@ Pet* Unit::_GetPet(ObjectGuid guid) const | |
return GetMap()->GetPet(guid); | |
} | |
+void Unit::RemoveMiniPet() | |
+{ | |
+ if (Pet* pet = GetMiniPet()) | |
+ pet->Unsummon(PET_SAVE_AS_DELETED,this); | |
+ else | |
+ SetCritterGuid(ObjectGuid()); | |
+} | |
+ | |
+Pet* Unit::GetMiniPet() const | |
+{ | |
+ if (GetCritterGuid().IsEmpty()) | |
+ return NULL; | |
+ | |
+ return GetMap()->GetPet(GetCritterGuid()); | |
+} | |
+ | |
Unit* Unit::GetCharm() const | |
{ | |
ObjectGuid charm_guid = GetCharmGuid(); | |
diff --git a/src/game/Unit.h b/src/game/Unit.h | |
index 3d61591..231e333 100644 | |
--- a/src/game/Unit.h | |
+++ b/src/game/Unit.h | |
@@ -1496,6 +1496,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject | |
ObjectGuid const& GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); } | |
void SetChannelObjectGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, targetGuid); } | |
+ void SetCritterGuid(ObjectGuid critter) { SetGuidValue(UNIT_FIELD_CRITTER, critter); } | |
+ ObjectGuid const& GetCritterGuid() const { return GetGuidValue(UNIT_FIELD_CRITTER); } | |
+ | |
+ void RemoveMiniPet(); | |
+ Pet* GetMiniPet() const; | |
+ void SetMiniPet(Unit* pet) { SetCritterGuid(pet ? pet->GetObjectGuid() : ObjectGuid()); } | |
+ | |
ObjectGuid const& GetCharmerOrOwnerGuid() const { return !GetCharmerGuid().IsEmpty() ? GetCharmerGuid() : GetOwnerGuid(); } | |
ObjectGuid const& GetCharmerOrOwnerOrOwnGuid() const | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment