Core/Battle Pets: Fixed possible crash in packet handler

This commit is contained in:
Shauren
2019-11-13 00:15:35 +01:00
parent ab6ae44b63
commit ce8f9b9a4e
2 changed files with 3 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ public:
uint8 GetPetCount(uint32 species) const;
WorldPackets::BattlePet::BattlePetSlot* GetSlot(uint8 slot) { return &_slots[slot]; }
WorldPackets::BattlePet::BattlePetSlot* GetSlot(uint8 slot) { return slot < _slots.size() ? &_slots[slot] : nullptr; }
void UnlockSlot(uint8 slot);
WorldSession* GetOwner() const { return _owner; }

View File

@@ -28,7 +28,8 @@ void WorldSession::HandleBattlePetRequestJournal(WorldPackets::BattlePet::Battle
void WorldSession::HandleBattlePetSetBattleSlot(WorldPackets::BattlePet::BattlePetSetBattleSlot& battlePetSetBattleSlot)
{
if (BattlePetMgr::BattlePet* pet = GetBattlePetMgr()->GetPet(battlePetSetBattleSlot.PetGuid))
GetBattlePetMgr()->GetSlot(battlePetSetBattleSlot.Slot)->Pet = pet->PacketInfo;
if (WorldPackets::BattlePet::BattlePetSlot* slot = GetBattlePetMgr()->GetSlot(battlePetSetBattleSlot.Slot))
slot->Pet = pet->PacketInfo;
}
void WorldSession::HandleBattlePetModifyName(WorldPackets::BattlePet::BattlePetModifyName& battlePetModifyName)