Core/Dungeon Finder: Add lfg state to know if a player is using lfg or lfr
- Do not allow to join battleground if using lfg/lfr Closes issue 4189 --HG-- branch : trunk
This commit is contained in:
@@ -28,6 +28,13 @@ enum LfgRoles
|
||||
ROLE_DAMAGE = 0x08,
|
||||
};
|
||||
|
||||
enum LfgState
|
||||
{
|
||||
LFG_STATE_NONE = 0, // Not using LFG / LFR
|
||||
LFG_STATE_LFG = 1, // Using Dungeon finder
|
||||
LFG_STATE_LFR = 2, // Using Raid finder
|
||||
};
|
||||
|
||||
enum LfgUpdateType
|
||||
{
|
||||
LFG_UPDATETYPE_LEADER = 1,
|
||||
@@ -49,9 +56,10 @@ typedef std::set<uint32> LfgDungeonSet;
|
||||
|
||||
struct LookingForGroup
|
||||
{
|
||||
LookingForGroup(): roles(0), update(true) {}
|
||||
LookingForGroup(): roles(0), update(true), state(LFG_STATE_NONE) {}
|
||||
uint8 roles;
|
||||
bool update;
|
||||
LfgState state;
|
||||
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
|
||||
LfgDungeonSet donerandomDungeons; // Finished random Dungeons (to calculate the bonus);
|
||||
std::string comment;
|
||||
|
||||
@@ -299,6 +299,8 @@ void LFGMgr::Update(uint32 diff)
|
||||
plr->GetSession()->SendLfgRoleCheckUpdate(pRoleCheck);
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
if (!plr->GetGroup() || !plr->GetGroup()->isLFGGroup())
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
|
||||
if (itRoles->first == pRoleCheck->leader)
|
||||
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
||||
@@ -632,6 +634,8 @@ void LFGMgr::Join(Player* plr)
|
||||
sLog.outError("DEBUG:LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result);
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
if (grp && !grp->isLFGGroup())
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
plr->GetSession()->SendLfgJoinResult(result);
|
||||
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||
return;
|
||||
@@ -644,6 +648,7 @@ void LFGMgr::Join(Player* plr)
|
||||
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
plrg = itr->getSource(); // Not null, checked earlier
|
||||
plrg->SetLfgState(LFG_STATE_LFG);
|
||||
if (plrg != plr)
|
||||
{
|
||||
dungeons = plrg->GetLfgDungeons();
|
||||
@@ -657,6 +662,7 @@ void LFGMgr::Join(Player* plr)
|
||||
}
|
||||
else
|
||||
{
|
||||
plr->SetLfgState(LFG_STATE_LFG);
|
||||
LfgRolesMap roles;
|
||||
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
||||
|
||||
@@ -700,7 +706,7 @@ void LFGMgr::Join(Player* plr)
|
||||
/// <param name="Group*">Group (could be NULL)</param>
|
||||
void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
||||
{
|
||||
if ((plr && !plr->GetLfgUpdate()) || !sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE))
|
||||
if ((plr && (!plr->GetLfgUpdate() || !plr->isUsingLfg())) || !sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE))
|
||||
return;
|
||||
|
||||
uint64 guid = grp ? grp->GetGUID() : plr ? plr->GetGUID() : 0;
|
||||
@@ -748,6 +754,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
plrg->SetLfgState(LFG_STATE_NONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -755,6 +762,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
||||
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,6 +1231,8 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/)
|
||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
if (!grp->isLFGGroup())
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1230,7 +1240,9 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/)
|
||||
session->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
if (grp->isLFGGroup())
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1644,6 +1656,8 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
|
||||
updateType = type;
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
if (!plr->GetGroup() || !plr->GetGroup()->isLFGGroup())
|
||||
plr->SetLfgState(LFG_STATE_NONE);
|
||||
|
||||
sLog.outError("DEBUG:LFGMgr::RemoveProposal: [" UI64FMTD "] didn't accept. Removing from queue and compatible cache", guid);
|
||||
RemoveFromQueue(guid);
|
||||
|
||||
@@ -2265,6 +2265,9 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetLfgRoles(uint8 _roles) { m_LookingForGroup.roles = _roles; }
|
||||
bool GetLfgUpdate() { return m_LookingForGroup.update; }
|
||||
void SetLfgUpdate(bool update) { m_LookingForGroup.update = update; }
|
||||
LfgState GetLfgState() { return m_LookingForGroup.state; }
|
||||
void SetLfgState(LfgState state) { m_LookingForGroup.state = state; }
|
||||
bool isUsingLfg() { return GetLfgState() != LFG_STATE_NONE; }
|
||||
|
||||
// Temporarily removed pet cache
|
||||
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
|
||||
|
||||
@@ -101,6 +101,15 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data)
|
||||
|
||||
sLog.outDebug("WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)));
|
||||
|
||||
// player is using dungeon finder or raid finder
|
||||
if (GetPlayer()->isUsingLfg())
|
||||
{
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_LFG_CANT_USE_BATTLEGROUND);
|
||||
GetPlayer()->GetSession()->SendPacket(&data);
|
||||
return;
|
||||
}
|
||||
|
||||
// can do this, since it's battleground, not arena
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
|
||||
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
|
||||
|
||||
Reference in New Issue
Block a user