Skip to content

Commit ffc5094

Browse files
authored
fix(Core/LFG): Sort players by role in LFG proposals (azerothcore#25954)
1 parent f8205c8 commit ffc5094

2 files changed

Lines changed: 45 additions & 11 deletions

File tree

src/server/game/DungeonFinding/LFGMgr.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,18 +1692,32 @@ namespace lfg
16921692
LfgGuidList players;
16931693
GuidUnorderedSet playersToTeleport;
16941694

1695-
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
1696-
{
1697-
ObjectGuid guid = it->first;
1698-
if (guid == proposal.leader)
1699-
players.push_front(guid);
1700-
else
1701-
players.push_back(guid);
1695+
// Sort players by role, leader first, then tank, healer and dps
1696+
std::vector<ObjectGuid> tanks, healers, dps;
1697+
1698+
if (proposal.leader && proposal.players.contains(proposal.leader))
1699+
players.push_back(proposal.leader);
17021700

1701+
for (auto const& [guid, player] : proposal.players)
1702+
{
17031703
if (proposal.isNew || GetGroup(guid) != proposal.group)
17041704
playersToTeleport.insert(guid);
1705+
1706+
if (guid == proposal.leader)
1707+
continue;
1708+
1709+
if (player.role & lfg::PLAYER_ROLE_TANK)
1710+
tanks.push_back(guid);
1711+
else if (player.role & lfg::PLAYER_ROLE_HEALER)
1712+
healers.push_back(guid);
1713+
else
1714+
dps.push_back(guid);
17051715
}
17061716

1717+
players.insert(players.end(), tanks.begin(), tanks.end());
1718+
players.insert(players.end(), healers.begin(), healers.end());
1719+
players.insert(players.end(), dps.begin(), dps.end());
1720+
17071721
// Set the dungeon difficulty
17081722
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
17091723
ASSERT(dungeon);

src/server/game/Handlers/LFGHandler.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,32 @@ void WorldSession::SendLfgUpdateProposal(lfg::LfgProposal const& proposal)
569569
data << uint8(silent); // Show proposal window
570570
data << uint8(proposal.players.size()); // Group size
571571

572-
for (lfg::LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
572+
// Sort by roles: tank, healer, dps
573+
std::vector<ObjectGuid> ordered;
574+
ordered.reserve(proposal.players.size());
575+
576+
std::vector<ObjectGuid> tanks, healers, dps;
577+
578+
for (auto const& [pguid, player] : proposal.players)
579+
{
580+
if (player.role & lfg::PLAYER_ROLE_TANK)
581+
tanks.push_back(pguid);
582+
else if (player.role & lfg::PLAYER_ROLE_HEALER)
583+
healers.push_back(pguid);
584+
else
585+
dps.push_back(pguid);
586+
}
587+
588+
ordered.insert(ordered.end(), tanks.begin(), tanks.end());
589+
ordered.insert(ordered.end(), healers.begin(), healers.end());
590+
ordered.insert(ordered.end(), dps.begin(), dps.end());
591+
592+
for (auto const& pguid : ordered)
573593
{
574-
lfg::LfgProposalPlayer const& player = it->second;
594+
lfg::LfgProposalPlayer const& player = proposal.players.find(pguid)->second;
575595
data << uint32(player.role); // Role
576-
data << uint8(it->first == guid); // Self player
577-
if (!player.group) // Player not it a group
596+
data << uint8(pguid == guid); // Self player
597+
if (!player.group) // Player not in a group
578598
{
579599
data << uint8(0); // Not in dungeon
580600
data << uint8(0); // Not same group

0 commit comments

Comments
 (0)