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,
|
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
|
enum LfgUpdateType
|
||||||
{
|
{
|
||||||
LFG_UPDATETYPE_LEADER = 1,
|
LFG_UPDATETYPE_LEADER = 1,
|
||||||
@@ -49,9 +56,10 @@ typedef std::set<uint32> LfgDungeonSet;
|
|||||||
|
|
||||||
struct LookingForGroup
|
struct LookingForGroup
|
||||||
{
|
{
|
||||||
LookingForGroup(): roles(0), update(true) {}
|
LookingForGroup(): roles(0), update(true), state(LFG_STATE_NONE) {}
|
||||||
uint8 roles;
|
uint8 roles;
|
||||||
bool update;
|
bool update;
|
||||||
|
LfgState state;
|
||||||
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
|
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
|
||||||
LfgDungeonSet donerandomDungeons; // Finished random Dungeons (to calculate the bonus);
|
LfgDungeonSet donerandomDungeons; // Finished random Dungeons (to calculate the bonus);
|
||||||
std::string comment;
|
std::string comment;
|
||||||
|
|||||||
@@ -299,6 +299,8 @@ void LFGMgr::Update(uint32 diff)
|
|||||||
plr->GetSession()->SendLfgRoleCheckUpdate(pRoleCheck);
|
plr->GetSession()->SendLfgRoleCheckUpdate(pRoleCheck);
|
||||||
plr->GetLfgDungeons()->clear();
|
plr->GetLfgDungeons()->clear();
|
||||||
plr->SetLfgRoles(ROLE_NONE);
|
plr->SetLfgRoles(ROLE_NONE);
|
||||||
|
if (!plr->GetGroup() || !plr->GetGroup()->isLFGGroup())
|
||||||
|
plr->SetLfgState(LFG_STATE_NONE);
|
||||||
|
|
||||||
if (itRoles->first == pRoleCheck->leader)
|
if (itRoles->first == pRoleCheck->leader)
|
||||||
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
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);
|
sLog.outError("DEBUG:LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result);
|
||||||
plr->GetLfgDungeons()->clear();
|
plr->GetLfgDungeons()->clear();
|
||||||
plr->SetLfgRoles(ROLE_NONE);
|
plr->SetLfgRoles(ROLE_NONE);
|
||||||
|
if (grp && !grp->isLFGGroup())
|
||||||
|
plr->SetLfgState(LFG_STATE_NONE);
|
||||||
plr->GetSession()->SendLfgJoinResult(result);
|
plr->GetSession()->SendLfgJoinResult(result);
|
||||||
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||||
return;
|
return;
|
||||||
@@ -644,6 +648,7 @@ void LFGMgr::Join(Player* plr)
|
|||||||
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
for (GroupReference* itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
{
|
{
|
||||||
plrg = itr->getSource(); // Not null, checked earlier
|
plrg = itr->getSource(); // Not null, checked earlier
|
||||||
|
plrg->SetLfgState(LFG_STATE_LFG);
|
||||||
if (plrg != plr)
|
if (plrg != plr)
|
||||||
{
|
{
|
||||||
dungeons = plrg->GetLfgDungeons();
|
dungeons = plrg->GetLfgDungeons();
|
||||||
@@ -657,6 +662,7 @@ void LFGMgr::Join(Player* plr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
plr->SetLfgState(LFG_STATE_LFG);
|
||||||
LfgRolesMap roles;
|
LfgRolesMap roles;
|
||||||
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
roles[plr->GetGUIDLow()] = plr->GetLfgRoles();
|
||||||
|
|
||||||
@@ -700,7 +706,7 @@ void LFGMgr::Join(Player* plr)
|
|||||||
/// <param name="Group*">Group (could be NULL)</param>
|
/// <param name="Group*">Group (could be NULL)</param>
|
||||||
void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
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;
|
return;
|
||||||
|
|
||||||
uint64 guid = grp ? grp->GetGUID() : plr ? plr->GetGUID() : 0;
|
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->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||||
plrg->GetLfgDungeons()->clear();
|
plrg->GetLfgDungeons()->clear();
|
||||||
plrg->SetLfgRoles(ROLE_NONE);
|
plrg->SetLfgRoles(ROLE_NONE);
|
||||||
|
plrg->SetLfgState(LFG_STATE_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -755,6 +762,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
|||||||
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||||
plr->GetLfgDungeons()->clear();
|
plr->GetLfgDungeons()->clear();
|
||||||
plr->SetLfgRoles(ROLE_NONE);
|
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);
|
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||||
plrg->GetLfgDungeons()->clear();
|
plrg->GetLfgDungeons()->clear();
|
||||||
plrg->SetLfgRoles(ROLE_NONE);
|
plrg->SetLfgRoles(ROLE_NONE);
|
||||||
|
if (!grp->isLFGGroup())
|
||||||
|
plr->SetLfgState(LFG_STATE_NONE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1230,7 +1240,9 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/)
|
|||||||
session->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
session->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
||||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||||
plrg->GetLfgDungeons()->clear();
|
plrg->GetLfgDungeons()->clear();
|
||||||
plrg->SetLfgRoles(ROLE_NONE);
|
if (grp->isLFGGroup())
|
||||||
|
plrg->SetLfgRoles(ROLE_NONE);
|
||||||
|
plr->SetLfgState(LFG_STATE_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1644,6 +1656,8 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
|
|||||||
updateType = type;
|
updateType = type;
|
||||||
plr->GetLfgDungeons()->clear();
|
plr->GetLfgDungeons()->clear();
|
||||||
plr->SetLfgRoles(ROLE_NONE);
|
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);
|
sLog.outError("DEBUG:LFGMgr::RemoveProposal: [" UI64FMTD "] didn't accept. Removing from queue and compatible cache", guid);
|
||||||
RemoveFromQueue(guid);
|
RemoveFromQueue(guid);
|
||||||
|
|||||||
@@ -2265,6 +2265,9 @@ class Player : public Unit, public GridObject<Player>
|
|||||||
void SetLfgRoles(uint8 _roles) { m_LookingForGroup.roles = _roles; }
|
void SetLfgRoles(uint8 _roles) { m_LookingForGroup.roles = _roles; }
|
||||||
bool GetLfgUpdate() { return m_LookingForGroup.update; }
|
bool GetLfgUpdate() { return m_LookingForGroup.update; }
|
||||||
void SetLfgUpdate(bool update) { m_LookingForGroup.update = 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
|
// Temporarily removed pet cache
|
||||||
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
|
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)));
|
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
|
// can do this, since it's battleground, not arena
|
||||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
|
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
|
||||||
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
|
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user