Core/BattlePets: Implemented CMSG_BATTLE_PET_UPDATE_NOTIFY
Port From (https://github.com/TrinityCore/TrinityCore/commit/966430dc449f6ac259262cb996051dfd04a6e5fb)
This commit is contained in:
@@ -689,17 +689,6 @@ namespace Game.BattlePets
|
|||||||
List<BattlePet> updates = new();
|
List<BattlePet> updates = new();
|
||||||
updates.Add(pet);
|
updates.Add(pet);
|
||||||
SendUpdates(updates, false);
|
SendUpdates(updates, false);
|
||||||
|
|
||||||
// Update battle pet related update fields
|
|
||||||
Creature summonedBattlePet = player.GetSummonedBattlePet();
|
|
||||||
if (summonedBattlePet != null)
|
|
||||||
{
|
|
||||||
if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
|
|
||||||
{
|
|
||||||
summonedBattlePet.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
|
||||||
player.SetBattlePetData(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GrantBattlePetLevel(ObjectGuid guid, ushort grantedLevels)
|
public void GrantBattlePetLevel(ObjectGuid guid, ushort grantedLevels)
|
||||||
@@ -720,14 +709,12 @@ namespace Game.BattlePets
|
|||||||
if (level >= SharedConst.MaxBattlePetLevel)
|
if (level >= SharedConst.MaxBattlePetLevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = _owner.GetPlayer();
|
|
||||||
|
|
||||||
while (grantedLevels > 0 && level < SharedConst.MaxBattlePetLevel)
|
while (grantedLevels > 0 && level < SharedConst.MaxBattlePetLevel)
|
||||||
{
|
{
|
||||||
++level;
|
++level;
|
||||||
--grantedLevels;
|
--grantedLevels;
|
||||||
|
|
||||||
player.UpdateCriteria(CriteriaType.BattlePetReachLevel, pet.PacketInfo.Species, level);
|
_owner.GetPlayer().UpdateCriteria(CriteriaType.BattlePetReachLevel, pet.PacketInfo.Species, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
pet.PacketInfo.Level = level;
|
pet.PacketInfo.Level = level;
|
||||||
@@ -742,17 +729,6 @@ namespace Game.BattlePets
|
|||||||
List<BattlePet> updates = new List<BattlePet>();
|
List<BattlePet> updates = new List<BattlePet>();
|
||||||
updates.Add(pet);
|
updates.Add(pet);
|
||||||
SendUpdates(updates, false);
|
SendUpdates(updates, false);
|
||||||
|
|
||||||
// Update battle pet related update fields
|
|
||||||
Creature summonedBattlePet = player.GetSummonedBattlePet();
|
|
||||||
if (summonedBattlePet != null)
|
|
||||||
{
|
|
||||||
if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
|
|
||||||
{
|
|
||||||
summonedBattlePet.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
|
||||||
player.SetBattlePetData(pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HealBattlePetsPct(byte pct)
|
public void HealBattlePetsPct(byte pct)
|
||||||
@@ -777,6 +753,26 @@ namespace Game.BattlePets
|
|||||||
SendUpdates(updates, false);
|
SendUpdates(updates, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateBattlePetData(ObjectGuid guid)
|
||||||
|
{
|
||||||
|
BattlePet pet = GetPet(guid);
|
||||||
|
if (pet == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = _owner.GetPlayer();
|
||||||
|
|
||||||
|
// Update battle pet related update fields
|
||||||
|
Creature summonedBattlePet = player.GetSummonedBattlePet();
|
||||||
|
if (summonedBattlePet != null)
|
||||||
|
{
|
||||||
|
if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
|
||||||
|
{
|
||||||
|
summonedBattlePet.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
||||||
|
player.SetBattlePetData(pet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SummonPet(ObjectGuid guid)
|
public void SummonPet(ObjectGuid guid)
|
||||||
{
|
{
|
||||||
BattlePet pet = GetPet(guid);
|
BattlePet pet = GetPet(guid);
|
||||||
|
|||||||
@@ -146,5 +146,11 @@ namespace Game
|
|||||||
else
|
else
|
||||||
GetBattlePetMgr().DismissPet();
|
GetBattlePetMgr().DismissPet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[WorldPacketHandler(ClientOpcodes.BattlePetUpdateNotify)]
|
||||||
|
void HandleBattlePetUpdateNotify(BattlePetUpdateNotify battlePetUpdateNotify)
|
||||||
|
{
|
||||||
|
GetBattlePetMgr().UpdateBattlePetData(battlePetUpdateNotify.PetGuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,18 @@ namespace Game.Networking.Packets
|
|||||||
public ObjectGuid PetGuid;
|
public ObjectGuid PetGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BattlePetUpdateNotify : ClientPacket
|
||||||
|
{
|
||||||
|
public ObjectGuid PetGuid;
|
||||||
|
|
||||||
|
public BattlePetUpdateNotify(WorldPacket packet) : base(packet) { }
|
||||||
|
|
||||||
|
public override void Read()
|
||||||
|
{
|
||||||
|
PetGuid = _worldPacket.ReadPackedGuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Structs
|
//Structs
|
||||||
public struct BattlePetStruct
|
public struct BattlePetStruct
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user