Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Packets: converted CMSG_SET_PET_SLOT to packet class
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovahlord committed Sep 26, 2023
1 parent 007f24c commit 4b6fa10
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
35 changes: 6 additions & 29 deletions src/server/game/Handlers/NPCHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,51 +341,28 @@ void WorldSession::SendStableResult(uint8 result)
SendPacket(packet.Write());
}

void WorldSession::HandleSetPetSlot(WorldPacket& recvData)
void WorldSession::HandleSetPetSlot(WorldPackets::Pet::SetPetSlot& packet)
{
/*
TC_LOG_DEBUG("network", "WORLD: Recv CMSG_STABLE_PET");
ObjectGuid guid;
uint32 petId;
uint8 new_slot;
recvData >> petId >> new_slot;
guid[3] = recvData.ReadBit();
guid[2] = recvData.ReadBit();
guid[0] = recvData.ReadBit();
guid[7] = recvData.ReadBit();
guid[5] = recvData.ReadBit();
guid[6] = recvData.ReadBit();
guid[1] = recvData.ReadBit();
guid[4] = recvData.ReadBit();
recvData.ReadByteSeq(guid[5]);
recvData.ReadByteSeq(guid[3]);
recvData.ReadByteSeq(guid[1]);
recvData.ReadByteSeq(guid[7]);
recvData.ReadByteSeq(guid[4]);
recvData.ReadByteSeq(guid[0]);
recvData.ReadByteSeq(guid[6]);
recvData.ReadByteSeq(guid[2]);
if (!GetPlayer()->IsAlive())
if (!_player->IsAlive())
{
SendStableResult(STABLE_ERR_STABLE);
return;
}
if (!CheckStableMaster(guid))
if (!CheckStableMaster(packet.StableMaster))
{
SendStableResult(STABLE_ERR_STABLE);
return;
}
if (new_slot > PET_SLOT_LAST_STABLE_SLOT)
if (packet.DestSlot > PET_SLOT_LAST_STABLE_SLOT)
{
SendStableResult(STABLE_ERR_STABLE);
return;
}
PlayerPetData* playerPetData = _player->GetPlayerPetDataById(petId);
CreatureTemplate const* creatureInfo = nullptr;
Expand Down
24 changes: 24 additions & 0 deletions src/server/game/Server/Packets/PetPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,27 @@ WorldPacket const* WorldPackets::Pet::PetStableResult::Write()

return &_worldPacket;
}

void WorldPackets::Pet::SetPetSlot::Read()
{
_worldPacket >> PetNumber;
_worldPacket >> DestSlot;

StableMaster[3] = _worldPacket.ReadBit();
StableMaster[2] = _worldPacket.ReadBit();
StableMaster[0] = _worldPacket.ReadBit();
StableMaster[7] = _worldPacket.ReadBit();
StableMaster[5] = _worldPacket.ReadBit();
StableMaster[6] = _worldPacket.ReadBit();
StableMaster[1] = _worldPacket.ReadBit();
StableMaster[4] = _worldPacket.ReadBit();

_worldPacket.ReadByteSeq(StableMaster[5]);
_worldPacket.ReadByteSeq(StableMaster[3]);
_worldPacket.ReadByteSeq(StableMaster[1]);
_worldPacket.ReadByteSeq(StableMaster[7]);
_worldPacket.ReadByteSeq(StableMaster[4]);
_worldPacket.ReadByteSeq(StableMaster[0]);
_worldPacket.ReadByteSeq(StableMaster[6]);
_worldPacket.ReadByteSeq(StableMaster[2]);
}
13 changes: 13 additions & 0 deletions src/server/game/Server/Packets/PetPackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ namespace WorldPackets

uint8 Result = 0;
};

class SetPetSlot final : public ClientPacket
{
public:
SetPetSlot(WorldPacket&& packet) : ClientPacket(CMSG_SET_PET_SLOT, std::move(packet)) { }

void Read() override;

ObjectGuid StableMaster;
uint32 PetNumber = 0;
uint8 DestSlot = 0;
};

}
}

Expand Down
3 changes: 2 additions & 1 deletion src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ namespace WorldPackets
class DismissCritter;
class PetAction;
class CPetStableList;
class SetPetSlot;
}

namespace Quest
Expand Down Expand Up @@ -918,7 +919,7 @@ class TC_GAME_API WorldSession
void HandleNpcTextQueryOpcode(WorldPacket& recvPacket);
void HandleBinderActivateOpcode(WorldPackets::NPC::Hello& packet);
void HandleListStabledPetsOpcode(WorldPackets::Pet::CPetStableList& packet);
void HandleSetPetSlot(WorldPacket& recvPacket);
void HandleSetPetSlot(WorldPackets::Pet::SetPetSlot& packet);
void HandleStableRevivePet(WorldPacket& recvPacket);

void HandleDuelAcceptedOpcode(WorldPacket& recvPacket);
Expand Down

0 comments on commit 4b6fa10

Please sign in to comment.