Dungeon Finder: Make player internal Lfg data private and some minor cleanups
--HG-- branch : trunk
This commit is contained in:
@@ -42,7 +42,7 @@ enum LfgUpdateType
|
||||
LFG_UPDATETYPE_PROPOSAL_DECLINED = 9,
|
||||
LFG_UPDATETYPE_GROUP_FOUND = 10,
|
||||
LFG_UPDATETYPE_ADDED_TO_QUEUE = 12,
|
||||
LFG_UPDATETYPE_PROPOSAL_FOUND = 13,
|
||||
LFG_UPDATETYPE_PROPOSAL_BEGIN = 13,
|
||||
LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14,
|
||||
LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15,
|
||||
LFG_UPDATETYPE_GROUP_DISBAND = 16,
|
||||
@@ -52,21 +52,11 @@ typedef std::set<uint32> LfgDungeonSet;
|
||||
|
||||
struct LookingForGroup
|
||||
{
|
||||
LookingForGroup(): roles(0)
|
||||
{
|
||||
donerandomDungeons.clear();
|
||||
applyDungeons.clear();
|
||||
}
|
||||
std::string comment;
|
||||
int8 roles;
|
||||
|
||||
bool isDungeonDone(const uint32 entry)
|
||||
{
|
||||
return donerandomDungeons.find(entry) != donerandomDungeons.end();
|
||||
}
|
||||
|
||||
LookingForGroup(): roles(0) {}
|
||||
uint8 roles;
|
||||
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
|
||||
LfgDungeonSet donerandomDungeons; // Finished random Dungeons (to calculate the bonus);
|
||||
std::string comment;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -181,8 +181,8 @@ void LFGMgr::Update(uint32 diff)
|
||||
if (!plr)
|
||||
continue;
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
plr->m_lookingForGroup.applyDungeons.clear();
|
||||
plr->m_lookingForGroup.roles = 0;
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
|
||||
if (itRoles->first == pRoleCheck->leader)
|
||||
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
||||
@@ -258,7 +258,7 @@ void LFGMgr::Join(Player *plr)
|
||||
else
|
||||
{
|
||||
// Check if all dungeons are valid
|
||||
for (LfgDungeonSet::const_iterator it = plr->m_lookingForGroup.applyDungeons.begin(); it != plr->m_lookingForGroup.applyDungeons.end(); ++it)
|
||||
for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end(); ++it)
|
||||
{
|
||||
if ((m_DungeonsMap[LFG_ALL_DUNGEONS])->find(*it) == (m_DungeonsMap[LFG_ALL_DUNGEONS])->end())
|
||||
{
|
||||
@@ -293,8 +293,8 @@ void LFGMgr::Join(Player *plr)
|
||||
|
||||
if (result != LFG_JOIN_OK)
|
||||
{
|
||||
plr->m_lookingForGroup.applyDungeons.clear();
|
||||
plr->m_lookingForGroup.roles = 0;
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
plr->GetSession()->SendLfgJoinResult(result, 0);
|
||||
return;
|
||||
}
|
||||
@@ -302,10 +302,13 @@ void LFGMgr::Join(Player *plr)
|
||||
if (grp)
|
||||
{
|
||||
Player *plrg = NULL;
|
||||
LfgDungeonSet *dungeons;
|
||||
for (GroupReference *itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
plrg = itr->getSource(); // Not null, checked earlier
|
||||
plrg->m_lookingForGroup.applyDungeons = plr->m_lookingForGroup.applyDungeons;
|
||||
dungeons = plrg->GetLfgDungeons();
|
||||
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
|
||||
dungeons->insert(*itDungeon);
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL);
|
||||
}
|
||||
UpdateRoleCheck(grp, plr);
|
||||
@@ -321,14 +324,14 @@ void LFGMgr::Join(Player *plr)
|
||||
uint8 tanks = LFG_TANKS_NEEDED;
|
||||
uint8 healers = LFG_HEALERS_NEEDED;
|
||||
uint8 dps = LFG_DPS_NEEDED;
|
||||
if (plr->m_lookingForGroup.roles & ROLE_TANK)
|
||||
if (plr->GetLfgRoles() & ROLE_TANK)
|
||||
--tanks;
|
||||
else if (plr->m_lookingForGroup.roles & ROLE_HEALER)
|
||||
else if (plr->GetLfgRoles() & ROLE_HEALER)
|
||||
--healers;
|
||||
else
|
||||
--dps;
|
||||
m_update = false;
|
||||
for (LfgDungeonSet::const_iterator it = plr->m_lookingForGroup.applyDungeons.begin(); it != plr->m_lookingForGroup.applyDungeons.end(); ++it)
|
||||
for (LfgDungeonSet::const_iterator it = plr->GetLfgDungeons()->begin(); it != plr->GetLfgDungeons()->end(); ++it)
|
||||
{
|
||||
groupType = GetDungeonGroupType(*it);
|
||||
pqInfo = m_Queues[groupType] ? m_Queues[groupType]->GetQueueInfo(plr->GetGUID()) : NULL;
|
||||
@@ -341,7 +344,7 @@ void LFGMgr::Join(Player *plr)
|
||||
pqInfo->tanks = tanks;
|
||||
pqInfo->healers = healers;
|
||||
pqInfo->dps = dps;
|
||||
pqInfo->roles[plr->GetGUID()] = plr->m_lookingForGroup.roles;
|
||||
pqInfo->roles[plr->GetGUID()] = plr->GetLfgRoles();
|
||||
if (!m_Queues[groupType])
|
||||
m_Queues[groupType] = new LFGQueue();
|
||||
m_Queues[groupType]->AddToQueue(plr->GetGUID(), pqInfo);
|
||||
@@ -386,15 +389,15 @@ void LFGMgr::Leave(Player *plr, Group *grp /* = NULL*/)
|
||||
if (Player *plrg = itr->getSource())
|
||||
{
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
plrg->m_lookingForGroup.applyDungeons.clear();
|
||||
plrg->m_lookingForGroup.roles = 0;
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
plr->m_lookingForGroup.applyDungeons.clear();
|
||||
plr->m_lookingForGroup.roles = 0;
|
||||
plr->GetLfgDungeons()->clear();
|
||||
plr->SetLfgRoles(ROLE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +429,8 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
|
||||
if (Player *plrg = itr->getSource())
|
||||
pRoleCheck->roles[plrg->GetGUID()] = 0;
|
||||
|
||||
pRoleCheck->dungeons = plr->m_lookingForGroup.applyDungeons;
|
||||
for (LfgDungeonSet::const_iterator itDungeon = plr->GetLfgDungeons()->begin(); itDungeon != plr->GetLfgDungeons()->end(); ++itDungeon)
|
||||
pRoleCheck->dungeons.insert(*itDungeon);
|
||||
}
|
||||
else
|
||||
pRoleCheck = itRoleCheck->second;
|
||||
@@ -435,12 +439,12 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
|
||||
if (plr)
|
||||
{
|
||||
// Player selected no role.
|
||||
if (plr->m_lookingForGroup.roles < ROLE_TANK)
|
||||
if (plr->GetLfgRoles() < ROLE_TANK)
|
||||
pRoleCheck->result = LFG_ROLECHECK_NO_ROLE;
|
||||
else
|
||||
{
|
||||
// Check if all players have selected a role
|
||||
pRoleCheck->roles[plr->GetGUID()] = plr->m_lookingForGroup.roles;
|
||||
pRoleCheck->roles[plr->GetGUID()] = plr->GetLfgRoles();
|
||||
uint8 size = 0;
|
||||
for (LfgRolesMap::const_iterator itRoles = pRoleCheck->roles.begin(); itRoles != pRoleCheck->roles.end() && itRoles->second != ROLE_NONE; ++itRoles)
|
||||
++size;
|
||||
@@ -489,7 +493,7 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
|
||||
|
||||
session = plrg->GetSession();
|
||||
if (!newRoleCheck && plr)
|
||||
session->SendLfgRoleChosen(plr->GetGUID(), plr->m_lookingForGroup.roles);
|
||||
session->SendLfgRoleChosen(plr->GetGUID(), plr->GetLfgRoles());
|
||||
session->SendPacket(&data);
|
||||
|
||||
switch(pRoleCheck->result)
|
||||
@@ -516,16 +520,16 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
|
||||
session->SendPacket(&data);
|
||||
}
|
||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||
plrg->m_lookingForGroup.applyDungeons.clear();
|
||||
plrg->m_lookingForGroup.roles = 0;
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (grp->IsLeader(plrg->GetGUID()))
|
||||
session->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
|
||||
session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
|
||||
plrg->m_lookingForGroup.applyDungeons.clear();
|
||||
plrg->m_lookingForGroup.roles = 0;
|
||||
plrg->GetLfgDungeons()->clear();
|
||||
plrg->SetLfgRoles(ROLE_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -565,7 +569,7 @@ void LFGMgr::UpdateRoleCheck(Group *grp, Player *plr /* = NULL*/)
|
||||
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
if (Player *plrg = itr->getSource())
|
||||
pqInfo->roles[plrg->GetGUID()] = plrg->m_lookingForGroup.roles;
|
||||
pqInfo->roles[plrg->GetGUID()] = plrg->GetLfgRoles();
|
||||
}
|
||||
if (!m_Queues[groupType])
|
||||
m_Queues[groupType] = new LFGQueue();
|
||||
@@ -769,7 +773,7 @@ void LFGMgr::SendLfgPartyInfo(Player *plr)
|
||||
/// <param name="plr">Player</param>
|
||||
void LFGMgr::BuildRewardBlock(WorldPacket &data, uint32 dungeon, Player *plr)
|
||||
{
|
||||
bool done = plr->m_lookingForGroup.isDungeonDone(dungeon);
|
||||
bool done = plr->isLfgDungeonDone(dungeon);
|
||||
LfgReward *reward = GetRandomDungeonReward(dungeon, done, plr->getLevel());
|
||||
|
||||
if (!reward)
|
||||
|
||||
@@ -2250,7 +2250,14 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
|
||||
void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
|
||||
|
||||
LookingForGroup m_lookingForGroup;
|
||||
// Dungeon Finder
|
||||
bool isLfgDungeonDone(const uint32 entry) { return m_LookingForGroup.donerandomDungeons.find(entry) != m_LookingForGroup.donerandomDungeons.end(); }
|
||||
LfgDungeonSet *GetLfgDungeons() { return &m_LookingForGroup.applyDungeons; }
|
||||
LfgDungeonSet *GetLfgDungeonsDone() { return &m_LookingForGroup.donerandomDungeons; }
|
||||
std::string GetLfgComment() { return m_LookingForGroup.comment; }
|
||||
void SetLfgComment(std::string _comment) { m_LookingForGroup.comment = _comment; }
|
||||
uint8 GetLfgRoles() { return m_LookingForGroup.roles; }
|
||||
void SetLfgRoles(uint8 _roles) { m_LookingForGroup.roles = _roles; }
|
||||
|
||||
// Temporarily removed pet cache
|
||||
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
|
||||
@@ -2671,6 +2678,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 m_timeSyncTimer;
|
||||
uint32 m_timeSyncClient;
|
||||
uint32 m_timeSyncServer;
|
||||
|
||||
LookingForGroup m_LookingForGroup;
|
||||
};
|
||||
|
||||
void AddItemsSetItem(Player*player,Item *item);
|
||||
|
||||
@@ -42,12 +42,12 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlayer()->m_lookingForGroup.roles = uint8(roles);
|
||||
GetPlayer()->SetLfgRoles(uint8(roles));
|
||||
for (int8 i = 0 ; i < numDungeons; ++i)
|
||||
{
|
||||
recv_data >> dungeon;
|
||||
// remove the type from the dungeon entry
|
||||
GetPlayer()->m_lookingForGroup.applyDungeons.insert((dungeon & 0x00FFFFFF));
|
||||
GetPlayer()->GetLfgDungeons()->insert((dungeon & 0x00FFFFFF));
|
||||
}
|
||||
|
||||
recv_data >> numDungeons; // unk - always 3
|
||||
@@ -56,7 +56,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
|
||||
recv_data >> comment;
|
||||
|
||||
GetPlayer()->m_lookingForGroup.comment = comment;
|
||||
GetPlayer()->SetLfgComment(comment);
|
||||
sLFGMgr.Join(GetPlayer());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
|
||||
Group *grp = GetPlayer()->GetGroup();
|
||||
if (!grp)
|
||||
return;
|
||||
GetPlayer()->m_lookingForGroup.roles = roles;
|
||||
GetPlayer()->SetLfgRoles(roles);
|
||||
sLFGMgr.UpdateRoleCheck(grp, GetPlayer());
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void WorldSession::HandleSetLfgCommentOpcode(WorldPacket & recv_data)
|
||||
std::string comment;
|
||||
recv_data >> comment;
|
||||
|
||||
GetPlayer()->m_lookingForGroup.comment = comment;
|
||||
GetPlayer()->SetLfgComment(comment);
|
||||
}
|
||||
|
||||
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
|
||||
@@ -125,12 +125,15 @@ void WorldSession::SendLfgUpdatePlayer(uint8 updateType)
|
||||
extrainfo = true;
|
||||
break;
|
||||
//case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences...
|
||||
case LFG_UPDATETYPE_PROPOSAL_FOUND:
|
||||
case LFG_UPDATETYPE_PROPOSAL_BEGIN:
|
||||
extrainfo = true;
|
||||
break;
|
||||
}
|
||||
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
|
||||
uint8 size = dungeons->size();
|
||||
std::string comment = GetPlayer()->GetLfgComment();
|
||||
sLog.outDebug("SMSG_LFG_UPDATE_PLAYER");
|
||||
WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + GetPlayer()->m_lookingForGroup.applyDungeons.size() * 4 + GetPlayer()->m_lookingForGroup.comment.length()));
|
||||
WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + comment.length()));
|
||||
data << uint8(updateType); // Lfg Update type
|
||||
data << uint8(extrainfo); // Extra info
|
||||
if (extrainfo)
|
||||
@@ -139,12 +142,11 @@ void WorldSession::SendLfgUpdatePlayer(uint8 updateType)
|
||||
data << uint8(0); // unk - Always 0
|
||||
data << uint8(0); // unk - Always 0
|
||||
|
||||
uint8 size = GetPlayer()->m_lookingForGroup.applyDungeons.size();
|
||||
data << uint8(size);
|
||||
|
||||
for (LfgDungeonSet::const_iterator it = GetPlayer()->m_lookingForGroup.applyDungeons.begin(); it != GetPlayer()->m_lookingForGroup.applyDungeons.end(); ++it)
|
||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
||||
data << uint32(*it);
|
||||
data << GetPlayer()->m_lookingForGroup.comment;
|
||||
data << comment;
|
||||
}
|
||||
SendPacket(&data);
|
||||
}
|
||||
@@ -169,14 +171,17 @@ void WorldSession::SendLfgUpdateParty(uint8 updateType)
|
||||
// join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences...
|
||||
queued = true;
|
||||
break;
|
||||
case LFG_UPDATETYPE_PROPOSAL_FOUND:
|
||||
case LFG_UPDATETYPE_PROPOSAL_BEGIN:
|
||||
extrainfo = true;
|
||||
join = true;
|
||||
break;
|
||||
}
|
||||
|
||||
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
|
||||
uint8 size = dungeons->size();
|
||||
std::string comment = GetPlayer()->GetLfgComment();
|
||||
sLog.outDebug("SMSG_LFG_UPDATE_PARTY");
|
||||
WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + GetPlayer()->m_lookingForGroup.applyDungeons.size() * 4 + GetPlayer()->m_lookingForGroup.comment.length()));
|
||||
WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + comment.length()));
|
||||
data << uint8(updateType); // Lfg Update type
|
||||
data << uint8(extrainfo); // Extra info
|
||||
if (extrainfo)
|
||||
@@ -188,13 +193,12 @@ void WorldSession::SendLfgUpdateParty(uint8 updateType)
|
||||
for (uint8 i = 0; i < 3; ++i)
|
||||
data << uint8(0); // unk - Always 0
|
||||
|
||||
uint8 size = GetPlayer()->m_lookingForGroup.applyDungeons.size();
|
||||
data << uint8(size);
|
||||
|
||||
for (LfgDungeonSet::const_iterator it = GetPlayer()->m_lookingForGroup.applyDungeons.begin(); it != GetPlayer()->m_lookingForGroup.applyDungeons.end(); ++it)
|
||||
for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
|
||||
data << uint32(*it);
|
||||
|
||||
data << GetPlayer()->m_lookingForGroup.comment;
|
||||
data << comment;
|
||||
}
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user