mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-07 15:28:02 +00:00
fix(Core/LFG): Sort players by role in LFG proposals (#25954)
This commit is contained in:
@@ -1692,18 +1692,32 @@ namespace lfg
|
|||||||
LfgGuidList players;
|
LfgGuidList players;
|
||||||
GuidUnorderedSet playersToTeleport;
|
GuidUnorderedSet playersToTeleport;
|
||||||
|
|
||||||
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
|
// Sort players by role, leader first, then tank, healer and dps
|
||||||
{
|
std::vector<ObjectGuid> tanks, healers, dps;
|
||||||
ObjectGuid guid = it->first;
|
|
||||||
if (guid == proposal.leader)
|
|
||||||
players.push_front(guid);
|
|
||||||
else
|
|
||||||
players.push_back(guid);
|
|
||||||
|
|
||||||
|
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)
|
if (proposal.isNew || GetGroup(guid) != proposal.group)
|
||||||
playersToTeleport.insert(guid);
|
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
|
// Set the dungeon difficulty
|
||||||
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
|
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
|
||||||
ASSERT(dungeon);
|
ASSERT(dungeon);
|
||||||
|
|||||||
@@ -569,12 +569,32 @@ void WorldSession::SendLfgUpdateProposal(lfg::LfgProposal const& proposal)
|
|||||||
data << uint8(silent); // Show proposal window
|
data << uint8(silent); // Show proposal window
|
||||||
data << uint8(proposal.players.size()); // Group size
|
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 << uint32(player.role); // Role
|
||||||
data << uint8(it->first == guid); // Self player
|
data << uint8(pguid == guid); // Self player
|
||||||
if (!player.group) // Player not it a group
|
if (!player.group) // Player not in a group
|
||||||
{
|
{
|
||||||
data << uint8(0); // Not in dungeon
|
data << uint8(0); // Not in dungeon
|
||||||
data << uint8(0); // Not same group
|
data << uint8(0); // Not same group
|
||||||
|
|||||||
Reference in New Issue
Block a user