Dungeon Finder: minor improvements and code clean-ups

- Initialize all packet size properly
- Updated all function documentation
- Add placeholders to all LFG opcodes
- Use lowguids wherever is possible

--HG--
branch : trunk
This commit is contained in:
Spp
2010-08-11 13:25:14 +02:00
parent ac4df5204b
commit 23c4b1be25
6 changed files with 231 additions and 170 deletions

View File

@@ -20,6 +20,7 @@
#include "SharedDefines.h"
#include "Group.h"
#include "Player.h"
#include "SocialMgr.h"
#include "LFGMgr.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
@@ -54,6 +55,9 @@ LFGMgr::~LFGMgr()
delete it->second;
m_RoleChecks.clear();
for (LfgDungeonMap::iterator it = m_CachedDungeonMap.begin(); it != m_CachedDungeonMap.end(); ++it)
delete it->second;
m_CachedDungeonMap.clear();
m_QueueInfoMap.clear();
m_currentQueue.clear();
m_newToQueue.clear();
@@ -188,18 +192,13 @@ void LFGMgr::InitLFG()
m_RewardDoneList.push_back(reward);
}
// Initialize dungeonMap
m_DungeonsMap[LFG_ALL_DUNGEONS] = GetAllDungeons();
m_DungeonsMap[LFG_RANDOM_CLASSIC] = GetDungeonsByRandom(LFG_RANDOM_CLASSIC);
m_DungeonsMap[LFG_RANDOM_BC_NORMAL] = GetDungeonsByRandom(LFG_RANDOM_BC_NORMAL);
m_DungeonsMap[LFG_RANDOM_BC_HEROIC] = GetDungeonsByRandom(LFG_RANDOM_BC_HEROIC);
m_DungeonsMap[LFG_RANDOM_LK_NORMAL] = GetDungeonsByRandom(LFG_RANDOM_LK_NORMAL);
m_DungeonsMap[LFG_RANDOM_LK_HEROIC] = GetDungeonsByRandom(LFG_RANDOM_LK_HEROIC);
GetAllDungeons();
}
/// <summary>
/// Adds the player to lfg queue
/// Adds the player/group to lfg queue
/// </summary>
/// <param name="plr">Player</param>
/// <param name="Player *">Player</param>
void LFGMgr::Join(Player *plr)
{
Group *grp = plr->GetGroup();
@@ -609,7 +608,6 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag /*= true
return tank == LFG_TANKS_NEEDED && healer == LFG_HEALERS_NEEDED && damage == LFG_DPS_NEEDED;
}
// --------------------------------------------------------------------------//
// Packet Functions
// --------------------------------------------------------------------------//
@@ -617,9 +615,8 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag /*= true
/// <summary>
/// Build lfgRolecheck packet
/// </summary>
/// <param name="data">WorldPacket</param>
/// <param name="plr">Player</param>
/// <param name="status">Player status in LFG system</param>
/// <param name="WorldPacket &">WorldPacket</param>
/// <param name="LfgRoleCheck *">RoleCheck info</param>
void LFGMgr::BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck)
{
ASSERT(pRoleCheck);
@@ -640,14 +637,12 @@ void LFGMgr::BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck)
data << uint8(pRoleCheck->roles.size()); // Players in group
// Leader info MUST be sent 1st :S
roles = pRoleCheck->roles[pRoleCheck->leader];
data << uint64(pRoleCheck->leader); // Guid
uint64 guid = MAKE_NEW_GUID(pRoleCheck->leader, 0, HIGHGUID_PLAYER);
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
plr = sObjectMgr.GetPlayer(pRoleCheck->leader);
if (plr)
data << uint8(plr->getLevel()); // Level
else
data << uint8(0);
plr = sObjectMgr.GetPlayer(guid);
data << uint8(plr ? plr->getLevel() : 0); // Level
for (LfgRolesMap::const_iterator itPlayers = pRoleCheck->roles.begin(); itPlayers != pRoleCheck->roles.end(); ++itPlayers)
{
@@ -655,43 +650,58 @@ void LFGMgr::BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck)
continue;
roles = itPlayers->second;
data << uint64(itPlayers->first); // Guid
guid = MAKE_NEW_GUID(itPlayers->first, 0, HIGHGUID_PLAYER);
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
plr = sObjectMgr.GetPlayer(pRoleCheck->leader);
if (plr)
data << uint8(plr->getLevel()); // Level
else
data << uint8(0);
plr = sObjectMgr.GetPlayer(guid);
data << uint8(plr ? plr->getLevel() : 0); // Level
}
}
/// <summary>
/// Build and Send LFG lock player info and reward
/// </summary>
/// <param name="plr">Player</param>
/// <param name="Player *">Player</param>
void LFGMgr::SendLfgPlayerInfo(Player *plr)
{
uint32 rsize = 0;
uint32 lsize = 0;
bool done;
LfgDungeonSet *randomlist = GetRandomDungeons(plr->getLevel(), plr->GetSession()->Expansion());
LfgLockStatusSet *lockSet = GetPlayerLockStatusDungeons(plr, m_DungeonsMap[LFG_ALL_DUNGEONS]);
LfgLockStatusSet *lockSet = GetPlayerLockStatusDungeons(plr, GetAllDungeons());
if (randomlist)
rsize = randomlist->size();
if (lockSet)
lsize = lockSet->size();
sLog.outDebug("SMSG_LFG_PLAYER_INFO");
WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (4 + 4));
WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4));
if (!randomlist)
data << uint8(0);
else
{
LfgReward *reward;
data << uint8(randomlist->size()); // Random Dungeon count
for (LfgDungeonSet::iterator it = randomlist->begin(); it != randomlist->end(); ++it)
{
done = plr->isLfgDungeonDone(*it);
reward = GetRandomDungeonReward(*it, done, plr->getLevel());
data << uint32(*it); // Entry
BuildRewardBlock(data, *it, plr);
data << uint8(done);
data << uint32(reward->baseMoney);
data << uint32(reward->baseXP);
data << uint32(reward->variableMoney);
data << uint32(reward->variableXP);
data << uint8(reward->itemId != 0);
if (reward->itemId)
{
data << uint32(reward->itemId);
data << uint32(reward->displayId);
data << uint32(reward->stackCount);
}
}
randomlist->clear();
delete randomlist;
@@ -703,10 +713,10 @@ void LFGMgr::SendLfgPlayerInfo(Player *plr)
/// <summary>
/// Build and Send LFG lock party info and reward
/// </summary>
/// <param name="plr">Player</param>
/// <param name="Player *">Player</param>
void LFGMgr::SendLfgPartyInfo(Player *plr)
{
if (LfgLockStatusMap *lockMap = GetPartyLockStatusDungeons(plr, m_DungeonsMap[LFG_ALL_DUNGEONS]))
if (LfgLockStatusMap *lockMap = GetPartyLockStatusDungeons(plr, GetAllDungeons()))
{
uint32 size = 0;
for (LfgLockStatusMap::const_iterator it = lockMap->begin(); it != lockMap->end(); ++it)
@@ -718,41 +728,11 @@ void LFGMgr::SendLfgPartyInfo(Player *plr)
}
}
/// <summary>
/// Build Reward packet structure for a given dungeon
/// </summary>
/// <param name="data">WorldPacket</param>
/// <param name="dungeon">Dungeon entry</param>
/// <param name="plr">Player</param>
void LFGMgr::BuildRewardBlock(WorldPacket &data, uint32 dungeon, Player *plr)
{
bool done = plr->isLfgDungeonDone(dungeon);
LfgReward *reward = GetRandomDungeonReward(dungeon, done, plr->getLevel());
if (!reward)
return;
data << uint8(done);
if (data.GetOpcode() == SMSG_LFG_PLAYER_REWARD)
data << uint32(reward->strangers);
data << uint32(reward->baseMoney);
data << uint32(reward->baseXP);
data << uint32(reward->variableMoney);
data << uint32(reward->variableXP);
data << uint8(reward->itemId != 0);
if (reward->itemId)
{
data << uint32(reward->itemId);
data << uint32(reward->displayId);
data << uint32(reward->stackCount);
}
}
/// <summary>
/// Build Party Dungeon lock status packet
/// </summary>
/// <param name="data">WorldPacket</param>
/// <param name="lock">lock status map</param>
/// <param name="WorldPacket &">WorldPacket</param>
/// <param name="LfgLockStatusMap *">lock status map</param>
void LFGMgr::BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *lockMap)
{
ASSERT(lockMap);
@@ -760,15 +740,13 @@ void LFGMgr::BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *loc
data << uint8(lockMap->size());
LfgLockStatusSet *lockSet;
uint64 guid;
for (LfgLockStatusMap::const_iterator it = lockMap->begin(); it != lockMap->end(); ++it)
{
guid = it->first;
lockSet = it->second;
if (!lockSet)
continue;
data << uint64(guid); // Player guid
data << uint64(MAKE_NEW_GUID(it->first, 0, HIGHGUID_PLAYER)); // Player guid
BuildPlayerLockDungeonBlock(data, lockSet);
}
lockMap->clear();
@@ -778,8 +756,8 @@ void LFGMgr::BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *loc
/// <summary>
/// Build Player Dungeon lock status packet
/// </summary>
/// <param name="data">WorldPacket</param>
/// <param name="lock">lock status list</param>
/// <param name="WorldPacket &">WorldPacket</param>
/// <param name="LfgLockStatusSet *">lock status list</param>
void LFGMgr::BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet)
{
ASSERT(lockSet);
@@ -794,40 +772,28 @@ void LFGMgr::BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lo
delete lockSet;
}
// --------------------------------------------------------------------------//
// Auxiliar Functions
// --------------------------------------------------------------------------//
/// <summary>
/// Get all Group members list of dungeons that can't be done and reason
/// leader excluded as the list given is he list he can do
/// Given a group get the dungeons that can't be done and reason
/// </summary>
/// <param name="grp">Group</param>
/// <param name="dungeons">Dungeons to check</param>
/// <param name="PlayerSet *">Players to check lock status</param>
/// <param name="LfgDungeonSet *">Dungeons to check</param>
/// <returns>LfgLockStatusMap*</returns>
LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons)
LfgLockStatusMap* LFGMgr::GetGroupLockStatusDungeons(PlayerSet *pPlayers, LfgDungeonSet *dungeons)
{
ASSERT(plr);
ASSERT(pPlayers);
ASSERT(dungeons);
Group *grp = plr->GetGroup();
if (!grp)
return NULL;
Player *plrg;
LfgLockStatusSet *dungeonSet = NULL;
LfgLockStatusMap *dungeonMap = new LfgLockStatusMap();
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
for (PlayerSet::const_iterator itr = pPlayers->begin(); itr != pPlayers->end(); ++itr)
{
plrg = itr->getSource();
if (!plrg || plrg == plr)
continue;
dungeonSet = GetPlayerLockStatusDungeons(plrg, dungeons);
dungeonSet = GetPlayerLockStatusDungeons(*itr, dungeons);
if (dungeonSet)
(*dungeonMap)[plrg->GetGUID()] = dungeonSet;
(*dungeonMap)[(*itr)->GetGUID()] = dungeonSet;
}
if (!dungeonMap->size())
@@ -838,11 +804,40 @@ LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet
return dungeonMap;
}
/// <summary>
/// Get all Group members list of dungeons that can't be done and reason
/// leader excluded as the list given is he list he can do
/// </summary>
/// <param name="Player *">Player to get Party Lock info</param>
/// <param name="LfgDungeonSet *">Dungeons to check</param>
/// <returns>LfgLockStatusMap*</returns>
LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons)
{
ASSERT(plr);
ASSERT(dungeons);
Group *grp = plr->GetGroup();
if (!grp)
return NULL;
PlayerSet *pPlayers = new PlayerSet();
Player *plrg;
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
plrg = itr->getSource();
if (plrg && plrg != plr)
pPlayers->insert(plrg);
}
LfgLockStatusMap *dungeonMap = GetGroupLockStatusDungeons(pPlayers, dungeons);
pPlayers->clear();
delete pPlayers;
return dungeonMap;
}
/// <summary>
/// Get list of dungeons player can't do and reasons
/// </summary>
/// <param name="plr">Player</param>
/// <param name="dungeons">Dungeons to check</param>
/// <param name="Player *">Player to check lock status</param>
/// <param name="LfgDungeonSet *">Dungeons to check</param>
/// <returns>LfgLockStatusSet*</returns>
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons)
{
@@ -906,58 +901,55 @@ LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet
/// <returns>LfgDungeonSet*</returns>
LfgDungeonSet* LFGMgr::GetAllDungeons()
{
LfgDungeonSet *dungeons = new LfgDungeonSet();
LfgDungeonSet *alldungeons = m_CachedDungeonMap[0];
if (alldungeons)
return alldungeons;
LfgDungeonSet *dungeons;
LFGDungeonEntry const *dungeon;
alldungeons = new LfgDungeonSet();
m_CachedDungeonMap[0] = alldungeons;
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
{
dungeon = sLFGDungeonStore.LookupEntry(i);
if (!dungeon || dungeon->type == LFG_TYPE_ZONE)
continue;
dungeons->insert(dungeon->ID);
dungeons = m_CachedDungeonMap[dungeon->grouptype];
if (!dungeons)
{
dungeons = new LfgDungeonSet();
m_CachedDungeonMap[dungeon->grouptype] = dungeons;
}
if (dungeon->type != LFG_TYPE_RANDOM)
dungeons->insert(dungeon->ID);
alldungeons->insert(dungeon->ID);
}
if (!dungeons->size())
{
delete dungeons;
return NULL;
}
else
return dungeons;
return alldungeons;
}
/// <summary>
/// Get the dungeon list that can be done given a random dungeon entry.
/// Special case: randomdungeon == 0 then will return all dungeons
/// </summary>
/// <param name="randomdungeon">Random dungeon entry</param>
/// <param name="uint32">Random dungeon entry</param>
/// <returns>LfgDungeonSet*</returns>
LfgDungeonSet* LFGMgr::GetDungeonsByRandom(uint32 randomdungeon)
{
LFGDungeonEntry const *dungeon = sLFGDungeonStore.LookupEntry(randomdungeon);
if (!dungeon)
return NULL;
uint8 groupType = 0;
if (LFGDungeonEntry const *dungeon = sLFGDungeonStore.LookupEntry(randomdungeon))
groupType = dungeon->grouptype;
uint32 grouptype = dungeon->grouptype;
LfgDungeonSet *random = new LfgDungeonSet();
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
{
dungeon = sLFGDungeonStore.LookupEntry(i);
if (!dungeon || dungeon->type == LFG_TYPE_RANDOM || dungeon->grouptype != grouptype)
continue;
random->insert(dungeon->ID);
}
if (!random->size())
{
delete random;
return NULL;
}
else
return random;
return m_CachedDungeonMap[groupType];
}
/// <summary>
/// Get the random dungeon list that can be done at a certain level and expansion.
/// </summary>
/// <param name="level">Player level</param>
/// <param name="expansion">Player account expansion</param>
/// <param name="uint8">Player level</param>
/// <param name="uint8">Player account expansion</param>
/// <returns>LfgDungeonSet*</returns>
LfgDungeonSet* LFGMgr::GetRandomDungeons(uint8 level, uint8 expansion)
{
@@ -974,11 +966,12 @@ LfgDungeonSet* LFGMgr::GetRandomDungeons(uint8 level, uint8 expansion)
}
/// <summary>
/// Get the reward of a given random dungeon
/// Get the reward of a given random dungeon at a certain level
/// </summary>
/// <param name="dungeon">random dungeon id</param>
/// <param name="done">Dungeon previously done</param>
/// <returns></returns>
/// <param name="uint32">random dungeon id</param>
/// <param name="bool">Dungeon previously done</param>
/// <param name="uint8">Player level</param>
/// <returns>LfgReward*</returns>
LfgReward* LFGMgr::GetRandomDungeonReward(uint32 dungeon, bool done, uint8 level)
{
uint8 index = 0;
@@ -1022,7 +1015,7 @@ LfgReward* LFGMgr::GetRandomDungeonReward(uint32 dungeon, bool done, uint8 level
/// <summary>
/// Given a Dungeon id returns the dungeon Group Type
/// </summary>
/// <param name="dungeonId">Dungeon id</param>
/// <param name="uint32">Dungeon id</param>
/// <returns>uint8: GroupType</returns>
uint8 LFGMgr::GetDungeonGroupType(uint32 dungeonId)
{

View File

@@ -47,6 +47,7 @@ enum LfgType
enum LfgGroupType
{
LFG_GROUPTYPE_ALL = 0, // Internal use, represents all groups.
LFG_GROUPTYPE_CLASSIC = 1,
LFG_GROUPTYPE_BC_NORMAL = 2,
LFG_GROUPTYPE_BC_HEROIC = 3,
@@ -107,6 +108,7 @@ enum LfgRoleCheckResult
LFG_ROLECHECK_NO_ROLE = 6, // Someone selected no role
};
// TODO: Remove me, will not be needed when Reward moved to quest system
enum LfgRandomDungeonEntries
{
LFG_ALL_DUNGEONS = 0,
@@ -182,15 +184,10 @@ struct LfgReward
uint32 stackCount;
};
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
typedef std::vector<LfgReward*> LfgRewardList;
typedef std::map<uint64, LfgLockStatusSet*> LfgLockStatusMap;
typedef std::map<uint32, LfgDungeonSet*> LfgDungeonMap;
typedef std::map<uint64, int8> LfgAnswerMap;
typedef std::map<uint32, uint8> LfgRolesMap;
typedef std::map<uint32, int8> LfgAnswerMap;
typedef std::list<uint64> LfgGuidList;
typedef std::map<uint64, uint8> LfgRolesMap;
typedef std::set<uint64> LfgGuidSet;
typedef std::map<uint32, LfgDungeonSet*> LfgDungeonMap;
// Stores player or group queue info
struct LfgQueueInfo
@@ -211,56 +208,63 @@ struct LfgRoleCheck
LfgRolesMap roles;
LfgRoleCheckResult result;
LfgDungeonSet dungeons;
uint64 leader;
uint32 leader;
};
typedef std::set<Player*> PlayerSet;
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
typedef std::vector<LfgReward*> LfgRewardList;
typedef std::map<uint32, LfgReward*> LfgRewardMap;
typedef std::map<uint32, LfgLockStatusSet*> LfgLockStatusMap;
typedef std::map<uint64, LfgQueueInfo*> LfgQueueInfoMap;
typedef std::map<uint32, LfgRoleCheck*> LfgRoleCheckMap;
typedef std::list<Player *> LfgPlayerList;
class LFGMgr
{
friend class ACE_Singleton<LFGMgr, ACE_Null_Mutex>;
LFGMgr();
public:
~LFGMgr();
LFGMgr();
~LFGMgr();
void InitLFG();
void SendLfgPlayerInfo(Player *plr);
void SendLfgPartyInfo(Player *plr);
void Join(Player *plr);
void Leave(Player *plr, Group *grp = NULL);
void UpdateRoleCheck(Group *grp, Player *plr = NULL);
void Update(uint32 diff);
void SendLfgPlayerInfo(Player *plr);
void SendLfgPartyInfo(Player *plr);
private:
void BuildLfgRoleCheck(WorldPacket &data, LfgRoleCheck *pRoleCheck);
void BuildAvailableRandomDungeonList(WorldPacket &data, Player *plr);
void BuildRewardBlock(WorldPacket &data, uint32 dungeon, Player *plr);
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet *lockSet);
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap *lockMap);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
void AddToQueue(uint64 guid, LfgRolesMap *roles, LfgDungeonSet *dungeons);
bool RemoveFromQueue(uint64 guid);
bool isRandomDungeon(uint32 dungeonId);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet *pPlayers, LfgDungeonSet *dungeons);
LfgLockStatusMap* GetPartyLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player *plr, LfgDungeonSet *dungeons);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
LfgDungeonSet* GetAllDungeons();
LfgReward* GetRandomDungeonReward(uint32 dungeon, bool done, uint8 level);
uint8 GetDungeonGroupType(uint32 dungeon);
LfgRewardList m_RewardList;
LfgRewardList m_RewardDoneList;
LfgDungeonMap m_DungeonsMap;
LfgRewardList m_RewardList; // TODO: Change it to list of quests
LfgRewardList m_RewardDoneList; // TODO: Change it to list of quests
LfgDungeonMap m_CachedDungeonMap; // Stores all dungeons by groupType
LfgQueueInfoMap m_QueueInfoMap; // Queued groups
LfgGuidList m_currentQueue; // Ordered list. Used to find groups
LfgGuidList m_newToQueue; // New groups to add to queue;
LfgRoleCheckMap m_RoleChecks; // Current Role checks
uint32 m_QueueTimer; // used to check interval of update
uint32 m_lfgProposalId; // used as internal counter for proposals
int32 m_avgWaitTime;
int32 m_waitTimeTanks;
int32 m_waitTimeHealer;

View File

@@ -63,25 +63,29 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
void WorldSession::HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/)
{
sLog.outDebug("CMSG_LFG_LEAVE");
Group *grp = GetPlayer()->GetGroup();
// Check cheating - only leader can leave the queue
if (Group *grp = GetPlayer()->GetGroup())
{
if (grp->GetLeaderGUID() != GetPlayer()->GetGUID())
return;
else
sLFGMgr.Leave(GetPlayer(), grp);
}
else
if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID())
sLFGMgr.Leave(GetPlayer());
}
void WorldSession::HandleLfgProposalResultOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_LFG_PROPOSAL_RESULT");
uint32 lfgGroupID; // Internal lfgGroupID
uint8 accept; // Accept to join?
recv_data >> lfgGroupID;
recv_data >> accept;
}
void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_LFG_SET_ROLES");
uint8 roles;
recv_data >> roles; // Player Group Roles
recv_data >> roles; // Player Group Roles
Group *grp = GetPlayer()->GetGroup();
if (!grp)
@@ -100,6 +104,22 @@ void WorldSession::HandleSetLfgCommentOpcode(WorldPacket & recv_data)
GetPlayer()->SetLfgComment(comment);
}
void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_LFG_SET_BOOT_VOTE");
uint8 agree; // Agree to kick player
recv_data >> agree;
}
void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_LFG_TELEPORT");
bool out;
recv_data >> out;
}
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
{
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST");
@@ -109,7 +129,22 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket &/*recv_data*/)
{
sLog.outDebug("CMSG_LFD_PARTY_LOCK_INFO_REQUEST");
sLFGMgr.SendLfgPartyInfo(GetPlayer());
}
void WorldSession::HandleLfrSearchOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_SEARCH_LFG_JOIN");
uint32 entry; // Raid id to search
recv_data >> entry;
}
void WorldSession::HandleLfrLeaveOpcode(WorldPacket &recv_data)
{
sLog.outDebug("CMSG_SEARCH_LFG_LEAVE");
uint32 dungeonId; // Raid id queue to leave
recv_data >> dungeonId;
}
void WorldSession::SendLfgUpdatePlayer(uint8 updateType)
@@ -207,7 +242,7 @@ void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles)
{
sLog.outDebug("SMSG_LFG_ROLE_CHOSEN");
WorldPacket data(SMSG_LFG_ROLE_CHOSEN);
WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4);
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
@@ -221,7 +256,7 @@ void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue)
sLog.outDebug("SMSG_LFG_JOIN_RESULT");
WorldPacket data(SMSG_LFG_JOIN_RESULT);
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4);
data << uint32(checkResult); // Check Result
data << uint32(checkValue); // Check Value
SendPacket(&data);
@@ -230,7 +265,7 @@ void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue)
void WorldSession::SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgWaitTime, int32 waitTimeTanks, int32 waitTimeHealer, int32 waitTimeDps, uint32 queuedTime, uint8 tanks, uint8 healers, uint8 dps)
{
sLog.outDebug("SMSG_LFG_QUEUE_STATUS");
WorldPacket data(SMSG_LFG_QUEUE_STATUS);
WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4);
data << uint32(dungeon); // Dungeon
data << uint32(avgWaitTime); // Average Wait time
@@ -249,7 +284,32 @@ void WorldSession::SendLfgUpdateSearch(bool update)
{
sLog.outDebug("SMSG_LFG_UPDATE_SEARCH");
WorldPacket data(SMSG_LFG_UPDATE_SEARCH);
WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1);
data << uint8(update); // In Lfg Queue?
SendPacket(&data);
}
void WorldSession::SendLfgDisabled()
{
sLog.outDebug("SMSG_LFG_DISABLED");
WorldPacket data(SMSG_LFG_DISABLED, 0);
SendPacket(&data);
}
void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry)
{
sLog.outDebug("SMSG_LFG_OFFER_CONTINUE");
WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4);
data << uint32(dungeonEntry);
SendPacket(&data);
}
void WorldSession::SendLfgTeleportError(uint8 err)
{
sLog.outDebug("SMSG_LFG_TELEPORT_DENIED");
WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4);
data << uint32(err); // Error
SendPacket(&data);
}

View File

@@ -890,11 +890,11 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x35B*/ { "SMSG_ARENA_TEAM_STATS", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x35C*/ { "CMSG_LFG_JOIN", STATUS_LOGGEDIN, &WorldSession::HandleLfgJoinOpcode },
/*0x35D*/ { "CMSG_LFG_LEAVE", STATUS_LOGGEDIN, &WorldSession::HandleLfgLeaveOpcode },
/*0x35E*/ { "CMSG_SEARCH_LFG_JOIN", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x35F*/ { "CMSG_SEARCH_LFG_LEAVE", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x35E*/ { "CMSG_SEARCH_LFG_JOIN", STATUS_LOGGEDIN, &WorldSession::HandleLfrSearchOpcode },
/*0x35F*/ { "CMSG_SEARCH_LFG_LEAVE", STATUS_LOGGEDIN, &WorldSession::HandleLfrLeaveOpcode },
/*0x360*/ { "SMSG_UPDATE_LFG_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x361*/ { "SMSG_LFG_PROPOSAL_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x362*/ { "CMSG_LFG_PROPOSAL_RESULT", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x362*/ { "CMSG_LFG_PROPOSAL_RESULT", STATUS_LOGGEDIN, &WorldSession::HandleLfgProposalResultOpcode },
/*0x363*/ { "SMSG_LFG_ROLE_CHECK_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x364*/ { "SMSG_LFG_JOIN_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x365*/ { "SMSG_LFG_QUEUE_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide },
@@ -904,11 +904,11 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x369*/ { "SMSG_LFG_UPDATE_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x36A*/ { "CMSG_LFG_SET_ROLES", STATUS_LOGGEDIN, &WorldSession::HandleLfgSetRolesOpcode },
/*0x36B*/ { "CMSG_LFG_SET_NEEDS", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x36C*/ { "CMSG_LFG_SET_BOOT_VOTE", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x36C*/ { "CMSG_LFG_SET_BOOT_VOTE", STATUS_LOGGEDIN, &WorldSession::HandleLfgSetBootVoteOpcode },
/*0x36D*/ { "SMSG_LFG_BOOT_PROPOSAL_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x36E*/ { "CMSG_LFD_PLAYER_LOCK_INFO_REQUEST", STATUS_LOGGEDIN, &WorldSession::HandleLfgPlayerLockInfoRequestOpcode},
/*0x36F*/ { "SMSG_LFG_PLAYER_INFO", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x370*/ { "CMSG_LFG_TELEPORT", STATUS_LOGGEDIN, &WorldSession::Handle_NULL },
/*0x370*/ { "CMSG_LFG_TELEPORT", STATUS_LOGGEDIN, &WorldSession::HandleLfgTeleportOpcode },
/*0x371*/ { "CMSG_LFD_PARTY_LOCK_INFO_REQUEST", STATUS_LOGGEDIN, &WorldSession::HandleLfgPartyLockInfoRequestOpcode},
/*0x372*/ { "SMSG_LFG_PARTY_INFO", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x373*/ { "SMSG_TITLE_EARNED", STATUS_NEVER, &WorldSession::Handle_ServerSide },

View File

@@ -47,8 +47,7 @@
/// WorldSession constructor
WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) :
LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time),
_player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion),
m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion),
m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)),
_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false),
m_latency(0), m_TutorialsChanged(false), m_timeOutTime(0)

View File

@@ -270,10 +270,6 @@ class WorldSession
void SendNotInArenaTeamPacket(uint8 type);
void SendPetitionShowList(uint64 guid);
void SendSaveGuildEmblem(uint32 msg);
// Looking For Group
// TRUE values set by client sending CMSG_LFG_SET_AUTOJOIN and CMSG_LFM_CLEAR_AUTOFILL before player login
bool LookingForGroup_auto_join;
bool LookingForGroup_auto_add;
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data);
@@ -705,12 +701,21 @@ class WorldSession
void HandleLfgJoinOpcode(WorldPacket &recv_data);
void HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/);
void HandleLfgSetRolesOpcode(WorldPacket &recv_data);
void HandleLfgProposalResultOpcode(WorldPacket &recv_data);
void HandleLfgSetBootVoteOpcode(WorldPacket &recv_data);
void HandleLfgTeleportOpcode(WorldPacket &recv_data);
void HandleLfrSearchOpcode(WorldPacket &recv_data);
void HandleLfrLeaveOpcode(WorldPacket &recv_data);
void SendLfgUpdatePlayer(uint8 updateType);
void SendLfgUpdateParty(uint8 updateType);
void SendLfgRoleChosen(uint64 guid, uint8 roles);
void SendLfgUpdateSearch(bool update);
void SendLfgJoinResult(uint8 checkResult, uint8 checkValue);
void SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgWaitTime, int32 waitTimeTanks, int32 waitTimeHealer, int32 waitTimeDps, uint32 queuedTime, uint8 tanks, uint8 healers, uint8 dps);
void SendLfgDisabled();
void SendLfgOfferContinue(uint32 dungeonEntry);
void SendLfgTeleportError(uint8 err);
// Arena Team
void HandleInspectArenaTeamsOpcode(WorldPacket& recv_data);