aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorihm-tswow <76849026+ihm-tswow@users.noreply.github.com>2021-12-21 18:15:11 +0000
committerShauren <shauren.trinity@gmail.com>2022-03-24 21:03:06 +0100
commit90b4c5afa22715cf2d73f727cbc20c4b667a2769 (patch)
treec48e3e9fc3dada10fa0a507491d50f4b6564c8b8 /src
parent56dd1243fd35e26f1f1046afb1c057b8a4a249f7 (diff)
Core/Misc: Verify LFG role selections by class (#27348)
* Core/Misc: Verify LFG role selections by class * style fix Co-authored-by: MaxtorCoder <warsongkiller.s8@gmail.com> * fix style * improve LfgRoleClasses readability * remove unnecessary comments * add missing SharedDefine include - try fix nopch * style fix Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: MaxtorCoder <warsongkiller.s8@gmail.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Shauren <shauren.trinity@gmail.com> (cherry picked from commit 5e2b2fd3f8bd8e1c1d3b4f3b833b9af6890d55dc)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp25
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.h1
2 files changed, 23 insertions, 3 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 7a5242f2612..936eaae171d 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -396,13 +396,14 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons)
if (!player || !player->GetSession() || dungeons.empty())
return;
+ // Sanitize input roles
+ roles &= PLAYER_ROLE_ANY;
+ roles = FilterClassRoles(player, roles);
+
// At least 1 role must be selected
if (!(roles & (PLAYER_ROLE_TANK | PLAYER_ROLE_HEALER | PLAYER_ROLE_DAMAGE)))
return;
- // Sanitize input roles
- roles &= PLAYER_ROLE_ANY;
-
Group* grp = player->GetGroup();
ObjectGuid guid = player->GetGUID();
ObjectGuid gguid = grp ? grp->GetGUID() : guid;
@@ -725,6 +726,14 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid::
// Sanitize input roles
roles &= PLAYER_ROLE_ANY;
+ if (!guid.IsEmpty())
+ {
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ roles = FilterClassRoles(player, roles);
+ else
+ return;
+ }
+
LfgRoleCheck& roleCheck = itRoleCheck->second;
bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && !guid.IsEmpty();
@@ -1895,6 +1904,16 @@ uint8 LFGMgr::GetTeam(ObjectGuid guid)
return team;
}
+uint8 LFGMgr::FilterClassRoles(Player* player, uint8 roles)
+{
+ uint8 allowedRoles = PLAYER_ROLE_LEADER;
+ for (uint32 i = 0; i < MAX_SPECIALIZATIONS; ++i)
+ if (ChrSpecializationEntry const* specialization = sDB2Manager.GetChrSpecializationByIndex(player->GetClass(), i))
+ allowedRoles |= 1 << (specialization->Role + 1);
+
+ return roles & allowedRoles;
+}
+
uint8 LFGMgr::RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid)
{
return GroupsStore[gguid].RemovePlayer(guid);
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index e9fd1a2299a..2e54163e8e7 100644
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -446,6 +446,7 @@ class TC_GAME_API LFGMgr
private:
uint8 GetTeam(ObjectGuid guid);
+ uint8 FilterClassRoles(Player* player, uint8 roles);
void RestoreState(ObjectGuid guid, char const* debugMsg);
void ClearState(ObjectGuid guid, char const* debugMsg);
void SetDungeon(ObjectGuid guid, uint32 dungeon);