diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/DungeonFinding/LFGMgr.cpp | 396 | ||||
-rwxr-xr-x | src/server/game/DungeonFinding/LFGMgr.h | 7 | ||||
-rwxr-xr-x | src/server/game/Server/Protocol/Handlers/LFGHandler.cpp | 110 | ||||
-rwxr-xr-x | src/server/game/Server/WorldSession.h | 6 |
4 files changed, 238 insertions, 281 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 7d31608b1a9..c488e864312 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -367,9 +367,9 @@ void LFGMgr::Update(uint32 diff) if (Player* plr = sObjectMgr.GetPlayerByLowGUID(itPlayers->first)) { if (plr->GetGroup()) - plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_PROPOSAL_BEGIN); + plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_PROPOSAL_BEGIN, plr->GetLfgDungeons(), plr->GetLfgComment()); else - plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_PROPOSAL_BEGIN); + plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_PROPOSAL_BEGIN, plr->GetLfgDungeons(), plr->GetLfgComment()); plr->GetSession()->SendUpdateProposal(m_lfgProposalId, pProposal); } } @@ -492,200 +492,239 @@ bool LFGMgr::RemoveFromQueue(uint64 guid) return ret; } -/// <summary> /// Adds the player/group to lfg queue -/// </summary> -/// <param name="Player*">Player</param> -void LFGMgr::Join(Player* plr) +void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment) { - LfgDungeonSet* dungeons = NULL; - Group* grp = plr->GetGroup(); + if (!plr || !plr->GetSession() || !dungeons || !dungeons->size()) + return; - if (grp && grp->GetLeaderGUID() != plr->GetGUID()) - return; + Group* grp = plr->GetGroup(); + uint64 guid = plr->GetGUID(); + uint64 gguid = grp ? grp->GetGUID() : guid; + LfgJoinResult result = LFG_JOIN_OK; + PlayerSet players; + uint32 rDungeonId = 0; + bool isContinue = grp && grp->isLFGGroup() && !grp->isLfgDungeonComplete(); - uint64 guid = grp ? grp->GetGUID() : plr->GetGUID(); + // Do not allow to change dungeon in the middle of a current dungeon + if (isContinue) + { + dungeons->clear(); + dungeons->insert(grp->GetLfgDungeonEntry()); + } - LfgJoinResult result = LFG_JOIN_OK; - bool isDungeon = false; - bool isRaid = false; - LfgLockStatusMap* playersLockMap = NULL; - // Previous checks before joining - LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid); + // Already in queue? + LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(gguid); if (itQueue != m_QueueInfoMap.end()) { - time_t now = time_t(time(NULL)); - time_t joinTime = itQueue->second->joinTime; - uint32 diff = uint32(now - joinTime); - sLog.outError("LFGMgr::Join: [" UI64FMTD "] trying to join but is already in queue! diff %u (" UI64FMTD " - " UI64FMTD ")", guid, diff, uint64(now), uint64(joinTime)); - Leave(plr, grp); - result = LFG_JOIN_INTERNAL_ERROR; + bool sameDungeons = true; + for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end() && sameDungeons; ++it) + if (dungeons->find(*it) == dungeons->end()) + sameDungeons = false; + + if (sameDungeons) // Joining the same dungeons -- Send OK + { + plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK); + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + if (itr->getSource() && itr->getSource()->GetSession()) + itr->getSource()->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment); + dungeons->clear(); + delete dungeons; + return; + } + else if (!isContinue) // Different dungeons and it's not an offer to continue + { + // Different dungeons and it's not a LfgGroup in the middle of a dungeon that need more people + Leave(plr, grp); + Join(plr, roles, dungeons, comment); + return; + } } - else if (plr->InBattleground() || plr->InArena() || plr->InBattlegroundQueue()) + + // Check player or group member restrictions + if (plr->InBattleground() || plr->InArena() || plr->InBattlegroundQueue()) result = LFG_JOIN_USING_BG_SYSTEM; else if (plr->HasAura(LFG_SPELL_DUNGEON_DESERTER)) result = LFG_JOIN_DESERTER; else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) result = LFG_JOIN_RANDOM_COOLDOWN; - else + else if (!dungeons || !dungeons->size()) + result = LFG_JOIN_NOT_MEET_REQS; + else if (grp) { - dungeons = plr->GetLfgDungeons(); - if (!dungeons || !dungeons->size()) - result = LFG_JOIN_NOT_MEET_REQS; - else // Check if all dungeons are valid + if (grp->GetMembersCount() > MAXGROUPSIZE) + result = LFG_JOIN_TOO_MUCH_MEMBERS; + else { - LfgType type = LFG_TYPE_NONE; - for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end() && result == LFG_JOIN_OK; ++it) + Player* plrg; + uint8 memberCount = 0; + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next()) { - type = GetDungeonType(*it); - switch(type) + plrg = itr->getSource(); + if (plrg) { - case LFG_TYPE_RANDOM: - case LFG_TYPE_DUNGEON: - case LFG_TYPE_HEROIC: - if (isRaid) - result = LFG_JOIN_MIXED_RAID_DUNGEON; - isDungeon = true; - break; - case LFG_TYPE_RAID: - if (isDungeon) - result = LFG_JOIN_MIXED_RAID_DUNGEON; - isRaid = true; - break; - default: - result = LFG_JOIN_DUNGEON_INVALID; - break; + if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER)) + result = LFG_JOIN_PARTY_DESERTER; + else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) + result = LFG_JOIN_PARTY_RANDOM_COOLDOWN; + else if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue()) + result = LFG_JOIN_USING_BG_SYSTEM; + ++memberCount; + players.insert(plrg); } } + if (memberCount != grp->GetMembersCount()) + result = LFG_JOIN_DISCONNECTED; } - dungeons = NULL; } + else + players.insert(plr); + // Check if all dungeons are valid + bool isRaid = false; if (result == LFG_JOIN_OK) { - if (grp) + bool isDungeon = false; + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end() && result == LFG_JOIN_OK; ++it) { - if (grp->GetMembersCount() > MAXGROUPSIZE) - result = LFG_JOIN_TOO_MUCH_MEMBERS; - else + switch(GetDungeonType(*it)) { - Player* plrg; - uint8 memberCount = 0; - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next()) - { - plrg = itr->getSource(); - if (plrg) - { - if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER)) - result = LFG_JOIN_PARTY_DESERTER; - else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) - result = LFG_JOIN_PARTY_RANDOM_COOLDOWN; - else if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue()) - result = LFG_JOIN_USING_BG_SYSTEM; - ++memberCount; - } - } - if (memberCount != grp->GetMembersCount()) - result = LFG_JOIN_DISCONNECTED; + case LFG_TYPE_RANDOM: + if (dungeons->size() > 1) // Only allow 1 random dungeon + result = LFG_JOIN_DUNGEON_INVALID; + else + rDungeonId = (*dungeons->begin()); + // No break on purpose (Random can only be dungeon or heroic dungeon) + case LFG_TYPE_HEROIC: + case LFG_TYPE_DUNGEON: + if (isRaid) + result = LFG_JOIN_MIXED_RAID_DUNGEON; + isDungeon = true; + break; + case LFG_TYPE_RAID: + if (isDungeon) + result = LFG_JOIN_MIXED_RAID_DUNGEON; + isRaid = true; + break; + default: + result = LFG_JOIN_DUNGEON_INVALID; + break; } } - else + + // Expand random dungeons and check restrictions + if (rDungeonId) { - // Expand random dungeons and check restrictions - PlayerSet players; - players.insert(plr); - if (plr->GetLfgDungeons()->size() == 1 && isRandomDungeon(*plr->GetLfgDungeons()->begin())) - dungeons = GetDungeonsByRandom(*plr->GetLfgDungeons()->begin()); - else - { - dungeons = new LfgDungeonSet(); - for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end(); ++it) - dungeons->insert(*it); - } - playersLockMap = CheckCompatibleDungeons(dungeons, &players); - if (!dungeons || !dungeons->size()) - result = LFG_JOIN_NOT_MEET_REQS; + dungeons->clear(); + delete dungeons; + dungeons = GetDungeonsByRandom(rDungeonId); } + CheckCompatibleDungeons(dungeons, &players, false); + if (!dungeons || !dungeons->size()) + result = LFG_JOIN_NOT_MEET_REQS; } - if (result != LFG_JOIN_OK) // Someone can't join. Clear all stuf + // Can't join. Send result + if (result != LFG_JOIN_OK) { sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result); + plr->GetSession()->SendLfgJoinResult(result); + if (dungeons) + dungeons->clear(); + delete dungeons; + dungeons = NULL; + return; + } + + // FIXME - Raid browser not supported yet + if (isRaid) + { + sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] trying to join raid browser and it's disabled.", guid); + dungeons->clear(); + delete dungeons; + dungeons = NULL; + return; + } + + // All ok, Update player info + if (!isContinue) + { plr->GetLfgDungeons()->clear(); - plr->SetLfgRoles(ROLE_NONE); - if (grp && !grp->isLFGGroup()) - plr->SetLfgState(LFG_STATE_NONE); - plr->GetSession()->SendLfgJoinResult(result, 0, playersLockMap); - if (playersLockMap) + if (rDungeonId) + plr->GetLfgDungeons()->insert(rDungeonId); + else + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + plr->GetLfgDungeons()->insert(*it); + } + + plr->SetLfgComment(comment); + plr->SetLfgRoles(roles); + + if (grp) // Begin rolecheck + { + LfgRoleCheck* pRoleCheck = new LfgRoleCheck(); + pRoleCheck->cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; + pRoleCheck->result = LFG_ROLECHECK_INITIALITING; + pRoleCheck->leader = plr->GetGUIDLow(); + m_RoleChecks[grp->GetLowGUID()] = pRoleCheck; + + if (isContinue) { - for(LfgLockStatusMap::iterator it = playersLockMap->begin(); it != playersLockMap->end(); ++it) - { - it->second->clear(); - delete it->second; - } - playersLockMap->clear(); - delete playersLockMap; + dungeons->clear(); + dungeons->insert(grp->GetLfgDungeonEntry()); } - if (dungeons) + else if (rDungeonId) { dungeons->clear(); - delete dungeons; + dungeons->insert(rDungeonId); } - return; - } + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + pRoleCheck->dungeons.insert(*it); - if (!isRaid) // At the moment do not allow to join Raid Browser - { - if (grp) + Player* plrg; + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* plrg = NULL; - for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next()) + plrg = itr->getSource(); + if (!plrg) + continue; + + plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment); + plrg->SetLfgState(LFG_STATE_LFG); + if (!isContinue) { - plrg = itr->getSource(); // Not null, checked earlier - plrg->SetLfgState(LFG_STATE_LFG); - if (plrg != plr) - { - dungeons = plrg->GetLfgDungeons(); - dungeons->clear(); - for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon) - dungeons->insert(*itDungeon); - } - plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL); + plrg->GetLfgDungeons()->clear(); + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + plrg->GetLfgDungeons()->insert(*it); } - UpdateRoleCheck(grp, plr); - std::string dungeonsstr = ConcatenateDungeons(dungeons); - sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str()); - dungeons = NULL; - } - else - { - plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK, 0); - plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL); - plr->SetLfgState(LFG_STATE_LFG); - LfgQueueInfo* pqInfo = new LfgQueueInfo(); - pqInfo->joinTime = time_t(time(NULL)); - pqInfo->roles[plr->GetGUIDLow()] = plr->GetLfgRoles(); - uint8 roles = plr->GetLfgRoles(); - if (roles & ROLE_TANK) - --pqInfo->tanks; - else if (roles & ROLE_HEALER) - --pqInfo->healers; - else - --pqInfo->dps; - for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) - pqInfo->dungeons.insert(*it); - m_QueueInfoMap[guid] = pqInfo; - AddGuidToNewQueue(guid); - std::string dungeonsstr = ConcatenateDungeons(dungeons); - sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str()); + pRoleCheck->roles[plrg->GetGUIDLow()] = 0; } + UpdateRoleCheck(grp, plr, true); } - - if (dungeons) + else // Add player to queue { - dungeons->clear(); - delete dungeons; - } + plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK); + plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment); + plr->SetLfgState(LFG_STATE_LFG); + LfgQueueInfo* pqInfo = new LfgQueueInfo(); + pqInfo->joinTime = time_t(time(NULL)); + pqInfo->roles[plr->GetGUIDLow()] = plr->GetLfgRoles(); + uint8 roles = plr->GetLfgRoles(); + if (roles & ROLE_TANK) + --pqInfo->tanks; + else if (roles & ROLE_HEALER) + --pqInfo->healers; + else + --pqInfo->dps; + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + pqInfo->dungeons.insert(*it); + m_QueueInfoMap[guid] = pqInfo; + AddGuidToNewQueue(guid); + } + std::string dungeonsstr = ConcatenateDungeons(dungeons); + sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %s", guid, grp ? grp->GetMembersCount() : 1, dungeonsstr.c_str()); + dungeons->clear(); + delete dungeons; + dungeons = NULL; } /// <summary> @@ -1073,46 +1112,19 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal) return true; } -/// <summary> /// Update the Role check info with the player selected role. -/// </summary> -/// <param name="Group*">Group</param> -/// <param name="Player*">Player (optional, default NULL)</param> -void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/) +void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCheck /* = false */) { if (!grp) return; - uint32 rolecheckId = grp->GetLowGUID(); LfgRoleCheck* pRoleCheck = NULL; LfgRolesMap check_roles; - LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(rolecheckId); - bool newRoleCheck = itRoleCheck == m_RoleChecks.end(); - if (newRoleCheck) - { - if (!plr || grp->GetLeaderGUID() != plr->GetGUID()) - return; - - LfgDungeonSet* dungeons = plr->GetLfgDungeons(); - pRoleCheck = new LfgRoleCheck(); - pRoleCheck->cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; - pRoleCheck->result = LFG_ROLECHECK_INITIALITING; - pRoleCheck->leader = plr->GetGUIDLow(); - - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) - if (Player* plrg = itr->getSource()) - pRoleCheck->roles[plrg->GetGUIDLow()] = 0; - - // Check if it's offer continue or trying to find a new instance after a random assigned (Join Random + LfgGroup) - if (grp->isLFGGroup() && dungeons->size() == 1 && isRandomDungeon(*dungeons->begin()) && grp->GetLfgDungeonEntry()) - pRoleCheck->dungeons.insert(grp->GetLfgDungeonEntry()); - else - for (LfgDungeonSet::const_iterator itDungeon = dungeons->begin(); itDungeon != dungeons->end(); ++itDungeon) - pRoleCheck->dungeons.insert(*itDungeon); - } - else - pRoleCheck = itRoleCheck->second; + LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(grp->GetLowGUID()); + if (itRoleCheck == m_RoleChecks.end()) + return; + pRoleCheck = itRoleCheck->second; LfgLockStatusMap* playersLockMap = NULL; if (plr) { @@ -1201,7 +1213,7 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/) continue; case LFG_ROLECHECK_FINISHED: if (!playersLockMap) - session->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE); + session->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &pRoleCheck->dungeons, plrg->GetLfgComment()); else { if (grp->GetLeaderGUID() == plrg->GetGUID()) @@ -1254,11 +1266,8 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/) pRoleCheck->dungeons.clear(); pRoleCheck->roles.clear(); delete pRoleCheck; - if (!newRoleCheck) - m_RoleChecks.erase(itRoleCheck); + m_RoleChecks.erase(itRoleCheck); } - else if (newRoleCheck) - m_RoleChecks[rolecheckId] = pRoleCheck; } /// <summary> @@ -1688,9 +1697,9 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } if (plr->GetGroup()) - plr->GetSession()->SendLfgUpdateParty(updateType); + plr->GetSession()->SendLfgUpdateParty(updateType, plr->GetLfgDungeons(), plr->GetLfgComment()); else - plr->GetSession()->SendLfgUpdatePlayer(updateType); + plr->GetSession()->SendLfgUpdatePlayer(updateType, plr->GetLfgDungeons(), plr->GetLfgComment()); } @@ -2242,17 +2251,6 @@ bool LFGMgr::isRandomDungeon(uint32 dungeonId) } /// <summary> -/// Given a guid returns if it recently joined queue -/// </summary> -/// <param name="uint64&">guid</param> -/// <returns>bool</returns> -bool LFGMgr::isJoining(uint64 guid) -{ - LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid); - return itQueue != m_QueueInfoMap.end() && itQueue->second->joinTime + LFG_TIME_JOIN_WARNING > time_t(time(NULL)); -} - -/// <summary> /// Given a Achievement id returns the related dungeon id /// </summary> /// <param name="uint32">Achievement id</param> diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index b62d56cc85a..02b0694146a 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -30,7 +30,6 @@ enum LFGenum LFG_TIME_ROLECHECK = 2*MINUTE, LFG_TIME_BOOT = 2*MINUTE, LFG_TIME_PROPOSAL = 2*MINUTE, - LFG_TIME_JOIN_WARNING = 1*IN_MILLISECONDS, LFG_TANKS_NEEDED = 1, LFG_HEALERS_NEEDED = 1, LFG_DPS_NEEDED = 3, @@ -248,13 +247,13 @@ class LFGMgr LFGMgr(); ~LFGMgr(); - void Join(Player* plr); + void Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment); void Leave(Player* plr, Group* grp = NULL); void OfferContinue(Group* grp); void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false); void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept); void UpdateBoot(Player* plr, bool accept); - void UpdateRoleCheck(Group* grp, Player* plr = NULL); + void UpdateRoleCheck(Group* grp, Player* plr = NULL, bool newRoleCheck = false); void Update(uint32 diff); bool isRandomDungeon(uint32 dungeonId); @@ -270,8 +269,6 @@ class LFGMgr LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL, bool useEntry = true); LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level); - bool isJoining(uint64 guid); - private: void Cleaner(); void AddGuidToNewQueue(uint64 guid); diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp index 95e083cd7dd..27fd75a3405 100755 --- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp @@ -59,17 +59,10 @@ void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap) void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data) { - if (!sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE)) + if (!sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE) || + (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID())) { recv_data.rpos(recv_data.wpos()); - sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] Dungeon finder disabled", GetPlayer()->GetGUID()); - return; - } - - if (sLFGMgr.isJoining(GetPlayer()->GetGUID())) - { - recv_data.rpos(recv_data.wpos()); - sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] already Joining. Ignoring", GetPlayer()->GetGUID()); return; } @@ -77,11 +70,10 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data) uint32 dungeon; uint32 roles; std::string comment; - LfgDungeonSet newDungeons; + LfgDungeonSet* newDungeons; recv_data >> roles; - recv_data.read_skip<uint8>(); // unk - always 0 - recv_data.read_skip<uint8>(); // unk - always 0 + recv_data.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0) recv_data >> numDungeons; if (!numDungeons) { @@ -90,34 +82,18 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data) return; } + newDungeons = new LfgDungeonSet(); for (int8 i = 0 ; i < numDungeons; ++i) { recv_data >> dungeon; - newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry + newDungeons->insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry } - recv_data >> numDungeons; // unk - always 3 - for (int8 i = 0 ; i < numDungeons; ++i) - recv_data.read_skip<uint8>(); // unk - always 0 + recv_data.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) } recv_data >> comment; - - LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons(); - Group* grp = GetPlayer()->GetGroup(); - bool isRandomDungeon = dungeons->size() == 1 && sLFGMgr.isRandomDungeon(*dungeons->begin()); - bool isCurrentDungeon = newDungeons.size() == 1 && grp && grp->isLFGGroup() && grp->GetLfgDungeonEntry() == (*newDungeons.begin()); - - if (!isRandomDungeon || !isCurrentDungeon) // is not offer to continue - clear old dungeons and use new dungeons - { - dungeons->clear(); - for (LfgDungeonSet::const_iterator it = newDungeons.begin(); it != newDungeons.end(); ++it) - dungeons->insert(*it); - } - GetPlayer()->SetLfgRoles(uint8(roles)); - GetPlayer()->SetLfgComment(comment); - sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] as group: %u - Dungeons: %u", GetPlayer()->GetGUID(), grp ? 1 : 0, uint8(newDungeons.size())); - newDungeons.clear(); - sLFGMgr.Join(GetPlayer()); + sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons->size()), comment.c_str()); + sLFGMgr.Join(GetPlayer(), uint8(roles), newDungeons, comment); } void WorldSession::HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/) @@ -300,14 +276,8 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket &recv_data) //sLFGMgr.LeaveLfr(GetPlayer(), dungeonId); } -void WorldSession::SendLfgUpdatePlayer(uint8 updateType) +void WorldSession::SendLfgUpdatePlayer(uint8 updateType, LfgDungeonSet* dungeons /* = NULL */, std::string comment /* = "" */) { - if (!GetPlayer()->GetLfgUpdate()) - { - sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u not sent! player flag: false", GetPlayer()->GetGUID(), updateType); - return; - } - bool queued = false; bool extrainfo = false; @@ -323,37 +293,31 @@ void WorldSession::SendLfgUpdatePlayer(uint8 updateType) extrainfo = true; break; } - LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons(); - uint8 size = dungeons->size(); - std::string comment = GetPlayer()->GetLfgComment(); - sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", GetPlayer()->GetGUID(), updateType); + uint64 guid = GetPlayer()->GetGUID(); + uint8 size = dungeons ? dungeons->size() : 0; + + sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateType); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + comment.length())); - data << uint8(updateType); // Lfg Update type - data << uint8(extrainfo); // Extra info + data << uint8(updateType); // Lfg Update type + data << uint8(extrainfo); // Extra info if (extrainfo) { - data << uint8(queued); // Join the queue - data << uint8(0); // unk - Always 0 - data << uint8(0); // unk - Always 0 + data << uint8(queued); // Join the queue + data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 data << uint8(size); - - for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) - data << uint32(*it); + if (size) + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + data << uint32(*it); data << comment; } SendPacket(&data); } -void WorldSession::SendLfgUpdateParty(uint8 updateType) +void WorldSession::SendLfgUpdateParty(uint8 updateType, LfgDungeonSet* dungeons /* = NULL */, std::string comment /* = "" */) { - if (!GetPlayer()->GetLfgUpdate()) - { - sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u not sent! player flag: false", GetPlayer()->GetGUID(), updateType); - return; - } - bool join = false; bool extrainfo = false; bool queued = false; @@ -378,28 +342,26 @@ void WorldSession::SendLfgUpdateParty(uint8 updateType) break; } - LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons(); - uint8 size = dungeons->size(); - std::string comment = GetPlayer()->GetLfgComment(); + uint64 guid = GetPlayer()->GetGUID(); + uint8 size = dungeons ? dungeons->size() : 0; - sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", GetPlayer()->GetGUID(), updateType); + sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateType); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + comment.length())); - data << uint8(updateType); // Lfg Update type - data << uint8(extrainfo); // Extra info + data << uint8(updateType); // Lfg Update type + data << uint8(extrainfo); // Extra info if (extrainfo) { - data << uint8(join); // LFG Join - data << uint8(queued); // Join the queue - data << uint8(0); // unk - Always 0 - data << uint8(0); // unk - Always 0 + data << uint8(join); // LFG Join + data << uint8(queued); // Join the queue + data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 for (uint8 i = 0; i < 3; ++i) - data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 data << uint8(size); - - for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) - data << uint32(*it); - + if (size) + for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it) + data << uint32(*it); data << comment; } SendPacket(&data); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 036ecb73f5b..9c853ef9b2f 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -730,12 +730,12 @@ class WorldSession void HandleLfrSearchOpcode(WorldPacket &recv_data); void HandleLfrLeaveOpcode(WorldPacket &recv_data); - void SendLfgUpdatePlayer(uint8 updateType); - void SendLfgUpdateParty(uint8 updateType); + void SendLfgUpdatePlayer(uint8 updateType, std::set<uint32>* dungeons = NULL, std::string comment = ""); + void SendLfgUpdateParty(uint8 updateType, std::set<uint32>* dungeons = NULL, std::string comment = ""); void SendLfgRoleChosen(uint64 guid, uint8 roles); void SendLfgRoleCheckUpdate(LfgRoleCheck *pRoleCheck); void SendLfgUpdateSearch(bool update); - void SendLfgJoinResult(uint8 checkResult, uint8 checkValue = 0, std::map<uint32, std::set<LfgLockStatus*>*> *playersLockMap = NULL /* LfgLockStatusMap *playersLockMap = NULL */); + void SendLfgJoinResult(uint8 checkResult, uint8 checkValue = 0, std::map<uint32, std::set<LfgLockStatus*>*> *playersLockMap = NULL); void SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgWaitTime, int32 waitTimeTanks, int32 waitTimeHealer, int32 waitTimeDps, uint32 queuedTime, uint8 tanks, uint8 healers, uint8 dps); void SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward *reward, const Quest *qRew); void SendLfgBootPlayer(LfgPlayerBoot *pBoot); |