aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpp <none@none>2010-12-13 21:28:36 +0100
committerSpp <none@none>2010-12-13 21:28:36 +0100
commit865f35a63702d5ab723cfbc2ea5a5f3e76e2f344 (patch)
tree62dd4d8a593073d50309c5435c91a90d294bd7e3 /src
parent9815847511b131f8ae550a9594fdab37970a193a (diff)
Core/Dungeon Finder: Minor optimization in handler code
Note: LfgDungeonSet and LfgLockStatusMap were being used without using the existing typedef (to avoid including LFGMgr.h). Now those functions use a struct as param that is forward declared so still LFGMgr.h is not needed and redefinition of LfgDungeonSet/LfgLockStatusMap is removed. --HG-- branch : trunk
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/DungeonFinding/LFG.h1
-rwxr-xr-xsrc/server/game/DungeonFinding/LFGMgr.cpp147
-rwxr-xr-xsrc/server/game/DungeonFinding/LFGMgr.h21
-rw-r--r--src/server/game/DungeonFinding/LFGScripts.cpp25
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/LFGHandler.cpp101
-rwxr-xr-xsrc/server/game/Server/WorldSession.h9
6 files changed, 182 insertions, 122 deletions
diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h
index 5823970f795..cc5bb0e481b 100755
--- a/src/server/game/DungeonFinding/LFG.h
+++ b/src/server/game/DungeonFinding/LFG.h
@@ -32,6 +32,7 @@ enum LfgRoles
enum LfgUpdateType
{
+ LFG_UPDATETYPE_DEFAULT = 0, // Internal Use
LFG_UPDATETYPE_LEADER = 1,
LFG_UPDATETYPE_ROLECHECK_ABORTED = 4,
LFG_UPDATETYPE_JOIN_PROPOSAL = 5,
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 91926c99349..735c92fa921 100755
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -205,6 +205,10 @@ void LFGMgr::Update(uint32 diff)
time_t currTime = time(NULL);
// Remove obsolete role checks
+ LfgJoinResultData joinData;
+ joinData.result = LFG_JOIN_FAILED;
+ joinData.state = LFG_ROLECHECK_MISSING_ROLE;
+
for (LfgRoleCheckMap::iterator it = m_RoleChecks.begin(); it != m_RoleChecks.end();)
{
LfgRoleCheckMap::iterator itRoleCheck = it++;
@@ -220,7 +224,7 @@ void LFGMgr::Update(uint32 diff)
plr->ClearLfgState();
if (itRoles->first == pRoleCheck->leader)
- plr->GetSession()->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
+ plr->GetSession()->SendLfgJoinResult(joinData);
}
delete pRoleCheck;
m_RoleChecks.erase(itRoleCheck);
@@ -279,13 +283,14 @@ void LFGMgr::Update(uint32 diff)
if (Player* plr = sObjectMgr.GetPlayerByLowGUID(itPlayers->first))
{
plr->SetLfgState(LFG_STATE_PROPOSAL);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, plr->GetLfgDungeons(), plr->GetLfgComment());
if (plr->GetGroup())
{
plr->GetGroup()->SetLfgState(LFG_STATE_PROPOSAL);
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_PROPOSAL_BEGIN, plr->GetLfgDungeons(), plr->GetLfgComment());
+ plr->GetSession()->SendLfgUpdateParty(updateData);
}
else
- plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_PROPOSAL_BEGIN, plr->GetLfgDungeons(), plr->GetLfgComment());
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
plr->GetSession()->SendLfgUpdateProposal(m_lfgProposalId, pProposal);
}
}
@@ -425,7 +430,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
Group* grp = plr->GetGroup();
uint64 guid = plr->GetGUID();
uint64 gguid = grp ? grp->GetGUID() : guid;
- LfgJoinResult result = LFG_JOIN_OK;
+ LfgJoinResultData joinData;
PlayerSet players;
uint32 rDungeonId = 0;
bool isContinue = grp && grp->isLFGGroup() && grp->GetLfgState() != LFG_STATE_FINISHED_DUNGEON;
@@ -448,12 +453,13 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
if (sameDungeons) // Joining the same dungeons -- Send OK
{
- plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK);
+ plr->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK
if (grp)
{
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, comment);
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (itr->getSource() && itr->getSource()->GetSession())
- itr->getSource()->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, comment);
+ itr->getSource()->GetSession()->SendLfgUpdateParty(updateData);
}
}
else if (!isContinue) // Different dungeons and it's not an offer to continue
@@ -467,36 +473,36 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
// Check player or group member restrictions
if (plr->InBattleground() || plr->InArena() || plr->InBattlegroundQueue())
- result = LFG_JOIN_USING_BG_SYSTEM;
+ joinData.result = LFG_JOIN_USING_BG_SYSTEM;
else if (plr->HasAura(LFG_SPELL_DUNGEON_DESERTER))
- result = LFG_JOIN_DESERTER;
+ joinData.result = LFG_JOIN_DESERTER;
else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
- result = LFG_JOIN_RANDOM_COOLDOWN;
+ joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
else if (!dungeons.size())
- result = LFG_JOIN_NOT_MEET_REQS;
+ joinData.result = LFG_JOIN_NOT_MEET_REQS;
else if (grp)
{
if (grp->GetMembersCount() > MAXGROUPSIZE)
- result = LFG_JOIN_TOO_MUCH_MEMBERS;
+ joinData.result = LFG_JOIN_TOO_MUCH_MEMBERS;
else
{
uint8 memberCount = 0;
- for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next())
+ for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && joinData.result == LFG_JOIN_OK; itr = itr->next())
{
if (Player* plrg = itr->getSource())
{
if (plrg->HasAura(LFG_SPELL_DUNGEON_DESERTER))
- result = LFG_JOIN_PARTY_DESERTER;
+ joinData.result = LFG_JOIN_PARTY_DESERTER;
else if (plrg->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
- result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
+ joinData.result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
else if (plrg->InBattleground() || plrg->InArena() || plrg->InBattlegroundQueue())
- result = LFG_JOIN_USING_BG_SYSTEM;
+ joinData.result = LFG_JOIN_USING_BG_SYSTEM;
++memberCount;
players.insert(plrg);
}
}
if (memberCount != grp->GetMembersCount())
- result = LFG_JOIN_DISCONNECTED;
+ joinData.result = LFG_JOIN_DISCONNECTED;
}
}
else
@@ -504,32 +510,32 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
// Check if all dungeons are valid
bool isRaid = false;
- if (result == LFG_JOIN_OK)
+ if (joinData.result == LFG_JOIN_OK)
{
bool isDungeon = false;
- for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && result == LFG_JOIN_OK; ++it)
+ for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end() && joinData.result == LFG_JOIN_OK; ++it)
{
switch(GetDungeonType(*it))
{
case LFG_TYPE_RANDOM:
if (dungeons.size() > 1) // Only allow 1 random dungeon
- result = LFG_JOIN_DUNGEON_INVALID;
+ joinData.result = LFG_JOIN_DUNGEON_INVALID;
else
rDungeonId = (*dungeons.begin());
// No break on purpose (Random can only be dungeon or heroic dungeon)
case LFG_TYPE_HEROIC:
case LFG_TYPE_DUNGEON:
if (isRaid)
- result = LFG_JOIN_MIXED_RAID_DUNGEON;
+ joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
isDungeon = true;
break;
case LFG_TYPE_RAID:
if (isDungeon)
- result = LFG_JOIN_MIXED_RAID_DUNGEON;
+ joinData.result = LFG_JOIN_MIXED_RAID_DUNGEON;
isRaid = true;
break;
default:
- result = LFG_JOIN_DUNGEON_INVALID;
+ joinData.result = LFG_JOIN_DUNGEON_INVALID;
break;
}
}
@@ -538,27 +544,28 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
if (rDungeonId)
dungeons = GetDungeonsByRandom(rDungeonId);
- LfgLockStatusMap* lockStatusMap = CheckCompatibleDungeons(dungeons, players);
+ joinData.lockmap = CheckCompatibleDungeons(dungeons, players);
if (!dungeons.size())
{
+ joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: LFG_JOIN_PARTY_NOT_MEET_REQS", guid, uint8(players.size()));
- plr->GetSession()->SendLfgJoinResult(LFG_JOIN_PARTY_NOT_MEET_REQS, 0, lockStatusMap);
+ plr->GetSession()->SendLfgJoinResult(joinData);
}
- if (lockStatusMap)
+ if (joinData.lockmap)
{
- for (LfgLockStatusMap::iterator it = lockStatusMap->begin(); it != lockStatusMap->end(); ++it)
+ for (LfgLockStatusMap::iterator it = joinData.lockmap->begin(); it != joinData.lockmap->end(); ++it)
delete it->second;
- delete lockStatusMap;
+ delete joinData.lockmap;
}
if (!dungeons.size())
return;
}
// Can't join. Send result
- if (result != LFG_JOIN_OK)
+ if (joinData.result != LFG_JOIN_OK)
{
- sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, result);
- plr->GetSession()->SendLfgJoinResult(result);
+ sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, joinData.result);
+ plr->GetSession()->SendLfgJoinResult(joinData);
return;
}
@@ -591,11 +598,12 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
grp->SetLfgState(LFG_STATE_ROLECHECK);
// Send update to player
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player* plrg = itr->getSource())
{
- plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
+ plrg->GetSession()->SendLfgUpdateParty(updateData);
plrg->SetLfgState(LFG_STATE_ROLECHECK);
if (!isContinue)
{
@@ -612,8 +620,9 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
else // Add player to queue
{
// Send update to player
- plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK);
- plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, &dungeons, comment);
+ plr->GetSession()->SendLfgJoinResult(joinData);
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
plr->SetLfgState(LFG_STATE_QUEUED);
if (!isContinue)
{
@@ -674,21 +683,24 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
switch(state)
{
case LFG_STATE_QUEUED:
- RemoveFromQueue(guid);
- if (grp)
{
- grp->RestoreLfgState();
- for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
- if (Player* plrg = itr->getSource())
- {
- plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
- plrg->ClearLfgState();
- }
- }
- else
- {
- plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
- plr->ClearLfgState();
+ RemoveFromQueue(guid);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
+ if (grp)
+ {
+ grp->RestoreLfgState();
+ for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
+ if (Player* plrg = itr->getSource())
+ {
+ plrg->GetSession()->SendLfgUpdateParty(updateData);
+ plrg->ClearLfgState();
+ }
+ }
+ else
+ {
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
+ plr->ClearLfgState();
+ }
}
break;
case LFG_STATE_ROLECHECK:
@@ -1031,6 +1043,9 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
else
dungeons = pRoleCheck->dungeons;
+ LfgJoinResultData joinData;
+ joinData.result = LFG_JOIN_FAILED;
+ joinData.state = pRoleCheck->result;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* plrg = itr->getSource();
@@ -1048,14 +1063,20 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
case LFG_ROLECHECK_INITIALITING:
continue;
case LFG_ROLECHECK_FINISHED:
- plrg->SetLfgState(LFG_STATE_QUEUED);
- session->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, plrg->GetLfgComment());
+ {
+ plrg->SetLfgState(LFG_STATE_QUEUED);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, plrg->GetLfgComment());
+ session->SendLfgUpdateParty(updateData);
+ }
break;
default:
- if (grp->GetLeaderGUID() == plrg->GetGUID())
- session->SendLfgJoinResult(LFG_JOIN_FAILED, pRoleCheck->result);
- session->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED);
- plrg->ClearLfgState();
+ {
+ if (grp->GetLeaderGUID() == plrg->GetGUID())
+ session->SendLfgJoinResult(joinData);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ROLECHECK_FAILED);
+ session->SendLfgUpdateParty(updateData);
+ plrg->ClearLfgState();
+ }
break;
}
}
@@ -1334,6 +1355,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept)
}
// Create a new group (if needed)
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND);
Group* grp = pProposal->groupLowGuid ? sObjectMgr.GetGroupByGUID(pProposal->groupLowGuid) : NULL;
for (LfgPlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
{
@@ -1343,12 +1365,12 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept)
plr->GetSession()->SendLfgUpdateProposal(proposalId, pProposal);
if (group)
{
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_FOUND);
+ plr->GetSession()->SendLfgUpdateParty(updateData);
if (group != grp)
plr->RemoveFromGroup();
}
else
- plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_GROUP_FOUND);
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
if (!grp)
{
@@ -1460,37 +1482,38 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
{
- LfgUpdateType updateType;
+ LfgUpdateData updateData;
if (it->second->accept == LFG_ANSWER_DENY)
{
- updateType = type;
+ updateData.updateType = type;
sLog.outDebug("LFGMgr::RemoveProposal: [" UI64FMTD "] didn't accept. Removing from queue and compatible cache", guid);
}
else
{
- updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
+ updateData.updateType = LFG_UPDATETYPE_REMOVED_FROM_QUEUE;
sLog.outDebug("LFGMgr::RemoveProposal: [" UI64FMTD "] in same group that someone that didn't accept. Removing from queue and compatible cache", guid);
}
plr->ClearLfgState();
if (grp)
{
grp->RestoreLfgState();
- plr->GetSession()->SendLfgUpdateParty(updateType);
+ plr->GetSession()->SendLfgUpdateParty(updateData);
}
else
- plr->GetSession()->SendLfgUpdatePlayer(updateType);
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
}
else
{
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, plr->GetLfgDungeons(), plr->GetLfgComment());
sLog.outDebug("LFGMgr::RemoveProposal: Readding [" UI64FMTD "] to queue.", guid);
plr->SetLfgState(LFG_STATE_QUEUED);
if (grp)
{
grp->SetLfgState(LFG_STATE_QUEUED);
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ADDED_TO_QUEUE, plr->GetLfgDungeons(), plr->GetLfgComment());
+ plr->GetSession()->SendLfgUpdateParty(updateData);
}
else
- plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_ADDED_TO_QUEUE, plr->GetLfgDungeons(), plr->GetLfgComment());
+ plr->GetSession()->SendLfgUpdatePlayer(updateData);
}
}
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index 75b5f0bee23..ea87cd6623f 100755
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -113,6 +113,7 @@ enum LfgJoinResult
/// Role check states
enum LfgRoleCheckState
{
+ LFG_ROLECHECK_DEFAULT = 0, // Internal use = Not initialized.
LFG_ROLECHECK_FINISHED = 1, // Role check finished
LFG_ROLECHECK_INITIALITING = 2, // Role check begins
LFG_ROLECHECK_MISSING_ROLE = 3, // Someone didn't selected a role after 2 mins
@@ -165,6 +166,26 @@ struct LfgLockStatus
LfgLockStatusType lockstatus; ///< Lock type
};
+// Data needed by SMSG_LFG_JOIN_RESULT
+struct LfgJoinResultData
+{
+ LfgJoinResultData(): result(LFG_JOIN_OK), state(LFG_ROLECHECK_DEFAULT), lockmap(NULL) {}
+ LfgJoinResult result;
+ LfgRoleCheckState state;
+ LfgLockStatusMap* lockmap;
+};
+
+// Data needed by SMSG_LFG_UPDATE_PARTY and SMSG_LFG_UPDATE_PLAYER
+struct LfgUpdateData
+{
+ LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT, LfgDungeonSet* _dungeons = NULL, std::string _comment = ""):
+ updateType(_type), dungeons(_dungeons), comment(_comment) {}
+
+ LfgUpdateType updateType;
+ LfgDungeonSet* dungeons;
+ std::string comment;
+};
+
/// Reward info
struct LfgReward
{
diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp
index d9f81435e93..555ead9b8c4 100644
--- a/src/server/game/DungeonFinding/LFGScripts.cpp
+++ b/src/server/game/DungeonFinding/LFGScripts.cpp
@@ -36,12 +36,13 @@ void LFGScripts::OnAddMember(Group* group, uint64 guid)
return;
sLog.outDebug("LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "]", gguid, guid);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
- plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
- plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
+ plrg->GetSession()->SendLfgUpdatePlayer(updateData);
+ plrg->GetSession()->SendLfgUpdateParty(updateData);
}
}
@@ -90,7 +91,8 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod& method,
*/
plr->ClearLfgState();
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER);
+ plr->GetSession()->SendLfgUpdateParty(updateData);
if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon
sLFGMgr.TeleportPlayer(plr, true);
}
@@ -111,12 +113,18 @@ void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLe
sLog.outDebug("LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
Player *plr = sObjectMgr.GetPlayer(newLeaderGuid);
+
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER);
if (plr)
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
+ plr->GetSession()->SendLfgUpdateParty(updateData);
+
plr = sObjectMgr.GetPlayer(oldLeaderGuid);
if (plr)
- plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
+ {
+ updateData.updateType = LFG_UPDATETYPE_GROUP_DISBAND;
+ plr->GetSession()->SendLfgUpdateParty(updateData);
+ }
}
void LFGScripts::OnInviteMember(Group* group, uint64 guid)
@@ -137,12 +145,13 @@ void LFGScripts::OnLevelChanged(Player* /*player*/, uint8 /*newLevel*/)
void LFGScripts::OnLogout(Player* player)
{
sLFGMgr.Leave(player);
- player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
- player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
+ LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
+ player->GetSession()->SendLfgUpdateParty(updateData);
+ player->GetSession()->SendLfgUpdatePlayer(updateData);
player->GetSession()->SendLfgUpdateSearch(false);
}
void LFGScripts::OnLogin(Player* /*player*/)
{
// TODO - Restore LfgPlayerData and send proper status to player if it was in a group
-} \ No newline at end of file
+}
diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
index 7e65b02b1af..afaeac66d09 100755
--- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
@@ -281,30 +281,32 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket &recv_data)
//sLFGMgr.LeaveLfr(GetPlayer(), dungeonId);
}
-void WorldSession::SendLfgUpdatePlayer(uint8 updateType, LfgDungeonSet* dungeons /* = NULL */, std::string comment /* = "" */)
+void WorldSession::SendLfgUpdatePlayer(LfgUpdateData& updateData)
{
bool queued = false;
bool extrainfo = false;
- switch(updateType)
+ switch(updateData.updateType)
{
- case LFG_UPDATETYPE_JOIN_PROPOSAL:
- case LFG_UPDATETYPE_ADDED_TO_QUEUE:
- queued = true;
- extrainfo = true;
- break;
- //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences...
- case LFG_UPDATETYPE_PROPOSAL_BEGIN:
- extrainfo = true;
- break;
+ case LFG_UPDATETYPE_JOIN_PROPOSAL:
+ case LFG_UPDATETYPE_ADDED_TO_QUEUE:
+ queued = true;
+ extrainfo = true;
+ break;
+ //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences...
+ case LFG_UPDATETYPE_PROPOSAL_BEGIN:
+ extrainfo = true;
+ break;
+ default:
+ break;
}
uint64 guid = GetPlayer()->GetGUID();
- uint8 size = dungeons ? dungeons->size() : 0;
+ uint8 size = updateData.dungeons ? updateData.dungeons->size() : 0;
- sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateType);
- 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
+ sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType);
+ WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
+ data << uint8(updateData.updateType); // Lfg Update type
data << uint8(extrainfo); // Extra info
if (extrainfo)
{
@@ -314,45 +316,47 @@ void WorldSession::SendLfgUpdatePlayer(uint8 updateType, LfgDungeonSet* dungeons
data << uint8(size);
if (size)
- for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
+ for (LfgDungeonSet::const_iterator it = updateData.dungeons->begin(); it != updateData.dungeons->end(); ++it)
data << uint32(*it);
- data << comment;
+ data << updateData.comment;
}
SendPacket(&data);
}
-void WorldSession::SendLfgUpdateParty(uint8 updateType, LfgDungeonSet* dungeons /* = NULL */, std::string comment /* = "" */)
+void WorldSession::SendLfgUpdateParty(LfgUpdateData& updateData)
{
bool join = false;
bool extrainfo = false;
bool queued = false;
- switch(updateType)
+ switch(updateData.updateType)
{
- case LFG_UPDATETYPE_JOIN_PROPOSAL:
- extrainfo = true;
- break;
- case LFG_UPDATETYPE_ADDED_TO_QUEUE:
- extrainfo = true;
- join = true;
- queued = true;
- break;
- case LFG_UPDATETYPE_CLEAR_LOCK_LIST:
- // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences...
- queued = true;
- break;
- case LFG_UPDATETYPE_PROPOSAL_BEGIN:
- extrainfo = true;
- join = true;
- break;
+ case LFG_UPDATETYPE_JOIN_PROPOSAL:
+ extrainfo = true;
+ break;
+ case LFG_UPDATETYPE_ADDED_TO_QUEUE:
+ extrainfo = true;
+ join = true;
+ queued = true;
+ break;
+ case LFG_UPDATETYPE_CLEAR_LOCK_LIST:
+ // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences...
+ queued = true;
+ break;
+ case LFG_UPDATETYPE_PROPOSAL_BEGIN:
+ extrainfo = true;
+ join = true;
+ break;
+ default:
+ break;
}
uint64 guid = GetPlayer()->GetGUID();
- uint8 size = dungeons ? dungeons->size() : 0;
+ uint8 size = updateData.dungeons ? updateData.dungeons->size() : 0;
- sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateType);
- 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
+ sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType);
+ WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
+ data << uint8(updateData.updateType); // Lfg Update type
data << uint8(extrainfo); // Extra info
if (extrainfo)
{
@@ -365,9 +369,9 @@ void WorldSession::SendLfgUpdateParty(uint8 updateType, LfgDungeonSet* dungeons
data << uint8(size);
if (size)
- for (LfgDungeonSet::const_iterator it = dungeons->begin(); it != dungeons->end(); ++it)
+ for (LfgDungeonSet::const_iterator it = updateData.dungeons->begin(); it != updateData.dungeons->end(); ++it)
data << uint32(*it);
- data << comment;
+ data << updateData.comment;
}
SendPacket(&data);
}
@@ -439,20 +443,21 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
SendPacket(&data);
}
-void WorldSession::SendLfgJoinResult(uint8 checkResult, uint8 checkValue /* = 0 */, LfgLockStatusMap* playersLockMap /* = NULL */)
+void WorldSession::SendLfgJoinResult(LfgJoinResultData& joinData)
{
uint32 size = 0;
- if (playersLockMap)
+ if (joinData.lockmap)
{
- for (LfgLockStatusMap::const_iterator it = playersLockMap->begin(); it != playersLockMap->end(); ++it)
+ for (LfgLockStatusMap::const_iterator it = joinData.lockmap->begin(); it != joinData.lockmap->end(); ++it)
size += 8 + 4 + it->second->size() * (4 + 4);
}
- sLog.outDebug("SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), checkResult, checkValue);
+ sLog.outDebug("SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state);
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
- data << uint32(checkResult); // Check Result
- data << uint32(checkValue); // Check Value
- BuildPartyLockDungeonBlock(data, playersLockMap);
+ data << uint32(joinData.result); // Check Result
+ data << uint32(joinData.state); // Check Value
+ if (joinData.lockmap)
+ BuildPartyLockDungeonBlock(data, joinData.lockmap);
SendPacket(&data);
}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 083d4c0786d..657e4f1ba36 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -48,12 +48,13 @@ class CharacterHandler;
class SpellCastTargets;
struct AreaTableEntry;
struct GM_Ticket;
+struct LfgJoinResultData;
struct LfgLockStatus;
struct LfgPlayerBoot;
struct LfgProposal;
struct LfgReward;
struct LfgRoleCheck;
-
+struct LfgUpdateData;
enum AccountDataType
{
@@ -730,12 +731,12 @@ class WorldSession
void HandleLfrSearchOpcode(WorldPacket &recv_data);
void HandleLfrLeaveOpcode(WorldPacket &recv_data);
- void SendLfgUpdatePlayer(uint8 updateType, std::set<uint32>* dungeons = NULL, std::string comment = "");
- void SendLfgUpdateParty(uint8 updateType, std::set<uint32>* dungeons = NULL, std::string comment = "");
+ void SendLfgUpdatePlayer(LfgUpdateData& updateData);
+ void SendLfgUpdateParty(LfgUpdateData& updateData);
void SendLfgRoleChosen(uint64 guid, uint8 roles);
void SendLfgRoleCheckUpdate(LfgRoleCheck *pRoleCheck);
void SendLfgUpdateSearch(bool update);
- void SendLfgJoinResult(uint8 checkResult, uint8 checkValue = 0, std::map<uint32, std::set<LfgLockStatus*>*> *playersLockMap = NULL);
+ void SendLfgJoinResult(LfgJoinResultData& joinData);
void SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgWaitTime, int32 waitTimeTanks, int32 waitTimeHealer, int32 waitTimeDps, uint32 queuedTime, uint8 tanks, uint8 healers, uint8 dps);
void SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward *reward, const Quest *qRew);
void SendLfgBootPlayer(LfgPlayerBoot *pBoot);