9be431bb56
Port From (https://github.com/TrinityCore/TrinityCore/commit/de4eaa0de9565da604fa3b6e2b4b59efe117fd7a)
102 lines
3.8 KiB
C#
102 lines
3.8 KiB
C#
/*
|
|
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
using Framework.Constants;
|
|
using Game.BattlePets;
|
|
using Game.Networking;
|
|
using Game.Networking.Packets;
|
|
|
|
namespace Game
|
|
{
|
|
public partial class WorldSession
|
|
{
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetRequestJournal)]
|
|
void HandleBattlePetRequestJournal(BattlePetRequestJournal battlePetRequestJournal)
|
|
{
|
|
GetBattlePetMgr().SendJournal();
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetSetBattleSlot)]
|
|
void HandleBattlePetSetBattleSlot(BattlePetSetBattleSlot battlePetSetBattleSlot)
|
|
{
|
|
BattlePetMgr.BattlePet pet = GetBattlePetMgr().GetPet(battlePetSetBattleSlot.PetGuid);
|
|
if (pet != null)
|
|
{
|
|
BattlePetSlot slot = GetBattlePetMgr().GetSlot(battlePetSetBattleSlot.Slot);
|
|
if (slot != null)
|
|
slot.Pet = pet.PacketInfo;
|
|
}
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetModifyName)]
|
|
void HandleBattlePetModifyName(BattlePetModifyName battlePetModifyName)
|
|
{
|
|
BattlePetMgr.BattlePet pet = GetBattlePetMgr().GetPet(battlePetModifyName.PetGuid);
|
|
if (pet != null)
|
|
{
|
|
pet.PacketInfo.Name = battlePetModifyName.Name;
|
|
|
|
if (pet.SaveInfo != BattlePetSaveInfo.New)
|
|
pet.SaveInfo = BattlePetSaveInfo.Changed;
|
|
}
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetDeletePet)]
|
|
void HandleBattlePetDeletePet(BattlePetDeletePet battlePetDeletePet)
|
|
{
|
|
GetBattlePetMgr().RemovePet(battlePetDeletePet.PetGuid);
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetSetFlags)]
|
|
void HandleBattlePetSetFlags(BattlePetSetFlags battlePetSetFlags)
|
|
{
|
|
var pet = GetBattlePetMgr().GetPet(battlePetSetFlags.PetGuid);
|
|
if (pet != null)
|
|
{
|
|
if (battlePetSetFlags.ControlType == FlagsControlType.Apply)
|
|
pet.PacketInfo.Flags |= (ushort)battlePetSetFlags.Flags;
|
|
else
|
|
pet.PacketInfo.Flags &= (ushort)~battlePetSetFlags.Flags;
|
|
|
|
if (pet.SaveInfo != BattlePetSaveInfo.New)
|
|
pet.SaveInfo = BattlePetSaveInfo.Changed;
|
|
}
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetClearFanfare)]
|
|
void HandleBattlePetClearFanfare(BattlePetClearFanfare battlePetClearFanfare)
|
|
{
|
|
GetBattlePetMgr().ClearFanfare(battlePetClearFanfare.PetGuid);
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.CageBattlePet)]
|
|
void HandleCageBattlePet(CageBattlePet cageBattlePet)
|
|
{
|
|
GetBattlePetMgr().CageBattlePet(cageBattlePet.PetGuid);
|
|
}
|
|
|
|
[WorldPacketHandler(ClientOpcodes.BattlePetSummon, Processing = PacketProcessing.Inplace)]
|
|
void HandleBattlePetSummon(BattlePetSummon battlePetSummon)
|
|
{
|
|
if (_player.m_activePlayerData.SummonedBattlePetGUID != battlePetSummon.PetGuid)
|
|
GetBattlePetMgr().SummonPet(battlePetSummon.PetGuid);
|
|
else
|
|
GetBattlePetMgr().DismissPet();
|
|
}
|
|
}
|
|
}
|