Merge pull request #3086 from LihO/master

Core/Groups: Refactored sending of update packets.
Closes #1042.
This commit is contained in:
QAston
2011-09-21 01:05:53 -07:00
4 changed files with 72 additions and 47 deletions

View File

@@ -2329,6 +2329,7 @@ bool Player::TeleportToBGEntryPoint()
ScheduleDelayedOperation(DELAYED_BG_MOUNT_RESTORE);
ScheduleDelayedOperation(DELAYED_BG_TAXI_RESTORE);
ScheduleDelayedOperation(DELAYED_BG_GROUP_RESTORE);
return TeleportTo(m_bgData.joinPos);
}
@@ -2383,7 +2384,13 @@ void Player::ProcessDelayedOperations()
ContinueTaxiFlight();
}
}
if (m_DelayedOperations & DELAYED_BG_GROUP_RESTORE)
{
if (Group *g = GetGroup())
g->SendUpdateToPlayer(GetGUID());
}
//we have executed ALL delayed ops, so clear the flag
m_DelayedOperations = 0;
}

View File

@@ -820,6 +820,7 @@ enum PlayerDelayedOperations
DELAYED_SPELL_CAST_DESERTER = 0x04,
DELAYED_BG_MOUNT_RESTORE = 0x08, ///< Flag to restore mount state after teleport from BG
DELAYED_BG_TAXI_RESTORE = 0x10, ///< Flag to restore taxi state after teleport from BG
DELAYED_BG_GROUP_RESTORE = 0x20, ///< Flag to restore group state after teleport from BG
DELAYED_END
};

View File

@@ -1184,59 +1184,75 @@ void Group::SendTargetIconList(WorldSession* session)
void Group::SendUpdate()
{
Player* player;
for (member_witerator witr = m_memberSlots.begin(); witr != m_memberSlots.end(); ++witr)
{
SendUpdateToPlayer(witr->guid, &(*witr));
}
}
void Group::SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot)
{
Player* player = ObjectAccessor::FindPlayer(playerGUID);
if (!player || !player->GetSession() || player->GetGroup() != this)
return;
// if MemberSlot wasn't provided
if (!slot)
{
member_witerator witr = _getMemberWSlot(playerGUID);
if (witr == m_memberSlots.end()) // if there is no MemberSlot for such a player
return;
slot = &(*witr);
}
WorldPacket data(SMSG_GROUP_LIST, (1+1+1+1+1+4+8+4+4+(GetMembersCount()-1)*(13+8+1+1+1+1)+8+1+8+1+1+1+1));
data << uint8(m_groupType); // group type (flags in 3.3)
data << uint8(slot->group);
data << uint8(slot->flags);
data << uint8(slot->roles);
if (isLFGGroup())
{
data << uint8(sLFGMgr->GetState(m_guid) == LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
data << uint32(sLFGMgr->GetDungeon(m_guid));
}
data << uint64(m_guid);
data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
data << uint32(GetMembersCount()-1);
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
{
player = ObjectAccessor::FindPlayer(citr->guid);
if (!player || !player->GetSession() || player->GetGroup() != this)
if (slot->guid == citr->guid)
continue;
WorldPacket data(SMSG_GROUP_LIST, (1+1+1+1+1+4+8+4+4+(GetMembersCount()-1)*(13+8+1+1+1+1)+8+1+8+1+1+1+1));
data << uint8(m_groupType); // group type (flags in 3.3)
data << uint8(citr->group);
data << uint8(citr->flags);
data << uint8(citr->roles);
if (isLFGGroup())
{
data << uint8(sLFGMgr->GetState(m_guid) == LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
data << uint32(sLFGMgr->GetDungeon(m_guid));
}
Player* member = ObjectAccessor::FindPlayer(citr->guid);
data << uint64(m_guid);
data << uint32(m_counter++); // 3.3, value increases every time this packet gets sent
data << uint32(GetMembersCount()-1);
for (member_citerator citr2 = m_memberSlots.begin(); citr2 != m_memberSlots.end(); ++citr2)
{
if (citr->guid == citr2->guid)
continue;
uint8 onlineState = (member) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
onlineState = onlineState | ((isBGGroup()) ? MEMBER_STATUS_PVP : 0);
Player* member = ObjectAccessor::FindPlayer(citr2->guid);
uint8 onlineState = (member) ? MEMBER_STATUS_ONLINE : MEMBER_STATUS_OFFLINE;
onlineState = onlineState | ((isBGGroup()) ? MEMBER_STATUS_PVP : 0);
data << citr2->name;
data << uint64(citr2->guid); // guid
data << uint8(onlineState); // online-state
data << uint8(citr2->group); // groupid
data << uint8(citr2->flags); // See enum GroupMemberFlags
data << uint8(citr2->roles); // Lfg Roles
}
data << uint64(m_leaderGuid); // leader guid
if (GetMembersCount() - 1)
{
data << uint8(m_lootMethod); // loot method
data << uint64(m_looterGuid); // looter guid
data << uint8(m_lootThreshold); // loot threshold
data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
data << uint8(m_raidDifficulty); // Raid Difficulty
data << uint8(0); // 3.3
}
player->GetSession()->SendPacket(&data);
data << citr->name;
data << uint64(citr->guid); // guid
data << uint8(onlineState); // online-state
data << uint8(citr->group); // groupid
data << uint8(citr->flags); // See enum GroupMemberFlags
data << uint8(citr->roles); // Lfg Roles
}
data << uint64(m_leaderGuid); // leader guid
if (GetMembersCount() - 1)
{
data << uint8(m_lootMethod); // loot method
data << uint64(m_looterGuid); // looter guid
data << uint8(m_lootThreshold); // loot threshold
data << uint8(m_dungeonDifficulty); // Dungeon Difficulty
data << uint8(m_raidDifficulty); // Raid Difficulty
data << uint8(0); // 3.3
}
player->GetSession()->SendPacket(&data);
}
void Group::UpdatePlayerOutOfRange(Player* pPlayer)

View File

@@ -260,6 +260,7 @@ class Group
//void SendInit(WorldSession* session);
void SendTargetIconList(WorldSession* session);
void SendUpdate();
void SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot = NULL);
void UpdatePlayerOutOfRange(Player* pPlayer);
// ignore: GUID of player that will be ignored
void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group=-1, uint64 ignore=0);