aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorihm-tswow <76849026+ihm-tswow@users.noreply.github.com>2021-12-21 18:15:11 +0000
committerGitHub <noreply@github.com>2021-12-21 19:15:11 +0100
commit5e2b2fd3f8bd8e1c1d3b4f3b833b9af6890d55dc (patch)
tree056b173d5146eb34a11b8b25a956e6e5f7b45b71
parent84909c749d5fcf4d9411e38cc29f261f14255e4e (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>
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp25
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.h14
2 files changed, 36 insertions, 3 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 38cb9ae38f2..aed1ec744da 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -399,13 +399,14 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
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;
@@ -710,6 +711,14 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid::
// Sanitize input roles
roles &= PLAYER_ROLE_ANY;
+ if (guid)
+ {
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ roles = FilterClassRoles(player, roles);
+ else
+ return;
+ }
+
LfgRoleCheck& roleCheck = itRoleCheck->second;
bool sendRoleChosen = roleCheck.state != LFG_ROLECHECK_DEFAULT && guid;
@@ -1859,6 +1868,16 @@ uint8 LFGMgr::GetTeam(ObjectGuid guid)
return team;
}
+uint8 LFGMgr::FilterClassRoles(Player* player, uint8 roles)
+{
+ roles &= PLAYER_ROLE_ANY;
+ if (!(LfgRoleClasses::TANK & player->GetClassMask()))
+ roles &= ~PLAYER_ROLE_TANK;
+ if (!(LfgRoleClasses::HEALER & player->GetClassMask()))
+ roles &= ~PLAYER_ROLE_HEALER;
+ return roles;
+}
+
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 63011752b61..3d9109677c0 100644
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -24,6 +24,7 @@
#include "LFGQueue.h"
#include "LFGGroupData.h"
#include "LFGPlayerData.h"
+#include "SharedDefines.h"
#include <unordered_map>
class Group;
@@ -128,6 +129,18 @@ enum LfgRoleCheckState
LFG_ROLECHECK_NO_ROLE = 6 // Someone selected no role
};
+enum LfgRoleClasses {
+ TANK = (1 << (CLASS_WARRIOR - 1)) |
+ (1 << (CLASS_PALADIN - 1)) |
+ (1 << (CLASS_DEATH_KNIGHT - 1)) |
+ (1 << (CLASS_DRUID - 1)),
+
+ HEALER = (1 << (CLASS_PALADIN - 1)) |
+ (1 << (CLASS_PRIEST - 1)) |
+ (1 << (CLASS_SHAMAN - 1)) |
+ (1 << (CLASS_DRUID - 1)),
+};
+
// Forward declaration (just to have all typedef together)
struct LFGDungeonData;
struct LfgReward;
@@ -415,6 +428,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);