Core/PacketIO: Updated and enabled CMSG_QUERY_PET_NAME / SMSG_QUERY_PET_NAME_RESPONSE for WoD

This commit is contained in:
Vincent-Michael
2015-04-18 19:17:19 +02:00
parent a1fe3cccd8
commit ee057d3a8d
5 changed files with 84 additions and 38 deletions

View File

@@ -34,6 +34,7 @@
#include "SpellInfo.h"
#include "Player.h"
#include "SpellPackets.h"
#include "QueryPackets.h"
void WorldSession::HandleDismissCritter(WorldPacket& recvData)
{
@@ -413,48 +414,36 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
}
}
void WorldSession::HandlePetNameQuery(WorldPacket& recvData)
void WorldSession::HandleQueryPetName(WorldPackets::Query::QueryPetName& packet)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PET_NAME_QUERY");
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUERY_PET_NAME");
uint32 petnumber;
ObjectGuid petguid;
recvData >> petnumber;
recvData >> petguid;
SendPetNameQuery(petguid, petnumber);
SendPetNameQuery(packet.UnitGUID);
}
void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber)
void WorldSession::SendPetNameQuery(ObjectGuid guid)
{
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
if (!pet)
WorldPackets::Query::QueryPetNameResponse response;
response.UnitGUID = guid;
if (Creature* unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid))
{
WorldPacket data(SMSG_QUERY_PET_NAME_RESPONSE, (4 + 1 + 4 + 1));
data << uint32(petnumber);
data << uint8(0);
data << uint32(0);
data << uint8(0);
_player->GetSession()->SendPacket(&data);
return;
response.Allow = true;
response.Timestamp = unit->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP);
response.Name = unit->GetName();
if (Pet* pet = unit->ToPet())
{
if (DeclinedName const* names = pet->GetDeclinedNames())
{
response.HasDeclined = true;
response.DeclinedNames = *names;
}
}
}
WorldPacket data(SMSG_QUERY_PET_NAME_RESPONSE, (4 + 4 + pet->GetName().size() + 1));
data << uint32(petnumber);
data << pet->GetName();
data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
if (pet->IsPet() && ((Pet*)pet)->GetDeclinedNames())
{
data << uint8(1);
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << ((Pet*)pet)->GetDeclinedNames()->name[i];
}
else
data << uint8(0);
_player->GetSession()->SendPacket(&data);
_player->GetSession()->SendPacket(response.Write());
}
bool WorldSession::CheckStableMaster(ObjectGuid guid)

View File

@@ -434,3 +434,33 @@ WorldPacket const* WorldPackets::Query::QuestCompletionNPCResponse::Write()
return &_worldPacket;
}
void WorldPackets::Query::QueryPetName::Read()
{
_worldPacket >> UnitGUID;
}
WorldPacket const* WorldPackets::Query::QueryPetNameResponse::Write()
{
_worldPacket << UnitGUID;
_worldPacket.WriteBit(Allow);
if (Allow)
{
_worldPacket.WriteBits(Name.length(), 8);
_worldPacket.WriteBit(HasDeclined);
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
_worldPacket.WriteBits(DeclinedNames.name[i].length(), 7);
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
_worldPacket.WriteString(DeclinedNames.name[i]);
_worldPacket << Timestamp;
_worldPacket.WriteString(Name);
}
_worldPacket.FlushBits();
return &_worldPacket;
}

View File

@@ -392,6 +392,32 @@ namespace WorldPackets
std::vector<QuestCompletionNPC> QuestCompletionNPCs;
};
class QueryPetName final : public ClientPacket
{
public:
QueryPetName(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_PET_NAME, std::move(packet)) { }
void Read() override;
ObjectGuid UnitGUID;
};
class QueryPetNameResponse final : public ServerPacket
{
public:
QueryPetNameResponse() : ServerPacket(SMSG_QUERY_PET_NAME_RESPONSE, 16 + 1) { }
WorldPacket const* Write() override;
ObjectGuid UnitGUID;
bool Allow = false;
bool HasDeclined = false;
DeclinedName DeclinedNames;
uint32 Timestamp = 0;
std::string Name;
};
}
}

View File

@@ -631,7 +631,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_QUERY_NPC_TEXT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryNPCText, &WorldSession::HandleNpcTextQueryOpcode);
DEFINE_HANDLER(CMSG_QUERY_PAGE_TEXT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPageText, &WorldSession::HandleQueryPageText);
DEFINE_HANDLER(CMSG_QUERY_PETITION, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Petition::QueryPetition, &WorldSession::HandleQueryPetition);
DEFINE_OPCODE_HANDLER_OLD(CMSG_QUERY_PET_NAME, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandlePetNameQuery );
DEFINE_HANDLER(CMSG_QUERY_PET_NAME, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPetName, &WorldSession::HandleQueryPetName);
DEFINE_HANDLER(CMSG_QUERY_PLAYER_NAME, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryPlayerName, &WorldSession::HandleNameQueryOpcode);
DEFINE_HANDLER(CMSG_QUERY_QUEST_COMPLETION_NPCS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Query::QueryQuestCompletionNPCs, &WorldSession::HandleQueryQuestCompletionNPCs);
DEFINE_HANDLER(CMSG_QUERY_QUEST_INFO, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Quest::QueryQuestInfo, &WorldSession::HandleQuestQueryOpcode);
@@ -1508,7 +1508,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_NPC_TEXT_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PAGE_TEXT_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PETITION_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PET_NAME_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PET_NAME_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PLAYER_NAME_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_QUEST_INFO_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_TIME_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);

View File

@@ -363,6 +363,7 @@ namespace WorldPackets
class QueryCorpseLocationFromClient;
class QueryCorpseTransport;
class QueryTime;
class QueryPetName;
class QuestPOIQuery;
class QueryQuestCompletionNPCs;
}
@@ -766,7 +767,7 @@ class WorldSession
void HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets);
// Pet
void SendPetNameQuery(ObjectGuid guid, uint32 petnumber);
void SendPetNameQuery(ObjectGuid guid);
void SendStablePet(ObjectGuid guid);
void SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid);
void SendPetStableResult(uint8 guid);
@@ -1270,7 +1271,7 @@ class WorldSession
void HandlePetAction(WorldPacket& recvData);
void HandlePetStopAttack(WorldPacket& recvData);
void HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spellid, uint16 flag, ObjectGuid guid2, float x, float y, float z);
void HandlePetNameQuery(WorldPacket& recvData);
void HandleQueryPetName(WorldPackets::Query::QueryPetName& packet);
void HandlePetSetAction(WorldPacket& recvData);
void HandlePetAbandon(WorldPacket& recvData);
void HandlePetRename(WorldPacket& recvData);