Core/Dungeon Finder: Multiple changes
- Code Style - Explicit removal of the proposal if player leaves the queue (do not waits to ::Update) - Force to leave LFG system if group/player is joining and its already in - Change some debug msgs and fix some typos (error --> debug) - Offer to continue: Remove duplicate checks - Move body functions from .h to .cpp - Revert 11e39d620d and check if group recently joined by comparing joinTimes --HG-- branch : trunk
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,7 @@ enum LFGenum
|
||||
LFG_TIME_ROLECHECK = 2*MINUTE,
|
||||
LFG_TIME_BOOT = 2*MINUTE,
|
||||
LFG_TIME_PROPOSAL = 2*MINUTE,
|
||||
LFG_TIME_JOIN_WARNING = 1*IN_MILLISECONDS,
|
||||
LFG_TANKS_NEEDED = 1,
|
||||
LFG_HEALERS_NEEDED = 1,
|
||||
LFG_DPS_NEEDED = 3,
|
||||
@@ -235,7 +236,7 @@ typedef std::map<uint32, LfgProposal*> LfgProposalMap;
|
||||
typedef std::map<uint32, LfgPlayerBoot*> LfgPlayerBootMap;
|
||||
typedef std::multimap<uint32, LfgReward const*> LfgRewardMap;
|
||||
typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds;
|
||||
typedef std::list<Player *> LfgPlayerList;
|
||||
typedef std::list<Player*> LfgPlayerList;
|
||||
typedef std::set<uint64> LfgGuidSet;
|
||||
typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
|
||||
|
||||
@@ -247,72 +248,51 @@ class LFGMgr
|
||||
LFGMgr();
|
||||
~LFGMgr();
|
||||
|
||||
void Join(Player *plr);
|
||||
void Leave(Player *plr, Group *grp = NULL);
|
||||
void OfferContinue(Group *grp);
|
||||
void TeleportPlayer(Player *plr, bool out);
|
||||
void Join(Player* plr);
|
||||
void Leave(Player* plr, Group* grp = NULL);
|
||||
void OfferContinue(Group* grp);
|
||||
void TeleportPlayer(Player* plr, bool out);
|
||||
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
|
||||
void UpdateBoot(Player *plr, bool accept);
|
||||
void UpdateRoleCheck(Group *grp, Player *plr = NULL);
|
||||
void UpdateBoot(Player* plr, bool accept);
|
||||
void UpdateRoleCheck(Group* grp, Player* plr = NULL);
|
||||
void Update(uint32 diff);
|
||||
|
||||
bool isRandomDungeon(uint32 dungeonId);
|
||||
void InitBoot(Group *grp, uint32 plowGuid, uint32 vlowGuid, std::string reason);
|
||||
void InitBoot(Group* grp, uint32 plowGuid, uint32 vlowGuid, std::string reason);
|
||||
|
||||
void LoadDungeonEncounters();
|
||||
void LoadRewards();
|
||||
void RewardDungeonDoneFor(const uint32 dungeonId, Player* player);
|
||||
uint32 GetDungeonIdForAchievement(uint32 achievementId)
|
||||
{
|
||||
std::map<uint32, uint32>::iterator itr = m_EncountersByAchievement.find(achievementId);
|
||||
if (itr != m_EncountersByAchievement.end())
|
||||
return itr->second;
|
||||
uint32 GetDungeonIdForAchievement(uint32 achievementId);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
LfgLockStatusMap* GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons = NULL);
|
||||
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL);
|
||||
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
|
||||
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons = NULL, bool useEntry = true);
|
||||
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL, bool useEntry = true);
|
||||
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
|
||||
|
||||
bool isJoining(uint64 guid)
|
||||
{
|
||||
return m_JoinQueue.find(guid) != m_JoinQueue.end();
|
||||
};
|
||||
|
||||
void SetJoining(uint64 guid, bool add)
|
||||
{
|
||||
if (add)
|
||||
m_JoinQueue.insert(guid);
|
||||
else
|
||||
{
|
||||
LfgGuidSet::const_iterator it = m_JoinQueue.find(guid);
|
||||
if (it != m_JoinQueue.end())
|
||||
m_JoinQueue.erase(it);
|
||||
}
|
||||
};
|
||||
bool isJoining(uint64 guid);
|
||||
|
||||
private:
|
||||
void Cleaner();
|
||||
void AddGuidToNewQueue(uint64 guid);
|
||||
void AddToQueue(uint64 guid, LfgRolesMap *roles, LfgDungeonSet *dungeons);
|
||||
void AddToQueue(uint64 guid, LfgRolesMap* roles, LfgDungeonSet* dungeons);
|
||||
|
||||
bool RemoveFromQueue(uint64 guid);
|
||||
void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type);
|
||||
|
||||
void FindNewGroups(LfgGuidList &check, LfgGuidList all, LfgProposalList *proposals);
|
||||
void FindNewGroups(LfgGuidList &check, LfgGuidList all, LfgProposalList* proposals);
|
||||
|
||||
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
|
||||
bool CheckCompatibility(LfgGuidList check, LfgProposalList *proposals);
|
||||
LfgDungeonSet* CheckCompatibleDungeons(LfgDungeonMap *dungeonsMap, PlayerSet *players);
|
||||
LfgLockStatusMap *CheckCompatibleDungeons(LfgDungeonSet *dungeons, PlayerSet *players, bool returnLockMap = true);
|
||||
bool CheckCompatibility(LfgGuidList check, LfgProposalList* proposals);
|
||||
LfgDungeonSet* CheckCompatibleDungeons(LfgDungeonMap* dungeonsMap, PlayerSet* players);
|
||||
LfgLockStatusMap* CheckCompatibleDungeons(LfgDungeonSet* dungeons, PlayerSet* players, bool returnLockMap = true);
|
||||
void SetCompatibles(std::string concatenatedGuids, bool compatibles);
|
||||
LfgAnswer GetCompatibles(std::string concatenatedGuids);
|
||||
void RemoveFromCompatibles(uint64 guid);
|
||||
std::string ConcatenateGuids(LfgGuidList check);
|
||||
std::string ConcatenateDungeons(LfgDungeonSet* dungeons);
|
||||
|
||||
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet *pPlayers, LfgDungeonSet *dungeons, bool useEntry = true);
|
||||
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet* pPlayers, LfgDungeonSet* dungeons, bool useEntry = true);
|
||||
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
|
||||
LfgDungeonSet* GetAllDungeons();
|
||||
uint8 GetDungeonGroupType(uint32 dungeon);
|
||||
@@ -323,7 +303,6 @@ class LFGMgr
|
||||
LfgQueueInfoMap m_QueueInfoMap; // Queued groups
|
||||
LfgGuidList m_currentQueue; // Ordered list. Used to find groups
|
||||
LfgGuidList m_newToQueue; // New groups to add to queue
|
||||
LfgGuidSet m_JoinQueue; // Stores guids being joined (to avoid duplicate tries to join)
|
||||
LfgCompatibleMap m_CompatibleMap; // Compatible dungeons
|
||||
LfgProposalMap m_Proposals; // Current Proposals
|
||||
LfgPlayerBootMap m_Boots; // Current player kicks
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "Player.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet)
|
||||
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet* lockSet)
|
||||
{
|
||||
if (!lockSet || !lockSet->size())
|
||||
{
|
||||
@@ -41,7 +41,7 @@ void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet)
|
||||
delete lockSet;
|
||||
}
|
||||
|
||||
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *lockMap)
|
||||
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap)
|
||||
{
|
||||
if (!lockMap || !lockMap->size())
|
||||
{
|
||||
@@ -75,8 +75,6 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
sLFGMgr.SetJoining(GetPlayer()->GetGUID(), true);
|
||||
|
||||
uint8 numDungeons;
|
||||
uint32 dungeon;
|
||||
uint32 roles;
|
||||
@@ -91,7 +89,6 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
{
|
||||
sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID());
|
||||
recv_data.rpos(recv_data.wpos());
|
||||
sLFGMgr.SetJoining(GetPlayer()->GetGUID(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,10 +104,10 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
|
||||
recv_data >> comment;
|
||||
|
||||
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
|
||||
Group *grp = GetPlayer()->GetGroup();
|
||||
LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons();
|
||||
Group* grp = GetPlayer()->GetGroup();
|
||||
bool isRandomDungeon = dungeons->size() == 1 && sLFGMgr.isRandomDungeon(*dungeons->begin());
|
||||
bool isCurrentDungeon = newDungeons.size() == 1 && grp && grp->isLFGGroup() && grp->GetLfgDungeonEntry() == *newDungeons.begin();
|
||||
bool isCurrentDungeon = newDungeons.size() == 1 && grp && grp->isLFGGroup() && grp->GetLfgDungeonEntry() == (*newDungeons.begin());
|
||||
|
||||
if (!isRandomDungeon || !isCurrentDungeon) // is not offer to continue - clear old dungeons and use new dungeons
|
||||
{
|
||||
@@ -123,12 +120,11 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
|
||||
sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] as group: %u - Dungeons: %u", GetPlayer()->GetGUID(), grp ? 1 : 0, uint8(newDungeons.size()));
|
||||
newDungeons.clear();
|
||||
sLFGMgr.Join(GetPlayer());
|
||||
sLFGMgr.SetJoining(GetPlayer()->GetGUID(), false);
|
||||
}
|
||||
|
||||
void WorldSession::HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/)
|
||||
{
|
||||
Group *grp = GetPlayer()->GetGroup();
|
||||
Group* grp = GetPlayer()->GetGroup();
|
||||
|
||||
sLog.outDebug("CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", GetPlayer()->GetGUID(), grp ? 1 : 0);
|
||||
|
||||
@@ -153,7 +149,7 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
|
||||
uint8 roles;
|
||||
recv_data >> roles; // Player Group Roles
|
||||
|
||||
Group *grp = GetPlayer()->GetGroup();
|
||||
Group* grp = GetPlayer()->GetGroup();
|
||||
if (!grp)
|
||||
{
|
||||
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", GetPlayer()->GetGUID());
|
||||
@@ -199,8 +195,8 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
||||
uint32 rsize = 0;
|
||||
uint32 lsize = 0;
|
||||
bool done;
|
||||
LfgDungeonSet *randomlist = sLFGMgr.GetRandomDungeons(GetPlayer()->getLevel(), GetPlayer()->GetSession()->Expansion());
|
||||
LfgLockStatusSet *lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer());
|
||||
LfgDungeonSet* randomlist = sLFGMgr.GetRandomDungeons(GetPlayer()->getLevel(), GetPlayer()->GetSession()->Expansion());
|
||||
LfgLockStatusSet* lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer());
|
||||
|
||||
if (randomlist)
|
||||
rsize = randomlist->size();
|
||||
@@ -267,7 +263,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
|
||||
void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket & /*recv_data*/)
|
||||
{
|
||||
sLog.outDebug("CMSG_LFD_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||
if (LfgLockStatusMap *lockMap = sLFGMgr.GetPartyLockStatusDungeons(GetPlayer()))
|
||||
if (LfgLockStatusMap* lockMap = sLFGMgr.GetPartyLockStatusDungeons(GetPlayer()))
|
||||
{
|
||||
uint32 size = 0;
|
||||
for (LfgLockStatusMap::const_iterator it = lockMap->begin(); it != lockMap->end(); ++it)
|
||||
@@ -318,7 +314,7 @@ void WorldSession::SendLfgUpdatePlayer(uint8 updateType)
|
||||
extrainfo = true;
|
||||
break;
|
||||
}
|
||||
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
|
||||
LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons();
|
||||
uint8 size = dungeons->size();
|
||||
std::string comment = GetPlayer()->GetLfgComment();
|
||||
|
||||
@@ -373,7 +369,7 @@ void WorldSession::SendLfgUpdateParty(uint8 updateType)
|
||||
break;
|
||||
}
|
||||
|
||||
LfgDungeonSet *dungeons = GetPlayer()->GetLfgDungeons();
|
||||
LfgDungeonSet* dungeons = GetPlayer()->GetLfgDungeons();
|
||||
uint8 size = dungeons->size();
|
||||
std::string comment = GetPlayer()->GetLfgComment();
|
||||
|
||||
@@ -411,26 +407,26 @@ void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck *pRoleCheck)
|
||||
void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
|
||||
{
|
||||
ASSERT(pRoleCheck);
|
||||
|
||||
sLog.outDebug("SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID());
|
||||
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + pRoleCheck->dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1));
|
||||
|
||||
Player *plr;
|
||||
Player* plr;
|
||||
uint8 roles;
|
||||
|
||||
data << uint32(pRoleCheck->result); // Check result
|
||||
data << uint8(pRoleCheck->result == LFG_ROLECHECK_INITIALITING);
|
||||
data << uint8(pRoleCheck->dungeons.size()); // Number of dungeons
|
||||
LFGDungeonEntry const *dungeon;
|
||||
LFGDungeonEntry const* dungeon;
|
||||
for (LfgDungeonSet::iterator it = pRoleCheck->dungeons.begin(); it != pRoleCheck->dungeons.end(); ++it)
|
||||
{
|
||||
dungeon = sLFGDungeonStore.LookupEntry(*it);
|
||||
if (!dungeon)
|
||||
{
|
||||
sLog.outError("BuildLfgRoleCheck: Dungeon %u does not exist in dbcs", *it);
|
||||
sLog.outError("BuildLfgRoleCheck: Dungeon %u does not exist in dbcs", (*it));
|
||||
data << uint32(0);
|
||||
}
|
||||
else
|
||||
@@ -463,7 +459,7 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck *pRoleCheck)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue /* = 0 */, LfgLockStatusMap *playersLockMap /* = NULL */)
|
||||
void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue /* = 0 */, LfgLockStatusMap* playersLockMap /* = NULL */)
|
||||
{
|
||||
uint32 size = 0;
|
||||
if (playersLockMap)
|
||||
@@ -499,7 +495,7 @@ void WorldSession::SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgW
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward *reward, const Quest *qRew)
|
||||
void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward* reward, const Quest* qRew)
|
||||
{
|
||||
if (!rdungeonEntry || !sdungeonEntry || !qRew)
|
||||
return;
|
||||
@@ -535,7 +531,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendLfgBootPlayer(LfgPlayerBoot *pBoot)
|
||||
void WorldSession::SendLfgBootPlayer(LfgPlayerBoot* pBoot)
|
||||
{
|
||||
int8 playerVote = pBoot->votes[GetPlayer()->GetGUIDLow()];
|
||||
uint8 votesNum = 0;
|
||||
@@ -567,7 +563,7 @@ void WorldSession::SendLfgBootPlayer(LfgPlayerBoot *pBoot)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal *pProp)
|
||||
void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal* pProp)
|
||||
{
|
||||
if (!pProp)
|
||||
return;
|
||||
@@ -577,7 +573,7 @@ void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal *pProp)
|
||||
if (itPlayer == pProp->players.end()) // Player MUST be in the proposal
|
||||
return;
|
||||
|
||||
LfgProposalPlayer *ppPlayer = itPlayer->second;
|
||||
LfgProposalPlayer* ppPlayer = itPlayer->second;
|
||||
uint32 pLowGroupGuid = ppPlayer->groupLowGuid;
|
||||
uint32 dLowGuid = pProp->groupLowGuid;
|
||||
uint32 dungeonId = pProp->dungeonId;
|
||||
@@ -586,8 +582,8 @@ void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal *pProp)
|
||||
sLog.outDebug("SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", GetPlayer()->GetGUID(), pProp->state);
|
||||
WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + pProp->players.size() * (4 + 1 + 1 + 1 + 1 +1));
|
||||
if (!dLowGuid && GetPlayer()->GetLfgDungeons()->size() == 1) // New group - select the dungeon the player selected
|
||||
dungeonId = *GetPlayer()->GetLfgDungeons()->begin();
|
||||
if (LFGDungeonEntry const *dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
|
||||
dungeonId = (*GetPlayer()->GetLfgDungeons()->begin());
|
||||
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
|
||||
dungeonId = dungeon->Entry();
|
||||
data << uint32(dungeonId); // Dungeon
|
||||
data << uint8(pProp->state); // Result state
|
||||
|
||||
Reference in New Issue
Block a user