fix(Core/LFG): Sort players by role in LFG proposals (#25954)

This commit is contained in:
sogladev
2026-05-28 04:31:56 +02:00
committed by GitHub
parent f8205c8b67
commit ffc5094300
2 changed files with 45 additions and 11 deletions
+21 -7
View File
@@ -1692,18 +1692,32 @@ namespace lfg
LfgGuidList players;
GuidUnorderedSet playersToTeleport;
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
ObjectGuid guid = it->first;
if (guid == proposal.leader)
players.push_front(guid);
else
players.push_back(guid);
// Sort players by role, leader first, then tank, healer and dps
std::vector<ObjectGuid> tanks, healers, dps;
if (proposal.leader && proposal.players.contains(proposal.leader))
players.push_back(proposal.leader);
for (auto const& [guid, player] : proposal.players)
{
if (proposal.isNew || GetGroup(guid) != proposal.group)
playersToTeleport.insert(guid);
if (guid == proposal.leader)
continue;
if (player.role & lfg::PLAYER_ROLE_TANK)
tanks.push_back(guid);
else if (player.role & lfg::PLAYER_ROLE_HEALER)
healers.push_back(guid);
else
dps.push_back(guid);
}
players.insert(players.end(), tanks.begin(), tanks.end());
players.insert(players.end(), healers.begin(), healers.end());
players.insert(players.end(), dps.begin(), dps.end());
// Set the dungeon difficulty
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
ASSERT(dungeon);
+24 -4
View File
@@ -569,12 +569,32 @@ void WorldSession::SendLfgUpdateProposal(lfg::LfgProposal const& proposal)
data << uint8(silent); // Show proposal window
data << uint8(proposal.players.size()); // Group size
for (lfg::LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
// Sort by roles: tank, healer, dps
std::vector<ObjectGuid> ordered;
ordered.reserve(proposal.players.size());
std::vector<ObjectGuid> tanks, healers, dps;
for (auto const& [pguid, player] : proposal.players)
{
lfg::LfgProposalPlayer const& player = it->second;
if (player.role & lfg::PLAYER_ROLE_TANK)
tanks.push_back(pguid);
else if (player.role & lfg::PLAYER_ROLE_HEALER)
healers.push_back(pguid);
else
dps.push_back(pguid);
}
ordered.insert(ordered.end(), tanks.begin(), tanks.end());
ordered.insert(ordered.end(), healers.begin(), healers.end());
ordered.insert(ordered.end(), dps.begin(), dps.end());
for (auto const& pguid : ordered)
{
lfg::LfgProposalPlayer const& player = proposal.players.find(pguid)->second;
data << uint32(player.role); // Role
data << uint8(it->first == guid); // Self player
if (!player.group) // Player not it a group
data << uint8(pguid == guid); // Self player
if (!player.group) // Player not in a group
{
data << uint8(0); // Not in dungeon
data << uint8(0); // Not same group