Update and enable CMSG_GET_MIRROR_IMAGE_DATA, SMSG_MIRROR_IMAGE_CREATURE_DATA, SMSG_MIRROR_IMAGE_COMPONENTED_DATA.

This commit is contained in:
Orion
2015-06-15 02:03:00 +03:00
committed by Rochet2
parent 3ada2ed993
commit eeb49d238a
5 changed files with 118 additions and 51 deletions

View File

@@ -501,11 +501,9 @@ void WorldSession::HandleSpellClick(WorldPacket& recvData)
unit->HandleSpellClick(_player);
}
void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
void WorldSession::HandleMirrorImageDataRequest(WorldPackets::Spells::GetMirrorImageData& packet)
{
ObjectGuid guid;
recvData >> guid;
recvData.read_skip<uint32>(); // DisplayId ?
ObjectGuid guid = packet.UnitGUID;
// Get unit for which data is needed by client
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
@@ -520,27 +518,25 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
if (!creator)
return;
WorldPacket data(SMSG_MIRROR_IMAGE_COMPONENTED_DATA, 68);
data << guid;
data << uint32(creator->GetDisplayId());
data << uint8(creator->getRace());
data << uint8(creator->getGender());
data << uint8(creator->getClass());
if (creator->GetTypeId() == TYPEID_PLAYER)
if (Player* player = creator->ToPlayer())
{
Player* player = creator->ToPlayer();
Guild* guild = NULL;
WorldPackets::Spells::MirrorImageComponentedData packet;
packet.UnitGUID = guid;
packet.DisplayID = creator->GetDisplayId();
packet.RaceID = creator->getRace();
packet.Gender = creator->getGender();
packet.ClassID = creator->getClass();
if (ObjectGuid::LowType guildId = player->GetGuildId())
guild = sGuildMgr->GetGuildById(guildId);
Guild* guild = player->GetGuild();
data << uint8(player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID));
data << uint8(player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID));
data << uint8(player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID));
data << uint8(player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID));
data << uint8(player->GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE));
data << (guild ? guild->GetGUID() : ObjectGuid::Empty);
packet.SkinColor = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID);
packet.FaceVariation = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID);
packet.HairVariation = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID);
packet.HairColor = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID);
packet.BeardVariation = player->GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE);
packet.GuildGUID = (guild ? guild->GetGUID() : ObjectGuid::Empty);
packet.ItemDisplayID.reserve(11);
static EquipmentSlots const itemSlots[] =
{
@@ -559,38 +555,28 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket& recvData)
};
// Display items in visible slots
for (EquipmentSlots const* itr = &itemSlots[0]; *itr != EQUIPMENT_SLOT_END; ++itr)
for (auto const& slot : itemSlots)
{
if (*itr == EQUIPMENT_SLOT_HEAD && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
data << uint32(0);
else if (*itr == EQUIPMENT_SLOT_BACK && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
data << uint32(0);
else if (Item const* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr))
data << uint32(item->GetDisplayId());
uint32 itemDisplayId;
if ((slot == EQUIPMENT_SLOT_HEAD && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) ||
(slot == EQUIPMENT_SLOT_BACK && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)))
itemDisplayId = 0;
else if (Item const* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
itemDisplayId = item->GetDisplayId();
else
data << uint32(0);
itemDisplayId = 0;
packet.ItemDisplayID.push_back(itemDisplayId);
}
SendPacket(packet.Write());
}
else
{
// Skip player data for creatures
data << uint8(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
WorldPackets::Spells::MirrorImageCreatureData packet;
packet.UnitGUID = guid;
packet.DisplayID = creator->GetDisplayId();
SendPacket(packet.Write());
}
SendPacket(&data);
}
void WorldSession::HandleUpdateProjectilePosition(WorldPacket& recvPacket)