void WorldSession::SendLfgBootPlayer() { if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE)) { DEBUG_LOG("SendLfgBootPlayer %u failed - Dungeon finder disabled", GetPlayer()->GetObjectGuid().GetCounter()); return; } Group* pGroup = GetPlayer()->GetGroup(); if (!pGroup) { sLog.outError("ERROR:SendLfgBootPlayer %u failed - player not in group!", GetPlayer()->GetObjectGuid().GetCounter()); return; } ObjectGuid guid = GetPlayer()->GetObjectGuid(); LFGAnswerMap* votes = pGroup->GetLFGGroupState()->GetBootMap(); if (votes->empty()) { sLog.outError("ERROR:SendLfgBootPlayer %u failed - votes map is empty!", GetPlayer()->GetObjectGuid().GetCounter()); return; } LFGAnswer playerVote = votes->find(guid)->second; uint8 votesNum = 0; uint8 agreeNum = 0; uint32 secsleft = uint8(pGroup->GetLFGGroupState()->GetBootCancelTime() - time(NULL)); bool isBootContinued = (pGroup->GetLFGGroupState()->GetBootResult() == LFG_ANSWER_PENDING); for (LFGAnswerMap::const_iterator itr = votes->begin(); itr != votes->end(); ++itr) { if (itr->second != LFG_ANSWER_PENDING) { ++votesNum; if (itr->second == LFG_ANSWER_AGREE) ++agreeNum; } } DEBUG_LOG("SMSG_LFG_BOOT_PLAYER %u didVote: %u - agree: %u - victim: %u votes: %u - agrees: %u - left: %u - needed: %u - reason %s", GetPlayer()->GetObjectGuid().GetCounter(), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), pGroup->GetLFGGroupState()->GetBootVictim().GetCounter(), votesNum, agreeNum, secsleft, pGroup->GetLFGGroupState()->GetVotesNeeded(), pGroup->GetLFGGroupState()->GetBootReason().c_str()); WorldPacket data(SMSG_LFG_BOOT_PLAYER, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + pGroup->GetLFGGroupState()->GetBootReason().length()+1); data << uint8(isBootContinued); // Vote in progress data << uint8(playerVote != LFG_ANSWER_PENDING); // Did Vote data << uint8(playerVote == LFG_ANSWER_AGREE); // Agree data << pGroup->GetLFGGroupState()->GetBootVictim(); // Victim GUID data << uint32(votesNum); // Total Votes data << uint32(agreeNum); // Agree Count data << uint32(secsleft); // Time Left data << uint32(pGroup->GetLFGGroupState()->GetVotesNeeded()); // Needed Votes data << pGroup->GetLFGGroupState()->GetBootReason().c_str(); // Kick reason SendPacket(&data); }
void WorldSession::SendLfgRoleCheckUpdate() { if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE)) { DEBUG_LOG("SendLfgRoleCheckUpdate %u failed - Dungeon finder disabled", GetPlayer()->GetObjectGuid().GetCounter()); return; } Group* pGroup = GetPlayer()->GetGroup(); if (!pGroup) return; LFGDungeonSet const* dungeons = pGroup->GetLFGGroupState()->GetDungeons(); if (!dungeons) return; DEBUG_LOG("SMSG_LFG_ROLE_CHECK_UPDATE %u, dugeons size " SIZEFMTD, GetPlayer()->GetObjectGuid().GetCounter(), dungeons->size()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons->size() * 4 + 1 + pGroup->GetMembersCount() * (8 + 1 + 4 + 1)); data << uint32(pGroup->GetLFGGroupState()->GetRoleCheckState()); // Check result data << uint8(pGroup->GetLFGGroupState()->GetRoleCheckState() == LFG_ROLECHECK_INITIALITING); data << uint8(dungeons->size()); // Number of dungeons if (dungeons->size()) { for (LFGDungeonSet::const_iterator itr = dungeons->begin(); itr != dungeons->end(); ++itr) { data << uint32(*itr ? (*itr)->Entry() : 0); // Dungeon Entry } } data << uint8(pGroup->GetMembersCount()); // Players in group if (pGroup->GetMembersCount()) { // Leader info MUST be sent 1st :S ObjectGuid leaderguid = pGroup->GetLeaderGuid(); Player* pLeader = sObjectMgr.GetPlayer(leaderguid); LFGRoleMask roles = LFG_ROLE_MASK_NONE; uint8 leaderLevel = 1; if (pLeader) { roles = pLeader->GetLFGPlayerState()->GetRoles(); leaderLevel = pLeader->getLevel(); } data << leaderguid; // Guid data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready data << uint32(roles); // Roles data << uint8(leaderLevel); // Level for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* pGroupMember = itr->getSource()) { ObjectGuid guid = pGroupMember->GetObjectGuid(); // Leader data handle first if (guid == leaderguid) continue; roles = pGroupMember->GetLFGPlayerState()->GetRoles(); data << guid; // Guid data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready data << uint32(roles); // Roles data << uint8(pGroupMember->getLevel()); // Level } } } SendPacket(&data); }