diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index f2792a3926..14f160508f 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -54,8 +54,8 @@ LFGDungeonData::LFGDungeonData(LFGDungeonEntry const* dbc) : id(dbc->ID), name(d LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)), - _isCallToArmsEligible(sWorld->getBoolConfig(CONFIG_LFG_CALL_TO_ARMS_ENABLED)), - _callToArmsRoles(PLAYER_ROLE_TANK | PLAYER_ROLE_HEALER) + _isCallToArmsEnabled(sWorld->getBoolConfig(CONFIG_LFG_CALL_TO_ARMS_ENABLED)), + _callToArmsRoles(PLAYER_ROLE_TANK | PLAYER_ROLE_HEALER | PLAYER_ROLE_DAMAGE) { } @@ -186,10 +186,11 @@ LFGDungeonData const* LFGMgr::GetLFGDungeon(uint32 id) return nullptr; } -bool LFGMgr::IsCallToArmsEligible(uint32 level, uint32 dungeonId) +bool LFGMgr::IsCallToArmsEligible(Player* player, uint32 dungeonId) { if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId)) - return (level == DEFAULT_MAX_LEVEL && dungeon->type == LFG_TYPE_RANDOM && dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC); + return (player->getLevel() == DEFAULT_MAX_LEVEL && !player->GetGroup() + && dungeon->type == LFG_TYPE_RANDOM && dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC); return false; } @@ -390,15 +391,22 @@ void LFGMgr::Update(uint32 diff) for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it) it->second.UpdateQueueTimers(it->first, currTime, tankCount, healerCount, dpsCount); - LFGMgr::RemoveCallToArmsRole(PLAYER_ROLE_HEALER); - LFGMgr::RemoveCallToArmsRole(PLAYER_ROLE_TANK); - LFGMgr::RemoveCallToArmsRole(PLAYER_ROLE_DAMAGE); - if (!tankCount || tankCount < dpsCount) - LFGMgr::AddCallToArmsRole(PLAYER_ROLE_TANK); - if (!healerCount || healerCount < dpsCount) - LFGMgr::AddCallToArmsRole(PLAYER_ROLE_HEALER); - if (dpsCount && (dpsCount < tankCount || dpsCount < healerCount)) + uint32 dpsCountAbsolute = dpsCount ? std::floor(dpsCount / 3) : 0; + + if (!tankCount || dpsCount && tankCount < dpsCountAbsolute || tankCount < healerCount) + AddCallToArmsRole(PLAYER_ROLE_TANK); + else + RemoveCallToArmsRole(PLAYER_ROLE_TANK); + + if (!healerCount || dpsCount && healerCount < dpsCountAbsolute || healerCount < tankCount) + AddCallToArmsRole(PLAYER_ROLE_HEALER); + else + RemoveCallToArmsRole(PLAYER_ROLE_HEALER); + + if (!dpsCountAbsolute || dpsCountAbsolute < tankCount || dpsCountAbsolute < healerCount) AddCallToArmsRole(PLAYER_ROLE_DAMAGE); + else + RemoveCallToArmsRole(PLAYER_ROLE_DAMAGE); } else m_QueueTimer += diff; @@ -545,6 +553,9 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const return; } + if (IsCallToArmsEnabled()) + player->SetTempCallToArmsRoles(GetRolesForCallToArms()); + SetComment(guid, comment); if (isRaid) @@ -1521,7 +1532,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* if (Group *group = player->GetGroup()) tmpRole = group->GetLfgRoles(player->GetGUID()); - if (IsCallToArmsEligible(player->getLevel(), rDungeonId)) + if (IsCallToArmsEligible(player, rDungeonId)) if (player->GetCallToArmsTempRoles() & tmpRole) if (Quest const* callToArmsQuest = sObjectMgr->GetQuestTemplate(LFG_CALL_TO_ARMS_QUEST)) player->RewardQuest(callToArmsQuest, 0, nullptr, false); diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 8ba94d9be8..287b718cd8 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -353,11 +353,11 @@ class TC_GAME_API LFGMgr /// Return Lfg dungeon entry for given dungeon id uint32 GetLFGDungeonEntry(uint32 id); /// Handles Call to Arms bonuses - bool IsCallToArmsEligible(uint32 level, uint32 dungeonId); + bool IsCallToArmsEligible(Player* player, uint32 dungeonId); uint8 GetRolesForCallToArms() { return _callToArmsRoles; } void AddCallToArmsRole(uint8 role) { _callToArmsRoles |= role; } void RemoveCallToArmsRole(uint8 role) { _callToArmsRoles = _callToArmsRoles & ~role; } - void SetCallToArmsEligible(bool val) { _isCallToArmsEligible = val; } + bool IsCallToArmsEnabled() const { return _isCallToArmsEnabled; } // cs_lfg /// Get current player roles @@ -496,7 +496,7 @@ class TC_GAME_API LFGMgr LfgPlayerDataContainer PlayersStore; ///< Player data LfgGroupDataContainer GroupsStore; ///< Group data // Call to Arms System - bool _isCallToArmsEligible; + bool _isCallToArmsEnabled; uint8 _callToArmsRoles; }; diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 20e6e0b746..2380fdb1d7 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -82,9 +82,9 @@ char const* GetCompatibleString(LfgCompatibility compatibles) void LfgQueueData::InitializeGroupSetup() { - tanks = -1; - healers = -1; - dps = -1; + tanks = 0; + healers = 0; + dps = 0; if (!dungeons.empty()) { @@ -622,12 +622,18 @@ void LFGQueue::UpdateQueueTimers(uint8 queueId, time_t currTime, uint32 &tankCou role |= itPlayer->second; role &= ~PLAYER_ROLE_LEADER; - if (role & PLAYER_ROLE_TANK) - tankCount++; - if (role & PLAYER_ROLE_HEALER) - healerCount++; - if (role & PLAYER_ROLE_DAMAGE) - dpsCount++; + if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId)) + { + if (dungeon->minlevel == DEFAULT_MAX_LEVEL && dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC) + { + if (role & PLAYER_ROLE_TANK) + tankCount++; + if (role & PLAYER_ROLE_HEALER) + healerCount++; + if (role & PLAYER_ROLE_DAMAGE) + dpsCount++; + } + } switch (role) { @@ -730,11 +736,12 @@ void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueu std::string sguid = o.str(); for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) - if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && - std::string::npos != itr->first.find(sguid)) + { + if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && std::string::npos != itr->first.find(sguid)) { UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles); } + } } void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles) diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 653173aca2..6f95e22444 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -135,8 +135,6 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) TC_LOG_DEBUG("lfg", "CMSG_LFG_JOIN %s roles: %u, Dungeons: %u, Comment: %s", GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str()); - GetPlayer()->SetTempCallToArmsRoles(sLFGMgr->GetRolesForCallToArms()); - sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } @@ -406,7 +404,7 @@ void WorldSession::SendLfgPlayerLockInfo() data << uint32(0); // completedEncounters - bool isCallToArmsEligible = sLFGMgr->IsCallToArmsEligible(level, dungeonId & 0x00FFFFFF); + bool isCallToArmsEligible = sLFGMgr->IsCallToArmsEnabled() && sLFGMgr->IsCallToArmsEligible(player, dungeonId & 0x00FFFFFF); data << uint8(isCallToArmsEligible); // Call to Arms eligible Quest const* ctaQuest = sObjectMgr->GetQuestTemplate(lfg::LFG_CALL_TO_ARMS_QUEST); @@ -425,9 +423,9 @@ void WorldSession::SendLfgPlayerLockInfo() for (uint8 i = 0; i < 3; i++) { + data << uint32(callToArmsRoleMask); if (callToArmsRoleMask & roleSet[i]) { - data << uint32(callToArmsRoleMask); if (!rewardSent) { BuildQuestReward(data, ctaQuest, player); @@ -440,8 +438,6 @@ void WorldSession::SendLfgPlayerLockInfo() data << uint8(0); } } - else - data << uint32(0); } } else