diff options
author | Spp <spp@jorge.gr> | 2012-10-29 20:13:42 +0100 |
---|---|---|
committer | Spp <spp@jorge.gr> | 2012-10-29 20:13:42 +0100 |
commit | 9074c11a908a84cad0d154c7aea821e0e5bf006e (patch) | |
tree | 3bbdfea18f5e18e44ca7107544cac34f43b734a1 /src/server/game/Handlers/LFGHandler.cpp | |
parent | 14027262eefa9299298a7b6a532781e48ca60651 (diff) |
Core/Dungeon Finder: Update "Current group roles" according to people in queue.
Core/Dungeon Finder: Properly update internal lfg group structure at server load
Diffstat (limited to 'src/server/game/Handlers/LFGHandler.cpp')
-rwxr-xr-x | src/server/game/Handlers/LFGHandler.cpp | 97 |
1 files changed, 66 insertions, 31 deletions
diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 96d21097e71..4d814365dae 100755 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -63,7 +63,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) recv_data >> numDungeons; if (!numDungeons) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); recv_data.rfinish(); return; } @@ -79,7 +79,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) std::string comment; recv_data >> comment; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } @@ -89,7 +89,7 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/) uint64 guid = GetPlayer()->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); // Check cheating - only leader can leave the queue if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID()) @@ -103,7 +103,7 @@ void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recv_data) recv_data >> lfgGroupID; recv_data >> accept; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); } @@ -115,11 +115,11 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recv_data) Group* grp = GetPlayer()->GetGroup(); if (!grp) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); return; } uint64 gguid = grp->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } @@ -128,7 +128,7 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recv_data) std::string comment; recv_data >> comment; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); sLFGMgr->SetComment(guid, comment); } @@ -139,7 +139,7 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recv_data) recv_data >> agree; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); sLFGMgr->UpdateBoot(guid, agree); } @@ -148,14 +148,14 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recv_data) bool out; recv_data >> out; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); // Get Random dungeons that can be done at a certain level and expansion LfgDungeonSet randomDungeons; @@ -176,7 +176,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data uint32 rsize = uint32(randomDungeons.size()); uint32 lsize = uint32(lock.size()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); data << uint8(randomDungeons.size()); // Random Dungeon count @@ -234,7 +234,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); Group* grp = GetPlayer()->GetGroup(); if (!grp) @@ -259,7 +259,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); SendPacket(&data); @@ -269,7 +269,7 @@ void WorldSession::HandleLfrJoinOpcode(WorldPacket& recv_data) { uint32 entry; // Raid id to search recv_data >> entry; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); //SendLfrUpdateListOpcode(entry); } @@ -277,7 +277,7 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recv_data) { uint32 dungeonId; // Raid id queue to leave recv_data >> dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId); } @@ -295,7 +295,9 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) queued = true; extrainfo = true; break; - //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: extrainfo = true; break; @@ -303,7 +305,7 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -340,8 +342,9 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) join = true; queued = true; break; - case LFG_UPDATETYPE_CLEAR_LOCK_LIST: - // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + join = true; queued = true; break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: @@ -352,7 +355,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -376,7 +379,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); data << uint64(guid); // Guid @@ -393,7 +396,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) else dungeons = roleCheck.dungeons; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); data << uint32(roleCheck.state); // Check result @@ -443,7 +446,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result data << uint32(joinData.state); // Check Value @@ -454,7 +457,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4); @@ -478,7 +481,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); data << uint32(rdungeonEntry); // Random Dungeon Finished data << uint32(sdungeonEntry); // Dungeon Finished @@ -519,7 +522,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) ++agreeNum; } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", guid, uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress @@ -541,7 +544,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1)); // show random dungeon if player selected random dungeon and it's not lfg group @@ -585,7 +588,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p void WorldSession::SendLfgLfrList(bool update) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? SendPacket(&data); @@ -593,14 +596,14 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); } void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); SendPacket(&data); @@ -608,12 +611,44 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error SendPacket(&data); } +void WorldSession::HandleLfgGetStatus(WorldPacket& /*recv_data*/) +{ + uint64 guid = GetPlayer()->GetGUID(); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_GET_STATUS [" UI64FMTD "]", guid); + + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); + LfgState state = sLFGMgr->GetLfgStatus(guid, updateData); + + if (state == LFG_STATE_NONE || updateData.dungeons.empty()) + { + SendLfgUpdatePlayer(updateData); + SendLfgUpdateParty(updateData); + return; + } + + if (state != LFG_STATE_QUEUED) + return; + + if (GetPlayer()->GetGroup()) + { + SendLfgUpdateParty(updateData); + updateData.dungeons.clear(); + SendLfgUpdatePlayer(updateData); + } + else + { + SendLfgUpdatePlayer(updateData); + updateData.dungeons.clear(); + SendLfgUpdateParty(updateData); + } +} + /* void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry) { |