本文整理汇总了C++中ObjectGuid::WriteAsPacked方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::WriteAsPacked方法的具体用法?C++ ObjectGuid::WriteAsPacked怎么用?C++ ObjectGuid::WriteAsPacked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGuid
的用法示例。
在下文中一共展示了ObjectGuid::WriteAsPacked方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendEnchantmentLog
void WorldSession::SendEnchantmentLog(ObjectGuid targetGuid, ObjectGuid casterGuid, uint32 itemId, uint32 spellId)
{
WorldPacket data(SMSG_ENCHANTMENTLOG, (8 + 8 + 4 + 4 + 1)); // last check 2.0.10
data << targetGuid.WriteAsPacked();
data << casterGuid.WriteAsPacked();
data << uint32(itemId);
data << uint32(spellId);
SendPacket(&data);
}
示例2: SendEnchantmentLog
void WorldSession::SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
{
WorldPacket data(SMSG_ENCHANTMENTLOG, (8+8+4+4)); // last check 2.0.10
data << target.WriteAsPacked();
data << caster.WriteAsPacked();
data << uint32(itemId);
data << uint32(enchantId);
GetPlayer()->SendMessageToSet(&data, true);
}
示例3: SendCalendarEventInvite
void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite)
{
CalendarEvent* calendarEvent = GetEvent(invite.GetEventId());
time_t statusTime = invite.GetStatusTime();
bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00
ObjectGuid invitee = invite.GetInviteeGUID();
Player* player = ObjectAccessor::FindConnectedPlayer(invitee);
uint8 level = player ? player->getLevel() : sCharacterCache->GetCharacterLevelByGuid(invitee);
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (4) + 1);
data << invitee.WriteAsPacked();
data << uint64(invite.GetEventId());
data << uint64(invite.GetInviteId());
data << uint8(level);
data << uint8(invite.GetStatus());
data << uint8(hasStatusTime);
if (hasStatusTime)
data.AppendPackedTime(statusTime);
data << uint8(invite.GetSenderGUID() != invite.GetInviteeGUID()); // false only if the invite is sign-up
if (!calendarEvent) // Pre-invite
{
if (Player* playerSender = ObjectAccessor::FindConnectedPlayer(invite.GetSenderGUID()))
playerSender->SendDirectMessage(&data);
}
else
{
if (calendarEvent->GetCreatorGUID() != invite.GetInviteeGUID()) // correct?
SendPacketToAllEventRelatives(data, *calendarEvent);
}
}
示例4: SendEncounterFrame
void InstanceData::SendEncounterFrame(uint32 type, ObjectGuid sourceGuid /*= NULL*/, uint8 param1 /*= 0*/, uint8 param2 /*= 0*/)
{
// size of this packet is at most 15 (usually less)
WorldPacket data(SMSG_INSTANCE_ENCOUNTER, 15);
data << uint32(type);
switch (type)
{
case ENCOUNTER_FRAME_ENGAGE:
case ENCOUNTER_FRAME_DISENGAGE:
case ENCOUNTER_FRAME_UPDATE_PRIORITY:
MANGOS_ASSERT(sourceGuid);
data << sourceGuid.WriteAsPacked();
data << uint8(param1);
break;
case ENCOUNTER_FRAME_ADD_TIMER:
case ENCOUNTER_FRAME_ENABLE_OBJECTIVE:
case ENCOUNTER_FRAME_DISABLE_OBJECTIVE:
case ENCOUNTER_FRAME_SET_COMBAT_RES_LIMIT:
data << uint8(param1);
break;
case ENCOUNTER_FRAME_UPDATE_OBJECTIVE:
data << uint8(param1);
data << uint8(param2);
break;
case ENCOUNTER_FRAME_UNK7:
case ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT:
case ENCOUNTER_FRAME_RESET_COMBAT_RES_LIMIT:
default:
break;
}
instance->SendToPlayers(&data);
}
示例5: HandleMoveKnockBackAck
void WorldSession::HandleMoveKnockBackAck(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "CMSG_MOVE_KNOCK_BACK_ACK");
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
if (_player->m_mover->GetGUID() != guid)
return;
recvData.read_skip<uint32>(); // unk
MovementInfo movementInfo;
ReadMovementInfo(recvData, &movementInfo);
_player->m_movementInfo = movementInfo;
WorldPacket data(MSG_MOVE_KNOCK_BACK, 66);
data << guid.WriteAsPacked();
_player->BuildMovementPacket(&data);
// knockback specific info
data << movementInfo.jump.sinAngle;
data << movementInfo.jump.cosAngle;
data << movementInfo.jump.xyspeed;
data << movementInfo.jump.zspeed;
_player->SendMessageToSet(&data, false);
}
示例6: SendNameQueryOpcode
void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
{
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid);
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data << guid.WriteAsPacked();
if (!nameData)
{
data << uint8(1); // name unknown
SendPacket(&data);
return;
}
data << uint8(0); // name known
data << nameData->m_name; // played name
data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
data << uint8(nameData->m_race);
data << uint8(nameData->m_gender);
data << uint8(nameData->m_class);
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL))
{
data << uint8(1); // Name is declined
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << names->name[i];
}
else
data << uint8(0); // Name is not declined
SendPacket(&data);
}
示例7: HandleFeatherFallAck
void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data)
{
DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK size %u", recv_data.wpos());
ObjectGuid guid;
MovementInfo movementInfo;
recv_data >> guid; // guid
recv_data.read_skip<uint32>(); // counter
recv_data >> movementInfo;
movementInfo.UpdateTime(recv_data.GetPacketTime());
if (guid != _clientMoverGuid)
return;
if (!VerifyMovementInfo(movementInfo))
return;
if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
return;
// Position change
HandleMoverRelocation(movementInfo);
_player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());
WorldPacket data(MSG_MOVE_FEATHER_FALL, recv_data.size());
data << guid.WriteAsPacked();
movementInfo.Write(data);
_player->SendMovementMessageToSet(std::move(data), true, _player);
}
示例8: HandleNameQueryOpcode
void WorldSession::HandleNameQueryOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
uint32 bytesLeft = recv_data.wpos() - recv_data.rpos();
sLog.outDebug("Received CMSG_NAME_QUERY from %s. Guid %s bytesleft %u.",
_player->GetGuidStr().c_str(), guid.GetString().c_str(), bytesLeft);
switch (bytesLeft)
{
case 4:
{
uint32 realmId;
recv_data >> realmId;
if (!realmId)
realmId = realmID;
// actually will never happen
if (realmID != realmId)
{
sLog.outError("Warning! Quering players from other realms is not supported. Queried realm id: %u This realm id: %u Guid: %s",
realmId, realmID, guid.GetString().c_str());
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, 9);
data << guid.WriteAsPacked();
data << uint8(1);
SendPacket(&data);
return;
}
Player* pChar = sObjectMgr.GetPlayer(guid);
if (pChar)
SendNameQueryOpcode(pChar, realmId);
else
SendNameQueryOpcodeFromDB(guid, realmId);
break;
}
case 8:
{
uint64 unk64;
recv_data >> unk64;
sLog.outDebug("Received unhandled CMSG_NAME_QUERY with uint64 value " UI64FMTD, unk64);
break;
}
case 12:
{
uint32 unk32;
uint64 unk64;
recv_data >> unk32 >> unk64;
sLog.outDebug("Received unhandled CMSG_NAME_QUERY with int32 value %u and uint64 value " UI64FMTD, unk32, unk64);
break;
}
}
}
示例9: SendCalendarEvent
void CalendarMgr::SendCalendarEvent(Player* player, CalendarEvent const* event, uint32 sendType)
{
if (!player || !event)
return;
std::string timeStr = TimeToTimestampStr(event->EventTime);
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarEvent> sendType[%u], CreatorGuid[%s], EventId["UI64FMTD"], Type[%u], Flags[%u], Title[%s]",
sendType, event->CreatorGuid.GetString().c_str(), event->EventId, uint32(event->Type), event->Flags, event->Title.c_str());
WorldPacket data(SMSG_CALENDAR_SEND_EVENT);
data << uint8(sendType);
data << event->CreatorGuid.WriteAsPacked();
data << uint64(event->EventId);
data << event->Title;
data << event->Description;
data << uint8(event->Type);
data << uint8(event->Repeatable);
data << uint32(CALENDAR_MAX_INVITES);
data << event->DungeonId;
data << event->Flags;
data << secsToTimeBitFields(event->EventTime);
data << secsToTimeBitFields(event->UnknownTime);
data << event->GuildId;
CalendarInviteMap const* cInvMap = event->GetInviteMap();
data << (uint32)cInvMap->size();
for (CalendarInviteMap::const_iterator itr = cInvMap->begin(); itr != cInvMap->end(); ++itr)
{
CalendarInvite const* invite = itr->second;
ObjectGuid inviteeGuid = invite->InviteeGuid;
Player* invitee = sObjectMgr.GetPlayer(inviteeGuid);
uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid);
uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid);
data << inviteeGuid.WriteAsPacked();
data << uint8(inviteeLevel);
data << uint8(invite->Status);
data << uint8(invite->Rank);
data << uint8(event->IsGuildEvent() && event->GuildId == inviteeGuildId);
data << uint64(itr->first);
data << secsToTimeBitFields(invite->LastUpdateTime);
data << invite->Text;
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Invite> InviteId["UI64FMTD"], InviteLvl[%u], Status[%u], Rank[%u], GuildEvent[%s], Text[%s]",
invite->InviteId, uint32(inviteeLevel), uint32(invite->Status), uint32(invite->Rank),
(event->IsGuildEvent() && event->GuildId == inviteeGuildId) ? "true" : "false", invite->Text.c_str());
}
//data.hexlike();
player->SendDirectMessage(&data);
}
示例10: SendCalendarEvent
void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType)
{
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
if (!player)
return;
CalendarInviteStore const& eventInviteeList = _invites[calendarEvent.GetEventId()];
WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32);
data << uint8(sendType);
data << calendarEvent.GetCreatorGUID().WriteAsPacked();
data << uint64(calendarEvent.GetEventId());
data << calendarEvent.GetTitle();
data << calendarEvent.GetDescription();
data << uint8(calendarEvent.GetType());
data << uint8(CALENDAR_REPEAT_NEVER); // repeatable
data << uint32(CALENDAR_MAX_INVITES);
data << int32(calendarEvent.GetDungeonId());
data << uint32(calendarEvent.GetFlags());
data.AppendPackedTime(calendarEvent.GetEventTime());
data.AppendPackedTime(calendarEvent.GetTimeZoneTime());
data << uint32(calendarEvent.GetGuildId());
data << uint32(eventInviteeList.size());
for (CalendarInviteStore::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr)
{
CalendarInvite const* calendarInvite = (*itr);
ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID();
Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid);
uint8 inviteeLevel = invitee ? invitee->getLevel() : sCharacterCache->GetCharacterLevelByGuid(inviteeGuid);
ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(inviteeGuid);
data << inviteeGuid.WriteAsPacked();
data << uint8(inviteeLevel);
data << uint8(calendarInvite->GetStatus());
data << uint8(calendarInvite->GetRank());
data << uint8(calendarEvent.IsGuildEvent() && calendarEvent.GetGuildId() == inviteeGuildId);
data << uint64(calendarInvite->GetInviteId());
data.AppendPackedTime(calendarInvite->GetStatusTime());
data << calendarInvite->GetText();
}
player->SendDirectMessage(&data);
}
示例11: HandleMoveKnockBackAck
void WorldSession::HandleMoveKnockBackAck(WorldPacket & recvData)
{
TC_LOG_DEBUG("network", "CMSG_MOVE_KNOCK_BACK_ACK");
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
if (_player->m_mover->GetGUID() != guid)
return;
recvData.read_skip<uint32>(); // unk
MovementInfo movementInfo;
ReadMovementInfo(recvData, &movementInfo);
// Save movement flags
_player->SetUnitMovementFlags(movementInfo.flags);
#ifdef ANTICHEAT_DEBUG
TC_LOG_WARN("cheat", "%s CMSG_MOVE_KNOCK_BACK_ACK: time: %d, fall time: %d | xyzo: %f,%f,%fo(%f) flags[%X] Vspeed: %f, Hspeed: %f", GetPlayer()->GetName(), movementInfo.time, movementInfo.fallTime, movementInfo.pos.m_positionX, movementInfo.pos.m_positionY, movementInfo.pos.m_positionZ, movementInfo.pos.m_orientation, movementInfo.flags, movementInfo.jump.zspeed, movementInfo.jump.xyspeed);
#endif
_player->m_movementInfo = movementInfo;
_player->m_anti_Last_HSpeed = movementInfo.jump.xyspeed;
_player->m_anti_Last_VSpeed = movementInfo.jump.zspeed < 3.2f ? movementInfo.jump.zspeed - 1.0f : 3.2f;
const uint32 dt = (_player->m_anti_Last_VSpeed < 0) ? int(ceil(_player->m_anti_Last_VSpeed / -25) * 1000) : int(ceil(_player->m_anti_Last_VSpeed / 25) * 1000);
_player->m_anti_LastSpeedChangeTime = movementInfo.time + dt + 1000;
WorldPacket data(MSG_MOVE_KNOCK_BACK, 66);
data << guid.WriteAsPacked();
_player->BuildMovementPacket(&data);
// knockback specific info
data << movementInfo.jump.sinAngle;
data << movementInfo.jump.cosAngle;
data << movementInfo.jump.xyspeed;
data << movementInfo.jump.zspeed;
_player->SendMessageToSet(&data, false);
}
示例12: HandleRequestPartyMemberStatsOpcode
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid Guid;
recvData >> Guid;
Player* player = ObjectAccessor::FindConnectedPlayer(Guid);
if (!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << Guid.WriteAsPacked();
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint16(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet* pet = player->GetPet();
Powers powerType = player->getPowerType();
std::set<uint32> const& phases = player->GetPhases();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
uint32 updateFlags = GROUP_UPDATE_FLAG_STATUS | GROUP_UPDATE_FLAG_CUR_HP | GROUP_UPDATE_FLAG_MAX_HP
| GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER | GROUP_UPDATE_FLAG_LEVEL
| GROUP_UPDATE_FLAG_ZONE | GROUP_UPDATE_FLAG_POSITION | GROUP_UPDATE_FLAG_AURAS
| GROUP_UPDATE_FLAG_PET_NAME | GROUP_UPDATE_FLAG_PET_MODEL_ID | GROUP_UPDATE_FLAG_PET_AURAS;
if (powerType != POWER_MANA)
updateFlags |= GROUP_UPDATE_FLAG_POWER_TYPE;
if (pet)
updateFlags |= GROUP_UPDATE_FLAG_PET_GUID | GROUP_UPDATE_FLAG_PET_CUR_HP | GROUP_UPDATE_FLAG_PET_MAX_HP
| GROUP_UPDATE_FLAG_PET_POWER_TYPE | GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER;
if (player->GetVehicle())
updateFlags |= GROUP_UPDATE_FLAG_VEHICLE_SEAT;
if (!phases.empty())
updateFlags |= GROUP_UPDATE_FLAG_PHASE;
uint16 playerStatus = MEMBER_STATUS_ONLINE;
if (player->IsPvP())
playerStatus |= MEMBER_STATUS_PVP;
if (!player->IsAlive())
{
if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
playerStatus |= MEMBER_STATUS_GHOST;
else
playerStatus |= MEMBER_STATUS_DEAD;
}
if (player->IsFFAPvP())
playerStatus |= MEMBER_STATUS_PVP_FFA;
if (player->isAFK())
playerStatus |= MEMBER_STATUS_AFK;
if (player->isDND())
playerStatus |= MEMBER_STATUS_DND;
data << uint32(updateFlags);
data << uint16(playerStatus); // GROUP_UPDATE_FLAG_STATUS
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
if (updateFlags & GROUP_UPDATE_FLAG_POWER_TYPE)
data << uint8(powerType);
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
data << uint16(player->GetZoneId()); // GROUP_UPDATE_FLAG_ZONE
data << uint16(player->GetPositionX()); // GROUP_UPDATE_FLAG_POSITION
data << uint16(player->GetPositionY()); // GROUP_UPDATE_FLAG_POSITION
data << uint16(player->GetPositionZ()); // GROUP_UPDATE_FLAG_POSITION
// GROUP_UPDATE_FLAG_AURAS
data << uint8(1);
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
data << uint32(MAX_AURAS); // count
for (uint8 i = 0; i < MAX_AURAS; ++i)
{
if (AuraApplication const* aurApp = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint32(aurApp->GetBase()->GetId());
data << uint16(aurApp->GetFlags());
if (aurApp->GetFlags() & AFLAG_ANY_EFFECT_AMOUNT_SENT)
{
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
//.........这里部分代码省略.........
示例13: HandleRequestPartyMemberStatsOpcode
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid guid;
recv_data >> guid;
Player * player = HashMapHolder<Player>::Find(guid);
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << guid.WriteAsPacked();
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint16(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
uint16 online_status = MEMBER_STATUS_ONLINE;
Powers powerType = player->getPowerType();
data << uint32(mask1); // group update mask
data << uint16(online_status); // member's online status
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
data << uint8(powerType); // GROUP_UPDATE_FLAG_POWER_TYPE
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
//verify player coordinates and zoneid to send to teammates
uint16 iZoneId = 0;
uint16 iCoordX = 0;
uint16 iCoordY = 0;
if (player->IsInWorld())
{
iZoneId = player->GetZoneId();
iCoordX = player->GetPositionX();
iCoordY = player->GetPositionY();
}
else if (player->IsBeingTeleported()) // Player is in teleportation
{
WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
iZoneId = sTerrainMgr.GetZoneId(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
iCoordX = loc.coord_x;
iCoordY = loc.coord_y;
}
else
{
//unknown player status.
}
data << uint16(iZoneId); // GROUP_UPDATE_FLAG_ZONE
data << uint16(iCoordX); // GROUP_UPDATE_FLAG_POSITION
data << uint16(iCoordY); // GROUP_UPDATE_FLAG_POSITION
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
MAPLOCK_READ(player,MAP_LOCK_TYPE_AURAS);
if(uint32 aura = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint32(aura);
data << uint8(1);
}
}
data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petpowertype = pet->getPowerType();
data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint32(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint32(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petpowertype); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint64 petauramask = 0;
size_t petMaskPos = data.wpos();
data << uint64(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
//.........这里部分代码省略.........
示例14: HandleRequestPartyMemberStatsOpcode
// this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request
void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid guid;
recv_data >> guid;
Player* player = ObjectAccessor::FindPlayer(guid, false);
if (!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 1 + 8 + 4 + 2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << guid.WriteAsPacked();
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint16(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Powers powerType = player->getPowerType();
uint32 updateFlags = GROUP_UPDATE_FLAG_STATUS | GROUP_UPDATE_FLAG_CUR_HP | GROUP_UPDATE_FLAG_MAX_HP |
GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER | GROUP_UPDATE_FLAG_LEVEL |
GROUP_UPDATE_FLAG_ZONE | GROUP_UPDATE_FLAG_POSITION | GROUP_UPDATE_FLAG_AURAS |
GROUP_UPDATE_FLAG_PET_NAME | GROUP_UPDATE_FLAG_PET_MODEL_ID | GROUP_UPDATE_FLAG_PET_AURAS;
if (powerType != POWER_MANA)
updateFlags |= GROUP_UPDATE_FLAG_POWER_TYPE;
Pet* pet = player->GetPet();
if (pet)
updateFlags |= GROUP_UPDATE_FLAG_PET_GUID | GROUP_UPDATE_FLAG_PET_CUR_HP | GROUP_UPDATE_FLAG_PET_MAX_HP |
GROUP_UPDATE_FLAG_PET_POWER_TYPE | GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER;
if (player->GetVehicle())
updateFlags |= GROUP_UPDATE_FLAG_VEHICLE_SEAT;
uint16 playerStatus = player->IsReferAFriendLinked(player) ? (MEMBER_STATUS_ONLINE | MEMBER_STATUS_RAF) : MEMBER_STATUS_ONLINE;
if (player->IsPvP())
playerStatus |= MEMBER_STATUS_PVP;
if (!player->isAlive())
{
if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
playerStatus |= MEMBER_STATUS_GHOST;
else
playerStatus |= MEMBER_STATUS_DEAD;
}
if (player->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
playerStatus |= MEMBER_STATUS_PVP_FFA;
if (player->isAFK())
playerStatus |= MEMBER_STATUS_AFK;
if (player->isDND())
playerStatus |= MEMBER_STATUS_DND;
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 255);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID();
data << uint32(updateFlags);
data << uint16(playerStatus); // GROUP_UPDATE_FLAG_STATUS
data << uint32(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint32(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
if (updateFlags & GROUP_UPDATE_FLAG_POWER_TYPE)
data << uint8(powerType);
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
// verify player coordinates and zoneid to send to teammates
uint16 iZoneId = 0;
uint16 iCoordX = 0;
uint16 iCoordY = 0;
if (player->IsInWorld())
{
iZoneId = player->GetZoneId();
iCoordX = player->GetPositionX();
iCoordY = player->GetPositionY();
}
else if (player->IsBeingTeleported()) // Player is in teleportation
{
WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
iZoneId = sTerrainMgr.GetZoneId(loc.GetMapId(), loc.x, loc.y, loc.z);
iCoordX = loc.x;
iCoordY = loc.y;
}
data << uint16(iZoneId); // GROUP_UPDATE_FLAG_ZONE
data << uint16(iCoordX); // GROUP_UPDATE_FLAG_POSITION
data << uint16(iCoordY); // GROUP_UPDATE_FLAG_POSITION
uint64 auramask = 0;
size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder
for (uint8 i = 0; i < MAX_AURAS; ++i)
{
//.........这里部分代码省略.........