Core/Misc: Verify LFG role selections by class
Port From (https://github.com/TrinityCore/TrinityCore/commit/90b4c5afa22715cf2d73f727cbc20c4b667a2769)
This commit is contained in:
@@ -357,13 +357,14 @@ namespace Game.DungeonFinding
|
|||||||
if (!player || player.GetSession() == null || dungeons.Empty())
|
if (!player || player.GetSession() == null || dungeons.Empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Sanitize input roles
|
||||||
|
roles &= LfgRoles.Any;
|
||||||
|
roles = FilterClassRoles(player, roles);
|
||||||
|
|
||||||
// At least 1 role must be selected
|
// At least 1 role must be selected
|
||||||
if ((roles & (LfgRoles.Tank | LfgRoles.Healer | LfgRoles.Damage)) == 0)
|
if ((roles & (LfgRoles.Tank | LfgRoles.Healer | LfgRoles.Damage)) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Sanitize input roles
|
|
||||||
roles &= LfgRoles.Any;
|
|
||||||
|
|
||||||
Group grp = player.GetGroup();
|
Group grp = player.GetGroup();
|
||||||
ObjectGuid guid = player.GetGUID();
|
ObjectGuid guid = player.GetGUID();
|
||||||
ObjectGuid gguid = grp ? grp.GetGUID() : guid;
|
ObjectGuid gguid = grp ? grp.GetGUID() : guid;
|
||||||
@@ -679,6 +680,15 @@ namespace Game.DungeonFinding
|
|||||||
// Sanitize input roles
|
// Sanitize input roles
|
||||||
roles &= LfgRoles.Any;
|
roles &= LfgRoles.Any;
|
||||||
|
|
||||||
|
if (!guid.IsEmpty())
|
||||||
|
{
|
||||||
|
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||||
|
if (player != null)
|
||||||
|
roles = FilterClassRoles(player, roles);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool sendRoleChosen = roleCheck.state != LfgRoleCheckState.Default && !guid.IsEmpty();
|
bool sendRoleChosen = roleCheck.state != LfgRoleCheckState.Default && !guid.IsEmpty();
|
||||||
|
|
||||||
if (guid.IsEmpty())
|
if (guid.IsEmpty())
|
||||||
@@ -1779,6 +1789,19 @@ namespace Game.DungeonFinding
|
|||||||
return PlayersStore[guid].GetTeam();
|
return PlayersStore[guid].GetTeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LfgRoles FilterClassRoles(Player player, LfgRoles roles)
|
||||||
|
{
|
||||||
|
uint allowedRoles = (uint)LfgRoles.Leader;
|
||||||
|
for (uint i = 0; i < PlayerConst.MaxSpecializations; ++i)
|
||||||
|
{
|
||||||
|
var specialization = Global.DB2Mgr.GetChrSpecializationByIndex(player.GetClass(), i);
|
||||||
|
if (specialization != null)
|
||||||
|
allowedRoles |= (1u << (specialization.Role + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return roles & (LfgRoles)allowedRoles;
|
||||||
|
}
|
||||||
|
|
||||||
public byte RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid)
|
public byte RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid)
|
||||||
{
|
{
|
||||||
return GroupsStore[gguid].RemovePlayer(guid);
|
return GroupsStore[gguid].RemovePlayer(guid);
|
||||||
|
|||||||
Reference in New Issue
Block a user