aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/BattlePets/BattlePetMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/BattlePets/BattlePetMgr.cpp')
-rw-r--r--src/server/game/BattlePets/BattlePetMgr.cpp43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/server/game/BattlePets/BattlePetMgr.cpp b/src/server/game/BattlePets/BattlePetMgr.cpp
index 559ffd6f95c..8497aef1b71 100644
--- a/src/server/game/BattlePets/BattlePetMgr.cpp
+++ b/src/server/game/BattlePets/BattlePetMgr.cpp
@@ -734,16 +734,6 @@ void BattlePetMgr::GrantBattlePetExperience(ObjectGuid guid, uint16 xp, BattlePe
std::vector<std::reference_wrapper<BattlePet>> updates;
updates.push_back(std::ref(*pet));
SendUpdates(std::move(updates), false);
-
- // Update battle pet related update fields
- if (Creature* summonedBattlePet = player->GetSummonedBattlePet())
- {
- if (summonedBattlePet->GetBattlePetCompanionGUID() == guid)
- {
- summonedBattlePet->SetWildBattlePetLevel(pet->PacketInfo.Level);
- player->SetBattlePetData(pet);
- }
- }
}
void BattlePetMgr::GrantBattlePetLevel(ObjectGuid guid, uint16 grantedLevels)
@@ -763,14 +753,12 @@ void BattlePetMgr::GrantBattlePetLevel(ObjectGuid guid, uint16 grantedLevels)
if (level >= MAX_BATTLE_PET_LEVEL)
return;
- Player* player = _owner->GetPlayer();
-
while (grantedLevels > 0 && level < MAX_BATTLE_PET_LEVEL)
{
++level;
--grantedLevels;
- player->UpdateCriteria(CriteriaType::BattlePetReachLevel, pet->PacketInfo.Species, level);
+ _owner->GetPlayer()->UpdateCriteria(CriteriaType::BattlePetReachLevel, pet->PacketInfo.Species, level);
}
pet->PacketInfo.Level = level;
@@ -785,16 +773,6 @@ void BattlePetMgr::GrantBattlePetLevel(ObjectGuid guid, uint16 grantedLevels)
std::vector<std::reference_wrapper<BattlePet>> updates;
updates.push_back(std::ref(*pet));
SendUpdates(std::move(updates), false);
-
- // Update battle pet related update fields
- if (Creature* summonedBattlePet = player->GetSummonedBattlePet())
- {
- if (summonedBattlePet->GetBattlePetCompanionGUID() == guid)
- {
- summonedBattlePet->SetWildBattlePetLevel(pet->PacketInfo.Level);
- player->SetBattlePetData(pet);
- }
- }
}
void BattlePetMgr::HealBattlePetsPct(uint8 pct)
@@ -817,6 +795,25 @@ void BattlePetMgr::HealBattlePetsPct(uint8 pct)
SendUpdates(std::move(updates), false);
}
+void BattlePetMgr::UpdateBattlePetData(ObjectGuid guid)
+{
+ BattlePet* pet = GetPet(guid);
+ if (!pet)
+ return;
+
+ Player* player = _owner->GetPlayer();
+
+ // Update battle pet related update fields
+ if (Creature* summonedBattlePet = player->GetSummonedBattlePet())
+ {
+ if (summonedBattlePet->GetBattlePetCompanionGUID() == guid)
+ {
+ summonedBattlePet->SetWildBattlePetLevel(pet->PacketInfo.Level);
+ player->SetBattlePetData(pet);
+ }
+ }
+}
+
void BattlePetMgr::SummonPet(ObjectGuid guid)
{
BattlePet* pet = GetPet(guid);