Core/Dungeon Finder: Multiple changes

- Simplify lock status calculations by caching player locked dungeons
- Fix incorrect Lfg State loading for groups
- All reference variables that are supposed not to be modified are declared as const
- Use full group guids in rolechecks
- Add some debug msgs
- Fix some warnings

--HG--
branch : trunk
This commit is contained in:
Spp
2010-12-21 22:33:17 +01:00
parent 68ed96989a
commit 0c44943cd2
10 changed files with 423 additions and 487 deletions
+6 -6
View File
@@ -26,7 +26,7 @@ enum LfgRoles
ROLE_LEADER = 0x01, ROLE_LEADER = 0x01,
ROLE_TANK = 0x02, ROLE_TANK = 0x02,
ROLE_HEALER = 0x04, ROLE_HEALER = 0x04,
ROLE_DAMAGE = 0x08, ROLE_DAMAGE = 0x08
}; };
enum LfgUpdateType enum LfgUpdateType
@@ -44,7 +44,7 @@ enum LfgUpdateType
LFG_UPDATETYPE_PROPOSAL_BEGIN = 13, LFG_UPDATETYPE_PROPOSAL_BEGIN = 13,
LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14, LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14,
LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15, LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15,
LFG_UPDATETYPE_GROUP_DISBAND = 16, LFG_UPDATETYPE_GROUP_DISBAND = 16
}; };
enum LfgState enum LfgState
@@ -56,7 +56,7 @@ enum LfgState
LFG_STATE_BOOT, // Vote kick active LFG_STATE_BOOT, // Vote kick active
LFG_STATE_DUNGEON, // In LFG Group, in a Dungeon LFG_STATE_DUNGEON, // In LFG Group, in a Dungeon
LFG_STATE_FINISHED_DUNGEON, // In LFG Group, in a finished Dungeon LFG_STATE_FINISHED_DUNGEON, // In LFG Group, in a finished Dungeon
LFG_STATE_RAIDBROWSER, // Using Raid finder LFG_STATE_RAIDBROWSER // Using Raid finder
}; };
/// Instance lock types /// Instance lock types
@@ -73,7 +73,7 @@ enum LfgLockStatusType
LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL = 1002, LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL = 1002,
LFG_LOCKSTATUS_QUEST_NOT_COMPLETED = 1022, LFG_LOCKSTATUS_QUEST_NOT_COMPLETED = 1022,
LFG_LOCKSTATUS_MISSING_ITEM = 1025, LFG_LOCKSTATUS_MISSING_ITEM = 1025,
LFG_LOCKSTATUS_NOT_IN_SEASON = 1031, LFG_LOCKSTATUS_NOT_IN_SEASON = 1031
}; };
/// Dungeon and reason why player can't join /// Dungeon and reason why player can't join
@@ -84,7 +84,7 @@ struct LfgLockStatus
}; };
typedef std::set<uint32> LfgDungeonSet; typedef std::set<uint32> LfgDungeonSet;
typedef std::set<LfgLockStatus*> LfgLockStatusSet; typedef std::map<uint32, LfgLockStatusType> LfgLockMap;
typedef std::map<uint64, LfgLockStatusSet*> LfgLockStatusMap; typedef std::map<uint64, LfgLockMap> LfgLockPartyMap;
#endif #endif
@@ -18,13 +18,12 @@
#ifndef _LFGGROUPDATA_H #ifndef _LFGGROUPDATA_H
#define _LFGGROUPDATA_H #define _LFGGROUPDATA_H
#include "Common.h"
#include "LFG.h" #include "LFG.h"
enum LfgGroupEnum enum LfgGroupEnum
{ {
LFG_GROUP_MAX_KICKS = 3, LFG_GROUP_MAX_KICKS = 3,
LFG_GROUP_KICK_VOTES_NEEDED = 3, LFG_GROUP_KICK_VOTES_NEEDED = 3
}; };
/** /**
+151 -205
View File
@@ -292,7 +292,8 @@ void LFGMgr::Update(uint32 diff)
if (Player* plr = sObjectMgr.GetPlayer(itPlayers->first)) if (Player* plr = sObjectMgr.GetPlayer(itPlayers->first))
{ {
Group *grp = plr->GetGroup(); Group *grp = plr->GetGroup();
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, &GetSelectedDungeons(guid), GetComment(guid)); LfgDungeonSet dungeons = GetSelectedDungeons(guid);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, &dungeons, GetComment(guid));
if (grp) if (grp)
{ {
uint64 gguid = grp->GetGUID(); uint64 gguid = grp->GetGUID();
@@ -375,7 +376,7 @@ void LFGMgr::Update(uint32 diff)
@param[in] guid Player or group guid to add to queue @param[in] guid Player or group guid to add to queue
@param[in] queueId Queue Id to add player/group to @param[in] queueId Queue Id to add player/group to
*/ */
void LFGMgr::AddToQueue(uint64& guid, uint8 queueId) void LFGMgr::AddToQueue(const uint64& guid, uint8 queueId)
{ {
if (sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) if (sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
queueId = 0; queueId = 0;
@@ -396,7 +397,7 @@ void LFGMgr::AddToQueue(uint64& guid, uint8 queueId)
@param[in] guid Player or group guid to add to queue @param[in] guid Player or group guid to add to queue
@return true if guid was found in main queue. @return true if guid was found in main queue.
*/ */
bool LFGMgr::RemoveFromQueue(uint64& guid) bool LFGMgr::RemoveFromQueue(const uint64& guid)
{ {
for (LfgGuidListMap::iterator it = m_currentQueue.begin(); it != m_currentQueue.end(); ++it) for (LfgGuidListMap::iterator it = m_currentQueue.begin(); it != m_currentQueue.end(); ++it)
it->second.remove(guid); it->second.remove(guid);
@@ -422,6 +423,73 @@ bool LFGMgr::RemoveFromQueue(uint64& guid)
} }
/**
Generate the dungeon lock map for a given player
@param[in] plr Player we need to initialize the lock status map
*/
void LFGMgr::InitializeLockedDungeons(Player* plr)
{
uint64 guid = plr->GetGUID();
LfgLockMap cachedLockMap = GetLockedDungeons(guid);
if (!cachedLockMap.empty())
return;
uint8 level = plr->getLevel();
uint8 expansion = plr->GetSession()->Expansion();
LfgDungeonSet dungeons = GetDungeonsByRandom(0);
LfgLockMap lock;
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
{
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
continue;
AccessRequirement const* ar = sObjectMgr.GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
LfgLockStatusType locktype = LFG_LOCKSTATUS_OK;
if (dungeon->expansion > expansion)
locktype = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION;
else if (sDisableMgr.IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && plr->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
else if (dungeon->minlevel > level)
locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
else if (dungeon->maxlevel < level)
locktype = LFG_LOCKSTATUS_TOO_HIGH_LEVEL;
else if (locktype == LFG_LOCKSTATUS_OK && ar)
{
if (ar->achievement && !plr->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED; // FIXME: Check the correct lock value
else if (plr->GetTeam() == ALLIANCE && ar->quest_A && !plr->GetQuestRewardStatus(ar->quest_A))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
else if (plr->GetTeam() == HORDE && ar->quest_H && !plr->GetQuestRewardStatus(ar->quest_H))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
else
if (ar->item)
{
if (!plr->HasItemCount(ar->item, 1) && (!ar->item2 || !plr->HasItemCount(ar->item2, 1)))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
else if (ar->item2 && !plr->HasItemCount(ar->item2, 1))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
/* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
locktype = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
locktype = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
locktype = LFG_LOCKSTATUS_NOT_IN_SEASON; // Need list of instances and needed season to open
*/
if (locktype != LFG_LOCKSTATUS_OK)
lock[dungeon->Entry()] = locktype;
}
SetLockedDungeons(guid, lock);
}
/** /**
Adds the player/group to lfg queue. If player is in a group then it is the leader Adds the player/group to lfg queue. If player is in a group then it is the leader
of the group tying to join the group. Join conditions are checked before adding of the group tying to join the group. Join conditions are checked before adding
@@ -432,9 +500,9 @@ bool LFGMgr::RemoveFromQueue(uint64& guid)
@param[in] dungeons Dungeons the player/group is applying for @param[in] dungeons Dungeons the player/group is applying for
@param[in] comment Player selected comment @param[in] comment Player selected comment
*/ */
void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string& comment) void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment)
{ {
if (!plr || !plr->GetSession() || !dungeons.size()) if (!plr || !plr->GetSession() || !selectedDungeons.size())
return; return;
Group* grp = plr->GetGroup(); Group* grp = plr->GetGroup();
@@ -444,6 +512,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
PlayerSet players; PlayerSet players;
uint32 rDungeonId = 0; uint32 rDungeonId = 0;
bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON; bool isContinue = grp && grp->isLFGGroup() && GetState(gguid) != LFG_STATE_FINISHED_DUNGEON;
LfgDungeonSet dungeons = selectedDungeons;
// Do not allow to change dungeon in the middle of a current dungeon // Do not allow to change dungeon in the middle of a current dungeon
if (isContinue) if (isContinue)
@@ -551,23 +620,15 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
dungeons = GetDungeonsByRandom(rDungeonId); dungeons = GetDungeonsByRandom(rDungeonId);
// if we have lockmap then there are no compatible dungeons // if we have lockmap then there are no compatible dungeons
if (LfgLockStatusMap* lockStatusMap = GetCompatibleDungeons(dungeons, players)) GetCompatibleDungeons(dungeons, players, joinData.lockmap);
if (!joinData.lockmap.empty())
{ {
joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS; joinData.result = LFG_JOIN_PARTY_NOT_MEET_REQS;
joinData.lockmap = lockStatusMap;
sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: LFG_JOIN_PARTY_NOT_MEET_REQS", guid, uint8(players.size())); sLog.outDebug("LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: LFG_JOIN_PARTY_NOT_MEET_REQS", guid, uint8(players.size()));
plr->GetSession()->SendLfgJoinResult(joinData); plr->GetSession()->SendLfgJoinResult(joinData);
for (LfgLockStatusMap::iterator itLockMap = lockStatusMap->begin(); itLockMap != lockStatusMap->end(); ++itLockMap)
{
for (LfgLockStatusSet::iterator itLockSet = itLockMap->second->begin(); itLockSet != itLockMap->second->end(); ++itLockSet)
delete (*itLockSet);
delete itLockMap->second;
}
delete lockStatusMap;
joinData.lockmap = NULL;
return; return;
} }
joinData.lockmap.clear();
} }
// Can't join. Send result // Can't join. Send result
@@ -596,7 +657,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
pRoleCheck->leader = plr->GetGUID(); pRoleCheck->leader = plr->GetGUID();
pRoleCheck->dungeons = dungeons; pRoleCheck->dungeons = dungeons;
pRoleCheck->rDungeonId = rDungeonId; pRoleCheck->rDungeonId = rDungeonId;
m_RoleChecks[grp->GetLowGUID()] = pRoleCheck; m_RoleChecks[grp->GetGUID()] = pRoleCheck;
if (rDungeonId) if (rDungeonId)
{ {
@@ -616,7 +677,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string
SetState(pguid, LFG_STATE_ROLECHECK); SetState(pguid, LFG_STATE_ROLECHECK);
if (!isContinue) if (!isContinue)
SetSelectedDungeons(pguid, dungeons); SetSelectedDungeons(pguid, dungeons);
pRoleCheck->roles[plrg->GetGUID()] = 0; pRoleCheck->roles[pguid] = 0;
} }
} }
// Update leader role // Update leader role
@@ -926,9 +987,10 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
if (itOther == pqInfoMap.end()) if (itOther == pqInfoMap.end())
compatibleDungeons.insert(*itDungeon); compatibleDungeons.insert(*itDungeon);
} }
GetCompatibleDungeons(compatibleDungeons, players, false); LfgLockPartyMap lockMap;
GetCompatibleDungeons(compatibleDungeons, players, lockMap);
if (!compatibleDungeons.size()) if (compatibleDungeons.empty())
{ {
SetCompatibles(strGuids, false); SetCompatibles(strGuids, false);
return false; return false;
@@ -964,7 +1026,7 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
PlayerSet::const_iterator itPlayers = players.begin(); PlayerSet::const_iterator itPlayers = players.begin();
if (!leader) if (!leader)
{ {
uint8 pos = urand(0, players.size() - 1); uint8 pos = uint8(urand(0, players.size() - 1));
for (uint8 i = 0; i < pos; ++i) for (uint8 i = 0; i < pos; ++i)
++itPlayers; ++itPlayers;
leader = (*itPlayers)->GetGUID(); leader = (*itPlayers)->GetGUID();
@@ -1007,7 +1069,7 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
return; return;
LfgRolesMap check_roles; LfgRolesMap check_roles;
LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(grp->GetLowGUID()); LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(grp->GetGUID());
if (itRoleCheck == m_RoleChecks.end()) if (itRoleCheck == m_RoleChecks.end())
return; return;
@@ -1049,7 +1111,7 @@ void LFGMgr::UpdateRoleCheck(Group* grp, Player* plr /* = NULL*/, bool newRoleCh
if (!plrg) if (!plrg)
continue; continue;
uint64 pguid = plrg->GetGUID(); uint64 pguid = plrg->GetGUID();
team = plrg->GetTeam(); team = uint8(plrg->GetTeam());
WorldSession* session = plrg->GetSession(); WorldSession* session = plrg->GetSession();
if (!newRoleCheck && plr) if (!newRoleCheck && plr)
session->SendLfgRoleChosen(guid, roles); session->SendLfgRoleChosen(guid, roles);
@@ -1160,39 +1222,25 @@ LfgAnswer LFGMgr::GetCompatibles(std::string key)
@param[in,out] dungeons Dungeons to check restrictions @param[in,out] dungeons Dungeons to check restrictions
@param[in] players Set of players to check their dungeon restrictions @param[in] players Set of players to check their dungeon restrictions
@param[in] returnLockMap Determines when to return a function value (Default true) @param[in] returnLockMap Determines when to return a function value (Default true)
@return Map of players Lock status info of given dungeons (NULL if dungeons is not empty) @param[out] Map of players Lock status info of given dungeons
*/ */
LfgLockStatusMap* LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, PlayerSet& players, bool returnLockMap /* = true */) void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, const PlayerSet& players, LfgLockPartyMap& lockMap)
{ {
if (!dungeons.size()) for (PlayerSet::const_iterator it = players.begin(); it != players.end() && dungeons.size(); ++it)
return NULL;
LfgLockStatusMap* pLockDungeons = GetGroupLockStatusDungeons(players, dungeons, false);
if (pLockDungeons) // Found dungeons not compatible, remove them from the set
{ {
for (LfgLockStatusMap::const_iterator itLockMap = pLockDungeons->begin(); itLockMap != pLockDungeons->end() && dungeons.size(); ++itLockMap) uint64 guid = (*it)->GetGUID();
LfgLockMap cachedLockMap = GetLockedDungeons(guid);
for(LfgLockMap::const_iterator it = cachedLockMap.begin(); it != cachedLockMap.end() && dungeons.size(); ++it)
{ {
for(LfgLockStatusSet::const_iterator itLockSet = itLockMap->second->begin(); itLockSet != itLockMap->second->end() && dungeons.size(); ++itLockSet) uint32 dungeonId = (it->first & 0x00FFFFFF); // Compare dungeon ids
{ LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
LfgDungeonSet::iterator itDungeon = dungeons.find((*itLockSet)->dungeon);
if (itDungeon != dungeons.end()) if (itDungeon != dungeons.end())
{
dungeons.erase(itDungeon); dungeons.erase(itDungeon);
lockMap[guid][dungeonId] = it->second;
} }
} }
if (!returnLockMap || !dungeons.empty())
{
for (LfgLockStatusMap::iterator itLockMap = pLockDungeons->begin(); itLockMap != pLockDungeons->end(); ++itLockMap)
{
for (LfgLockStatusSet::iterator itLockSet = itLockMap->second->begin(); itLockSet != itLockMap->second->end(); ++itLockSet)
delete (*itLockSet);
delete itLockMap->second;
} }
delete pLockDungeons;
pLockDungeons = NULL;
}
}
return pLockDungeons;
} }
/** /**
@@ -1505,7 +1553,8 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
} }
else else
{ {
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, &GetSelectedDungeons(guid), GetComment(guid)); LfgDungeonSet dungeons = GetSelectedDungeons(guid);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, &dungeons, GetComment(guid));
sLog.outDebug("LFGMgr::RemoveProposal: Readding [" UI64FMTD "] to queue.", guid); sLog.outDebug("LFGMgr::RemoveProposal: Readding [" UI64FMTD "] to queue.", guid);
SetState(guid, LFG_STATE_QUEUED); SetState(guid, LFG_STATE_QUEUED);
if (grp) if (grp)
@@ -1545,7 +1594,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
@param[in] victim Victim guid @param[in] victim Victim guid
@param[in] reason Kick reason @param[in] reason Kick reason
*/ */
void LFGMgr::InitBoot(Group* grp, uint64& kicker, uint64& victim, std::string reason) void LFGMgr::InitBoot(Group* grp, const uint64& kicker, const uint64& victim, std::string reason)
{ {
if (!grp) if (!grp)
return; return;
@@ -1763,7 +1812,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
} }
if (error != LFG_TELEPORTERROR_OK) if (error != LFG_TELEPORTERROR_OK)
plr->GetSession()->SendLfgTeleportError(error); plr->GetSession()->SendLfgTeleportError(uint8(error));
} }
/** /**
@@ -1841,151 +1890,17 @@ void LFGMgr::RewardDungeonDoneFor(const uint32 /*dungeonId*/, Player* player)
// Auxiliar Functions // Auxiliar Functions
// --------------------------------------------------------------------------// // --------------------------------------------------------------------------//
/**
Get all Group members list of all dungeons that can't be done and reason
leader excluded as the list given is he list he can do
@param[in] plr Players to check group lock status
@returns Map of player's group dungeon Lock status
*/
LfgLockStatusMap* LFGMgr::GetPartyLockStatusDungeons(Player* plr)
{
Group* grp = plr->GetGroup();
if (!grp)
return NULL;
PlayerSet players;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* plrg = itr->getSource();
if (plrg && plrg != plr)
players.insert(plrg);
}
LfgDungeonSet allDungeons = GetDungeonsByRandom(0);
return GetGroupLockStatusDungeons(players, allDungeons, true);
}
/**
Get list of all dungeons player can't do and reasons
@param[in] plr Players to check dungeon lock status
@returns Set of player's dungeon Lock status
*/
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr)
{
LfgDungeonSet allDungeons = GetDungeonsByRandom(0);
return GetPlayerLockStatusDungeons(plr, allDungeons, true);
}
/**
Given a group get the dungeons that can't be done and reason
@param[in] players Players to check lock status
@param[in] dungeons Dungeons to check
@param[in] useEntry Use dungeon entry (true) or id (false)
@returns Map of player's dungeon Lock status
*/
LfgLockStatusMap* LFGMgr::GetGroupLockStatusDungeons(PlayerSet& players, LfgDungeonSet& dungeons, bool useEntry)
{
LfgLockStatusMap* dungeonMap = new LfgLockStatusMap();
for (PlayerSet::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (LfgLockStatusSet* dungeonSet = GetPlayerLockStatusDungeons(*itr, dungeons, useEntry))
(*dungeonMap)[(*itr)->GetGUID()] = dungeonSet;
if (!dungeonMap->size())
{
delete dungeonMap;
dungeonMap = NULL;
}
return dungeonMap;
}
/**
Given a list of dungeon return the list of dungeons player can't do and reasons
@param[in] plr Players to check dungeon lock status
@param[in] dungeons Dungeons to check (Default = NULL, means check all dungeons)
@param[in] useEntry Use dungeon entry (true) or id (false)
@returns Set of player's dungeon Lock status
*/
LfgLockStatusSet* LFGMgr::GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet& dungeons, bool useEntry)
{
LfgLockStatusSet* list = new LfgLockStatusSet();
uint8 level = plr->getLevel();
uint8 expansion = plr->GetSession()->Expansion();
for (LfgDungeonSet::const_iterator it = dungeons.begin(); it != dungeons.end(); ++it)
{
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
if (!dungeon) // should never happen - We provide a list from sLFGDungeonStore
continue;
AccessRequirement const* ar = sObjectMgr.GetAccessRequirement(dungeon->map, Difficulty(dungeon->difficulty));
LfgLockStatusType locktype = LFG_LOCKSTATUS_OK;
if (dungeon->expansion > expansion)
locktype = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION;
else if (sDisableMgr.IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && plr->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
else if (dungeon->minlevel > level)
locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
else if (dungeon->maxlevel < level)
locktype = LFG_LOCKSTATUS_TOO_HIGH_LEVEL;
else if (locktype == LFG_LOCKSTATUS_OK && ar)
{
if (ar->achievement && !plr->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED; // FIXME: Check the correct lock value
else if (plr->GetTeam() == ALLIANCE && ar->quest_A && !plr->GetQuestRewardStatus(ar->quest_A))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
else if (plr->GetTeam() == HORDE && ar->quest_H && !plr->GetQuestRewardStatus(ar->quest_H))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
else
if (ar->item)
{
if (!plr->HasItemCount(ar->item, 1) && (!ar->item2 || !plr->HasItemCount(ar->item2, 1)))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
else if (ar->item2 && !plr->HasItemCount(ar->item2, 1))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
/* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
locktype = LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE;
locktype = LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL;
locktype = LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL;
locktype = LFG_LOCKSTATUS_NOT_IN_SEASON; // Need list of instances and needed season to open
*/
if (locktype != LFG_LOCKSTATUS_OK)
{
LfgLockStatus* lockstatus = new LfgLockStatus();
lockstatus->dungeon = useEntry ? dungeon->Entry(): dungeon->ID;
lockstatus->lockstatus = locktype;
list->insert(lockstatus);
}
}
if (!list->size())
{
delete list;
list = NULL;
}
return list;
}
/** /**
Get the dungeon list that can be done given a random dungeon entry. Get the dungeon list that can be done given a random dungeon entry.
@param[in] randomdungeon Random dungeon id (if value = 0 will return all dungeons) @param[in] randomdungeon Random dungeon id (if value = 0 will return all dungeons)
@returns Set of dungeons that can be done. @returns Set of dungeons that can be done.
*/ */
LfgDungeonSet LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon)
{ {
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(randomdungeon); LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(randomdungeon);
uint8 groupType = dungeon ? dungeon->grouptype : 0; uint32 groupType = dungeon ? dungeon->grouptype : 0;
return m_CachedDungeonMap[groupType]; // Return a copy return m_CachedDungeonMap[groupType];
} }
/** /**
@@ -2060,94 +1975,125 @@ std::string LFGMgr::ConcatenateGuids(LfgGuidList check)
} }
LfgState LFGMgr::GetState(uint64& guid) LfgState LFGMgr::GetState(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetState: [" UI64FMTD "]", guid);
if (IS_GROUP(guid))
return m_Groups[guid].GetState();
else
return m_Players[guid].GetState(); return m_Players[guid].GetState();
} }
uint32 LFGMgr::GetDungeon(uint64& guid, bool asId /*= true*/) uint32 LFGMgr::GetDungeon(const uint64& guid, bool asId /*= true*/)
{ {
sLog.outDebug("LFGMgr::GetDungeon: [" UI64FMTD "] asId: %u", guid, asId);
return m_Groups[guid].GetDungeon(asId); return m_Groups[guid].GetDungeon(asId);
} }
uint8 LFGMgr::GetRoles(uint64& guid) uint8 LFGMgr::GetRoles(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetRoles: [" UI64FMTD "]", guid);
return m_Players[guid].GetRoles(); return m_Players[guid].GetRoles();
} }
const std::string& LFGMgr::GetComment(uint64& guid) const std::string& LFGMgr::GetComment(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetComment: [" UI64FMTD "]", guid);
return m_Players[guid].GetComment(); return m_Players[guid].GetComment();
} }
LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64& guid) const LfgDungeonSet& LFGMgr::GetSelectedDungeons(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid);
return m_Players[guid].GetSelectedDungeons(); return m_Players[guid].GetSelectedDungeons();
} }
uint8 LFGMgr::GetKicksLeft(uint64& guid) const LfgLockMap& LFGMgr::GetLockedDungeons(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid);
return m_Players[guid].GetLockedDungeons();
}
uint8 LFGMgr::GetKicksLeft(const uint64& guid)
{
sLog.outDebug("LFGMgr::GetKicksLeft: [" UI64FMTD "]", guid);
return m_Groups[guid].GetKicksLeft(); return m_Groups[guid].GetKicksLeft();
} }
uint8 LFGMgr::GetVotesNeeded(uint64& guid) uint8 LFGMgr::GetVotesNeeded(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::GetVotesNeeded: [" UI64FMTD "]", guid);
return m_Groups[guid].GetVotesNeeded(); return m_Groups[guid].GetVotesNeeded();
} }
void LFGMgr::RestoreState(const uint64& guid)
void LFGMgr::RestoreState(uint64& guid)
{ {
sLog.outDebug("LFGMgr::RestoreState: [" UI64FMTD "]", guid);
m_Groups[guid].RestoreState(); m_Groups[guid].RestoreState();
} }
void LFGMgr::ClearState(uint64& guid) void LFGMgr::ClearState(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::ClearState: [" UI64FMTD "]", guid);
m_Players[guid].ClearState(); m_Players[guid].ClearState();
} }
void LFGMgr::SetState(uint64& guid, LfgState state) void LFGMgr::SetState(const uint64& guid, LfgState state)
{ {
sLog.outDebug("LFGMgr::SetState: [" UI64FMTD "] state %u", guid, state);
if (IS_GROUP(guid)) if (IS_GROUP(guid))
m_Groups[guid].SetState(state); m_Groups[guid].SetState(state);
else else
m_Players[guid].SetState(state); m_Players[guid].SetState(state);
} }
void LFGMgr::SetDungeon(uint64& guid, uint32 dungeon) void LFGMgr::SetDungeon(const uint64& guid, uint32 dungeon)
{ {
sLog.outDebug("LFGMgr::SetDungeon: [" UI64FMTD "] dungeon %u", guid, dungeon);
m_Groups[guid].SetDungeon(dungeon); m_Groups[guid].SetDungeon(dungeon);
} }
void LFGMgr::SetRoles(uint64& guid, uint8 roles) void LFGMgr::SetRoles(const uint64& guid, uint8 roles)
{ {
sLog.outDebug("LFGMgr::SetRoles: [" UI64FMTD "] roles: %u", guid, roles);
m_Players[guid].SetRoles(roles); m_Players[guid].SetRoles(roles);
} }
void LFGMgr::SetComment(uint64& guid, std::string& comment) void LFGMgr::SetComment(const uint64& guid, const std::string& comment)
{ {
sLog.outDebug("LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str());
m_Players[guid].SetComment(comment); m_Players[guid].SetComment(comment);
} }
void LFGMgr::SetSelectedDungeons(uint64& guid, LfgDungeonSet dungeons) void LFGMgr::SetSelectedDungeons(const uint64& guid, const LfgDungeonSet& dungeons)
{ {
sLog.outDebug("LFGMgr::SetSelectedDungeons: [" UI64FMTD "]", guid);
m_Players[guid].SetSelectedDungeons(dungeons); m_Players[guid].SetSelectedDungeons(dungeons);
} }
void LFGMgr::DecreaseKicksLeft(uint64& guid) void LFGMgr::SetLockedDungeons(const uint64& guid, const LfgLockMap& lock)
{ {
sLog.outDebug("LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid);
m_Players[guid].SetLockedDungeons(lock);
}
void LFGMgr::DecreaseKicksLeft(const uint64& guid)
{
sLog.outDebug("LFGMgr::DecreaseKicksLeft: [" UI64FMTD "]", guid);
m_Groups[guid].DecreaseKicksLeft(); m_Groups[guid].DecreaseKicksLeft();
} }
void LFGMgr::RemovePlayerData(uint64& guid) void LFGMgr::RemovePlayerData(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::RemovePlayerData: [" UI64FMTD "]", guid);
LfgPlayerDataMap::iterator it = m_Players.find(guid); LfgPlayerDataMap::iterator it = m_Players.find(guid);
if (it != m_Players.end()) if (it != m_Players.end())
m_Players.erase(it); m_Players.erase(it);
} }
void LFGMgr::RemoveGroupData(uint64& guid) void LFGMgr::RemoveGroupData(const uint64& guid)
{ {
sLog.outDebug("LFGMgr::RemoveGroupData: [" UI64FMTD "]", guid);
LfgGroupDataMap::iterator it = m_Groups.find(guid); LfgGroupDataMap::iterator it = m_Groups.find(guid);
if (it != m_Groups.end()) if (it != m_Groups.end())
m_Groups.erase(it); m_Groups.erase(it);
+43 -48
View File
@@ -38,7 +38,7 @@ enum LFGenum
LFG_QUEUEUPDATE_INTERVAL = 15*IN_MILLISECONDS, LFG_QUEUEUPDATE_INTERVAL = 15*IN_MILLISECONDS,
LFG_SPELL_DUNGEON_COOLDOWN = 71328, LFG_SPELL_DUNGEON_COOLDOWN = 71328,
LFG_SPELL_DUNGEON_DESERTER = 71041, LFG_SPELL_DUNGEON_DESERTER = 71041,
LFG_SPELL_LUCK_OF_THE_DRAW = 72221, LFG_SPELL_LUCK_OF_THE_DRAW = 72221
}; };
/// Determines the type of instance /// Determines the type of instance
@@ -50,7 +50,7 @@ enum LfgType
LFG_TYPE_QUEST = 3, LFG_TYPE_QUEST = 3,
LFG_TYPE_ZONE = 4, LFG_TYPE_ZONE = 4,
LFG_TYPE_HEROIC = 5, LFG_TYPE_HEROIC = 5,
LFG_TYPE_RANDOM = 6, LFG_TYPE_RANDOM = 6
}; };
/// Proposal states /// Proposal states
@@ -58,7 +58,7 @@ enum LfgProposalState
{ {
LFG_PROPOSAL_INITIATING = 0, LFG_PROPOSAL_INITIATING = 0,
LFG_PROPOSAL_FAILED = 1, LFG_PROPOSAL_FAILED = 1,
LFG_PROPOSAL_SUCCESS = 2, LFG_PROPOSAL_SUCCESS = 2
}; };
/// Teleport errors /// Teleport errors
@@ -69,7 +69,7 @@ enum LfgTeleportError
LFG_TELEPORTERROR_PLAYER_DEAD = 1, LFG_TELEPORTERROR_PLAYER_DEAD = 1,
LFG_TELEPORTERROR_FALLING = 2, LFG_TELEPORTERROR_FALLING = 2,
LFG_TELEPORTERROR_FATIGUE = 4, LFG_TELEPORTERROR_FATIGUE = 4,
LFG_TELEPORTERROR_INVALID_LOCATION = 6, LFG_TELEPORTERROR_INVALID_LOCATION = 6
}; };
/// Queue join results /// Queue join results
@@ -92,7 +92,7 @@ enum LfgJoinResult
LFG_JOIN_RANDOM_COOLDOWN = 14, // You can not queue for random dungeons while on random dungeon cooldown LFG_JOIN_RANDOM_COOLDOWN = 14, // You can not queue for random dungeons while on random dungeon cooldown
LFG_JOIN_PARTY_RANDOM_COOLDOWN = 15, // One or more party members are on random dungeon cooldown LFG_JOIN_PARTY_RANDOM_COOLDOWN = 15, // One or more party members are on random dungeon cooldown
LFG_JOIN_TOO_MUCH_MEMBERS = 16, // You can not enter dungeons with more that 5 party members LFG_JOIN_TOO_MUCH_MEMBERS = 16, // You can not enter dungeons with more that 5 party members
LFG_JOIN_USING_BG_SYSTEM = 17, // You can not use the dungeon system while in BG or arenas LFG_JOIN_USING_BG_SYSTEM = 17 // You can not use the dungeon system while in BG or arenas
}; };
/// Role check states /// Role check states
@@ -104,7 +104,7 @@ enum LfgRoleCheckState
LFG_ROLECHECK_MISSING_ROLE = 3, // Someone didn't selected a role after 2 mins LFG_ROLECHECK_MISSING_ROLE = 3, // Someone didn't selected a role after 2 mins
LFG_ROLECHECK_WRONG_ROLES = 4, // Can't form a group with that role selection LFG_ROLECHECK_WRONG_ROLES = 4, // Can't form a group with that role selection
LFG_ROLECHECK_ABORTED = 5, // Someone leave the group LFG_ROLECHECK_ABORTED = 5, // Someone leave the group
LFG_ROLECHECK_NO_ROLE = 6, // Someone selected no role LFG_ROLECHECK_NO_ROLE = 6 // Someone selected no role
}; };
/// Answer state (Also used to check compatibilites) /// Answer state (Also used to check compatibilites)
@@ -112,7 +112,7 @@ enum LfgAnswer
{ {
LFG_ANSWER_PENDING = -1, LFG_ANSWER_PENDING = -1,
LFG_ANSWER_DENY = 0, LFG_ANSWER_DENY = 0,
LFG_ANSWER_AGREE = 1, LFG_ANSWER_AGREE = 1
}; };
@@ -136,7 +136,7 @@ typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
typedef std::map<uint64, LfgDungeonSet> LfgDungeonMap; typedef std::map<uint64, LfgDungeonSet> LfgDungeonMap;
typedef std::map<uint64, uint8> LfgRolesMap; typedef std::map<uint64, uint8> LfgRolesMap;
typedef std::map<uint64, LfgAnswer> LfgAnswerMap; typedef std::map<uint64, LfgAnswer> LfgAnswerMap;
typedef std::map<uint32, LfgRoleCheck*> LfgRoleCheckMap; typedef std::map<uint64, LfgRoleCheck*> LfgRoleCheckMap;
typedef std::map<uint64, LfgQueueInfo*> LfgQueueInfoMap; typedef std::map<uint64, LfgQueueInfo*> LfgQueueInfoMap;
typedef std::map<uint32, LfgProposal*> LfgProposalMap; typedef std::map<uint32, LfgProposal*> LfgProposalMap;
typedef std::map<uint64, LfgProposalPlayer*> LfgProposalPlayerMap; typedef std::map<uint64, LfgProposalPlayer*> LfgProposalPlayerMap;
@@ -147,11 +147,11 @@ typedef std::map<uint64, LfgPlayerData> LfgPlayerDataMap;
// Data needed by SMSG_LFG_JOIN_RESULT // Data needed by SMSG_LFG_JOIN_RESULT
struct LfgJoinResultData struct LfgJoinResultData
{ {
LfgJoinResultData(LfgJoinResult _result = LFG_JOIN_OK, LfgRoleCheckState _state = LFG_ROLECHECK_DEFAULT, LfgLockStatusMap* _lockmap = NULL): LfgJoinResultData(LfgJoinResult _result = LFG_JOIN_OK, LfgRoleCheckState _state = LFG_ROLECHECK_DEFAULT):
result(_result), state(_state), lockmap(_lockmap) {} result(_result), state(_state) {}
LfgJoinResult result; LfgJoinResult result;
LfgRoleCheckState state; LfgRoleCheckState state;
LfgLockStatusMap* lockmap; LfgLockPartyMap lockmap;
}; };
// Data needed by SMSG_LFG_UPDATE_PARTY and SMSG_LFG_UPDATE_PLAYER // Data needed by SMSG_LFG_UPDATE_PARTY and SMSG_LFG_UPDATE_PLAYER
@@ -176,7 +176,7 @@ struct LfgReward
uint32 variableXP; uint32 variableXP;
} reward[2]; } reward[2];
LfgReward(uint32 _maxLevel, uint32 firstQuest, uint32 firstVarMoney, uint32 firstVarXp, uint32 otherQuest, uint32 otherVarMoney, uint32 otherVarXp) LfgReward(uint32 _maxLevel = 0, uint32 firstQuest = 0, uint32 firstVarMoney = 0, uint32 firstVarXp = 0, uint32 otherQuest = 0, uint32 otherVarMoney = 0, uint32 otherVarXp = 0)
: maxLevel(_maxLevel) : maxLevel(_maxLevel)
{ {
reward[0].questId = firstQuest; reward[0].questId = firstQuest;
@@ -191,7 +191,7 @@ struct LfgReward
/// Stores player or group queue info /// Stores player or group queue info
struct LfgQueueInfo struct LfgQueueInfo
{ {
LfgQueueInfo(): tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) {}; LfgQueueInfo(): joinTime(0), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) {};
time_t joinTime; ///< Player queue join time (to calculate wait times) time_t joinTime; ///< Player queue join time (to calculate wait times)
uint8 tanks; ///< Tanks needed uint8 tanks; ///< Tanks needed
uint8 healers; ///< Healers needed uint8 healers; ///< Healers needed
@@ -213,14 +213,12 @@ struct LfgProposalPlayer
/// Stores group data related to proposal to join /// Stores group data related to proposal to join
struct LfgProposal struct LfgProposal
{ {
LfgProposal(uint32 dungeon): dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), groupLowGuid(0), leader(0) {} LfgProposal(uint32 dungeon = 0): dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), groupLowGuid(0), leader(0), cancelTime(0) {}
~LfgProposal() ~LfgProposal()
{ {
for (LfgProposalPlayerMap::iterator it = players.begin(); it != players.end(); ++it) for (LfgProposalPlayerMap::iterator it = players.begin(); it != players.end(); ++it)
delete it->second; delete it->second;
players.clear();
queues.clear();
}; };
uint32 dungeonId; ///< Dungeon to join uint32 dungeonId; ///< Dungeon to join
LfgProposalState state; ///< State of the proposal LfgProposalState state; ///< State of the proposal
@@ -270,7 +268,7 @@ class LFGMgr
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level); LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
// Queue // Queue
void Join(Player* plr, uint8 roles, LfgDungeonSet& dungeons, std::string& comment); void Join(Player* plr, uint8 roles, const LfgDungeonSet& dungeons, const std::string& comment);
void Leave(Player* plr, Group* grp = NULL); void Leave(Player* plr, Group* grp = NULL);
// Role Check // Role Check
@@ -283,38 +281,39 @@ class LFGMgr
void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false); void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
// Vote kick // Vote kick
void InitBoot(Group* grp, uint64& kguid, uint64& vguid, std::string reason); void InitBoot(Group* grp, const uint64& kguid, const uint64& vguid, std::string reason);
void UpdateBoot(Player* plr, bool accept); void UpdateBoot(Player* plr, bool accept);
void OfferContinue(Group* grp); void OfferContinue(Group* grp);
// Lock info void InitializeLockedDungeons(Player* plr);
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr);
void SetComment(const uint64& guid, const std::string& comment);
LfgState GetState(uint64& guid); const LfgLockMap& GetLockedDungeons(const uint64& guid);
uint32 GetDungeon(uint64& guid, bool asId = true); LfgState GetState(const uint64& guid);
uint8 GetRoles(uint64& guid); const LfgDungeonSet& GetSelectedDungeons(const uint64& guid);
const std::string& GetComment(uint64& gguid); uint32 GetDungeon(const uint64& guid, bool asId = true);
LfgDungeonSet& GetSelectedDungeons(uint64& guid); void ClearState(const uint64& guid);
uint8 GetKicksLeft(uint64& gguid); void RemovePlayerData(const uint64& guid);
uint8 GetVotesNeeded(uint64& gguid); void RemoveGroupData(const uint64& guid);
uint8 GetKicksLeft(const uint64& gguid);
void RestoreState(uint64& guid); uint8 GetVotesNeeded(const uint64& gguid);
void ClearState(uint64& guid); void SetRoles(const uint64& guid, uint8 roles);
void SetState(uint64& guid, LfgState state);
void SetDungeon(uint64& guid, uint32 dungeon);
void SetRoles(uint64& guid, uint8 roles);
void SetComment(uint64& guid, std::string& comment);
void SetSelectedDungeons(uint64& guid, LfgDungeonSet dungeons);
void DecreaseKicksLeft(uint64& guid);
void RemovePlayerData(uint64& guid);
void RemoveGroupData(uint64& guid);
private: private:
uint8 GetRoles(const uint64& guid);
const std::string& GetComment(const uint64& gguid);
void RestoreState(const uint64& guid);
void SetState(const uint64& guid, LfgState state);
void SetDungeon(const uint64& guid, uint32 dungeon);
void SetSelectedDungeons(const uint64& guid, const LfgDungeonSet& dungeons);
void SetLockedDungeons(const uint64& guid, const LfgLockMap& lock);
void DecreaseKicksLeft(const uint64& guid);
void NoExiste(uint8 lala);
// Queue // Queue
void AddToQueue(uint64& guid, uint8 queueId); void AddToQueue(const uint64& guid, uint8 queueId);
bool RemoveFromQueue(uint64& guid); bool RemoveFromQueue(const uint64& guid);
// Proposals // Proposals
void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type); void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type);
@@ -323,17 +322,13 @@ class LFGMgr
LfgProposal* FindNewGroups(LfgGuidList& check, LfgGuidList& all); LfgProposal* FindNewGroups(LfgGuidList& check, LfgGuidList& all);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true); bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
bool CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal); bool CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal);
LfgLockStatusMap* GetCompatibleDungeons(LfgDungeonSet& dungeons, PlayerSet& players, bool returnLockMap = true); void GetCompatibleDungeons(LfgDungeonSet& dungeons, const PlayerSet& players, LfgLockPartyMap& lockMap);
void SetCompatibles(std::string concatenatedGuids, bool compatibles); void SetCompatibles(std::string concatenatedGuids, bool compatibles);
LfgAnswer GetCompatibles(std::string concatenatedGuids); LfgAnswer GetCompatibles(std::string concatenatedGuids);
void RemoveFromCompatibles(uint64 guid); void RemoveFromCompatibles(uint64 guid);
// Lock info
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet& players, LfgDungeonSet& dungeons, bool useEntry);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet& dungeons, bool useEntry);
// Generic // Generic
LfgDungeonSet GetDungeonsByRandom(uint32 randomdungeon); const LfgDungeonSet& GetDungeonsByRandom(uint32 randomdungeon);
LfgType GetDungeonType(uint32 dungeon); LfgType GetDungeonType(uint32 dungeon);
std::string ConcatenateGuids(LfgGuidList check); std::string ConcatenateGuids(LfgGuidList check);
@@ -18,7 +18,7 @@
#include "LFGPlayerData.h" #include "LFGPlayerData.h"
LfgPlayerData::LfgPlayerData(): LfgPlayerData::LfgPlayerData():
m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE), m_Roles(ROLE_NONE), m_Comment("") m_State(LFG_STATE_NONE), m_OldState(LFG_STATE_NONE), m_Roles(0), m_Comment("")
{} {}
LfgPlayerData::~LfgPlayerData() LfgPlayerData::~LfgPlayerData()
@@ -42,11 +42,11 @@ void LfgPlayerData::SetState(LfgState state)
void LfgPlayerData::ClearState() void LfgPlayerData::ClearState()
{ {
m_SelectedDungeons.clear(); m_SelectedDungeons.clear();
m_Roles = ROLE_NONE; m_Roles = 0;
m_State = m_OldState; m_State = m_OldState;
} }
void LfgPlayerData::SetDungeonsLockStatus(LfgLockStatusSet& lockStatus) void LfgPlayerData::SetLockedDungeons(const LfgLockMap& lockStatus)
{ {
m_LockedDungeons = lockStatus; m_LockedDungeons = lockStatus;
} }
@@ -56,12 +56,12 @@ void LfgPlayerData::SetRoles(uint8 roles)
m_Roles = roles; m_Roles = roles;
} }
void LfgPlayerData::SetComment(std::string& comment) void LfgPlayerData::SetComment(const std::string& comment)
{ {
m_Comment = comment; m_Comment = comment;
} }
void LfgPlayerData::SetSelectedDungeons(LfgDungeonSet& dungeons) void LfgPlayerData::SetSelectedDungeons(const LfgDungeonSet& dungeons)
{ {
m_SelectedDungeons = dungeons; m_SelectedDungeons = dungeons;
} }
@@ -76,7 +76,7 @@ LfgState LfgPlayerData::GetState() const
return m_State; return m_State;
} }
LfgLockStatusSet& LfgPlayerData::GetDungeonsLockStatus() const LfgLockMap & LfgPlayerData::GetLockedDungeons() const
{ {
return m_LockedDungeons; return m_LockedDungeons;
} }
@@ -91,7 +91,7 @@ const std::string& LfgPlayerData::GetComment() const
return m_Comment; return m_Comment;
} }
LfgDungeonSet& LfgPlayerData::GetSelectedDungeons() const LfgDungeonSet& LfgPlayerData::GetSelectedDungeons() const
{ {
return m_SelectedDungeons; return m_SelectedDungeons;
} }
@@ -33,27 +33,27 @@ class LfgPlayerData
// General // General
void SetState(LfgState state); void SetState(LfgState state);
void ClearState(); void ClearState();
void SetDungeonsLockStatus(LfgLockStatusSet& lockStatus); void SetLockedDungeons(const LfgLockMap& lock);
// Queue // Queue
void SetRoles(uint8 roles); void SetRoles(uint8 roles);
void SetComment(std::string& comment); void SetComment(const std::string& comment);
void SetSelectedDungeons(LfgDungeonSet& dungeons); void SetSelectedDungeons(const LfgDungeonSet& dungeons);
void ClearSelectedDungeons(); void ClearSelectedDungeons();
// General // General
LfgState GetState() const; LfgState GetState() const;
LfgLockStatusSet& GetDungeonsLockStatus(); const LfgLockMap& GetLockedDungeons() const;
// Queue // Queue
uint8 GetRoles() const; uint8 GetRoles() const;
const std::string& GetComment() const; const std::string& GetComment() const;
LfgDungeonSet& GetSelectedDungeons(); const LfgDungeonSet& GetSelectedDungeons() const;
private: private:
// General // General
LfgState m_State; ///< State if group in LFG LfgState m_State; ///< State if group in LFG
LfgState m_OldState; ///< Old State LfgState m_OldState; ///< Old State
// Player // Player
LfgLockStatusSet m_LockedDungeons; ///< Dungeons player can't do and reason LfgLockMap m_LockedDungeons; ///< Dungeons player can't do and reason
// Queue // Queue
uint8 m_Roles; ///< Roles the player selected when joined LFG uint8 m_Roles; ///< Roles the player selected when joined LFG
std::string m_Comment; ///< Player comment used when joined LFG std::string m_Comment; ///< Player comment used when joined LFG
@@ -158,7 +158,8 @@ void LFGScripts::OnLogout(Player* player)
sLFGMgr.RemovePlayerData(guid); sLFGMgr.RemovePlayerData(guid);
} }
void LFGScripts::OnLogin(Player* /*player*/) void LFGScripts::OnLogin(Player* player)
{ {
sLFGMgr.InitializeLockedDungeons(player);
// TODO - Restore LfgPlayerData and send proper status to player if it was in a group // TODO - Restore LfgPlayerData and send proper status to player if it was in a group
} }
+1 -1
View File
@@ -26,7 +26,7 @@
class Player; class Player;
class Group; class Group;
class LFGScripts: public GroupScript, PlayerScript class LFGScripts: public GroupScript, public PlayerScript
{ {
public: public:
LFGScripts(); LFGScripts();
@@ -24,39 +24,27 @@
#include "ObjectMgr.h" #include "ObjectMgr.h"
void BuildPlayerLockDungeonBlock(WorldPacket &data, LfgLockStatusSet* lockSet) void BuildPlayerLockDungeonBlock(WorldPacket& data, const LfgLockMap& lock)
{ {
if (!lockSet) data << uint32(lock.size()); // Size of lock dungeons
for (LfgLockMap::const_iterator it = lock.begin(); it != lock.end(); ++it)
{ {
data << uint8(0); data << uint32(it->first); // Dungeon entry (id + type)
return; data << uint32(it->second); // Lock status
}
data << uint32(lockSet->size()); // Size of lock dungeons
for (LfgLockStatusSet::const_iterator it = lockSet->begin(); it != lockSet->end(); ++it)
{
data << uint32((*it)->dungeon); // Dungeon entry + type
data << uint32((*it)->lockstatus); // Lock status
} }
} }
void BuildPartyLockDungeonBlock(WorldPacket &data, LfgLockStatusMap* lockMap) void BuildPartyLockDungeonBlock(WorldPacket& data, const LfgLockPartyMap& lockMap)
{ {
if (!lockMap) data << uint8(lockMap.size());
for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it)
{ {
data << uint8(0); data << uint64(it->first); // Player guid
return;
}
data << uint8(lockMap->size());
for (LfgLockStatusMap::const_iterator it = lockMap->begin(); it != lockMap->end(); ++it)
{
data << uint64(MAKE_NEW_GUID(it->first, 0, HIGHGUID_PLAYER)); // Player guid
BuildPlayerLockDungeonBlock(data, it->second); BuildPlayerLockDungeonBlock(data, it->second);
} }
} }
void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data) void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data)
{ {
if (!sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE) || if (!sWorld.getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE) ||
(GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID())) (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID()))
@@ -91,10 +79,10 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket &recv_data)
std::string comment; std::string comment;
recv_data >> comment; recv_data >> comment;
sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); sLog.outDebug("CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str());
sLFGMgr.Join(GetPlayer(), LfgRoles(roles), newDungeons, comment); sLFGMgr.Join(GetPlayer(), uint8(roles), newDungeons, comment);
} }
void WorldSession::HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/) void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/)
{ {
Group* grp = GetPlayer()->GetGroup(); Group* grp = GetPlayer()->GetGroup();
@@ -105,7 +93,7 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket & /*recv_data*/)
sLFGMgr.Leave(GetPlayer(), grp); sLFGMgr.Leave(GetPlayer(), grp);
} }
void WorldSession::HandleLfgProposalResultOpcode(WorldPacket &recv_data) void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recv_data)
{ {
uint32 lfgGroupID; // Internal lfgGroupID uint32 lfgGroupID; // Internal lfgGroupID
bool accept; // Accept to join? bool accept; // Accept to join?
@@ -116,7 +104,7 @@ void WorldSession::HandleLfgProposalResultOpcode(WorldPacket &recv_data)
sLFGMgr.UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); sLFGMgr.UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept);
} }
void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data) void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recv_data)
{ {
uint8 roles; uint8 roles;
recv_data >> roles; // Player Group Roles recv_data >> roles; // Player Group Roles
@@ -128,10 +116,10 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
return; return;
} }
sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Roles: %u", guid, roles); sLog.outDebug("CMSG_LFG_SET_ROLES [" UI64FMTD "] Roles: %u", guid, roles);
sLFGMgr.UpdateRoleCheck(grp, GetPlayer(), LfgRoles(roles)); sLFGMgr.UpdateRoleCheck(grp, GetPlayer());
} }
void WorldSession::HandleLfgSetCommentOpcode(WorldPacket & recv_data) void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recv_data)
{ {
std::string comment; std::string comment;
recv_data >> comment; recv_data >> comment;
@@ -141,7 +129,7 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket & recv_data)
sLFGMgr.SetComment(guid, comment); sLFGMgr.SetComment(guid, comment);
} }
void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket &recv_data) void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recv_data)
{ {
bool agree; // Agree to kick player bool agree; // Agree to kick player
recv_data >> agree; recv_data >> agree;
@@ -150,7 +138,7 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket &recv_data)
sLFGMgr.UpdateBoot(GetPlayer(), agree); sLFGMgr.UpdateBoot(GetPlayer(), agree);
} }
void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data) void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recv_data)
{ {
bool out; bool out;
recv_data >> out; recv_data >> out;
@@ -159,10 +147,12 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket &recv_data)
sLFGMgr.TeleportPlayer(GetPlayer(), out, true); sLFGMgr.TeleportPlayer(GetPlayer(), out, true);
} }
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data*/) void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data*/)
{ {
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID()); uint64 guid = GetPlayer()->GetGUID();
sLog.outDebug("CMSG_LFD_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid);
// Get Random dungeons that can be done at a certain level and expansion
// FIXME - Should return seasonals (when not disabled) // FIXME - Should return seasonals (when not disabled)
LfgDungeonSet randomDungeons; LfgDungeonSet randomDungeons;
uint8 level = GetPlayer()->getLevel(); uint8 level = GetPlayer()->getLevel();
@@ -170,41 +160,35 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i) for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i)
{ {
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i); LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(i);
if (dungeon && dungeon->type == LFG_TYPE_RANDOM && dungeon && dungeon->expansion <= expansion && if (dungeon && dungeon->type == LFG_TYPE_RANDOM && dungeon->expansion <= expansion &&
dungeon->minlevel <= level && level <= dungeon->maxlevel) dungeon->minlevel <= level && level <= dungeon->maxlevel)
randomDungeons.insert(dungeon->Entry()); randomDungeons.insert(dungeon->Entry());
} }
LfgLockStatusSet* lockSet = sLFGMgr.GetPlayerLockStatusDungeons(GetPlayer()); // Get player locked Dungeons
LfgLockMap lock = sLFGMgr.GetLockedDungeons(guid);
uint32 rsize = uint32(randomDungeons.size()); uint32 rsize = uint32(randomDungeons.size());
uint32 lsize = lockSet ? uint32(lockSet->size()) : 0; uint32 lsize = uint32(lock.size());
sLog.outDebug("SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", GetPlayer()->GetGUID()); sLog.outDebug("SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid);
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)); 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 (!randomDungeons.size())
data << uint8(0);
else
{
LfgReward const* reward = NULL;
Quest const* qRew = NULL;
uint8 done = 0;
data << uint8(randomDungeons.size()); // Random Dungeon count data << uint8(randomDungeons.size()); // Random Dungeon count
for (LfgDungeonSet::iterator it = randomDungeons.begin(); it != randomDungeons.end(); ++it) for (LfgDungeonSet::const_iterator it = randomDungeons.begin(); it != randomDungeons.end(); ++it)
{ {
data << uint32(*it); // Entry data << uint32(*it); // Dungeon Entry (id + type)
reward = sLFGMgr.GetRandomDungeonReward(*it, level); LfgReward const* reward = sLFGMgr.GetRandomDungeonReward(*it, level);
qRew = NULL; Quest const* qRew = NULL;
uint8 done = 0;
if (reward) if (reward)
{ {
qRew = sObjectMgr.GetQuestTemplate(reward->reward[0].questId); qRew = sObjectMgr.GetQuestTemplate(reward->reward[0].questId);
if (qRew) if (qRew)
{ {
done = !GetPlayer()->CanRewardQuest(qRew,false); done = !GetPlayer()->CanRewardQuest(qRew, false);
if (done) if (done)
qRew = sObjectMgr.GetQuestTemplate(reward->reward[1].questId); qRew = sObjectMgr.GetQuestTemplate(reward->reward[1].questId);
} }
} }
if (qRew) if (qRew)
{ {
@@ -240,27 +224,45 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket &/*recv_data
data << uint8(0); data << uint8(0);
} }
} }
} BuildPlayerLockDungeonBlock(data, lock);
BuildPlayerLockDungeonBlock(data, lockSet);
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket & /*recv_data*/) void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data*/)
{ {
sLog.outDebug("CMSG_LFD_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", GetPlayer()->GetGUID()); uint64 guid = GetPlayer()->GetGUID();
if (LfgLockStatusMap* lockMap = sLFGMgr.GetPartyLockStatusDungeons(GetPlayer())) sLog.outDebug("CMSG_LFD_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid);
Group* grp = GetPlayer()->GetGroup();
if (!grp)
return;
// Get the locked dungeons of the other party members
LfgLockPartyMap lockMap;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* plrg = itr->getSource();
if (!plrg)
continue;
uint64 pguid = plrg->GetGUID();
if (pguid == guid)
continue;
lockMap[pguid] = sLFGMgr.GetLockedDungeons(pguid);
}
uint32 size = 0; uint32 size = 0;
for (LfgLockStatusMap::const_iterator it = lockMap->begin(); it != lockMap->end(); ++it) for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it)
size += 8 + 4 + it->second->size() * (4 + 4); size += 8 + 4 + uint32(it->second.size()) * (4 + 4);
sLog.outDebug("SMSG_LFG_PARTY_INFO [" UI64FMTD "]", GetPlayer()->GetGUID());
sLog.outDebug("SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid);
WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size);
BuildPartyLockDungeonBlock(data, lockMap); BuildPartyLockDungeonBlock(data, lockMap);
SendPacket(&data); SendPacket(&data);
}
} }
void WorldSession::HandleLfrSearchOpcode(WorldPacket &recv_data) void WorldSession::HandleLfrSearchOpcode(WorldPacket& recv_data)
{ {
uint32 entry; // Raid id to search uint32 entry; // Raid id to search
recv_data >> entry; recv_data >> entry;
@@ -268,7 +270,7 @@ void WorldSession::HandleLfrSearchOpcode(WorldPacket &recv_data)
//SendLfrUpdateListOpcode(entry); //SendLfrUpdateListOpcode(entry);
} }
void WorldSession::HandleLfrLeaveOpcode(WorldPacket &recv_data) void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recv_data)
{ {
uint32 dungeonId; // Raid id queue to leave uint32 dungeonId; // Raid id queue to leave
recv_data >> dungeonId; recv_data >> dungeonId;
@@ -276,7 +278,7 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket &recv_data)
//sLFGMgr.LeaveLfr(GetPlayer(), dungeonId); //sLFGMgr.LeaveLfr(GetPlayer(), dungeonId);
} }
void WorldSession::SendLfgUpdatePlayer(LfgUpdateData updateData) void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData)
{ {
bool queued = false; bool queued = false;
bool extrainfo = false; bool extrainfo = false;
@@ -297,7 +299,7 @@ void WorldSession::SendLfgUpdatePlayer(LfgUpdateData updateData)
} }
uint64 guid = GetPlayer()->GetGUID(); uint64 guid = GetPlayer()->GetGUID();
uint8 size = updateData.dungeons ? updateData.dungeons->size() : 0; uint8 size = updateData.dungeons ? uint8(updateData.dungeons->size()) : 0;
sLog.outDebug("SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); 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())); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
@@ -318,7 +320,7 @@ void WorldSession::SendLfgUpdatePlayer(LfgUpdateData updateData)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendLfgUpdateParty(LfgUpdateData updateData) void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData)
{ {
bool join = false; bool join = false;
bool extrainfo = false; bool extrainfo = false;
@@ -347,7 +349,7 @@ void WorldSession::SendLfgUpdateParty(LfgUpdateData updateData)
} }
uint64 guid = GetPlayer()->GetGUID(); uint64 guid = GetPlayer()->GetGUID();
uint8 size = updateData.dungeons ? updateData.dungeons->size() : 0; uint8 size = updateData.dungeons ? uint8(updateData.dungeons->size()) : 0;
sLog.outDebug("SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); 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())); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
@@ -382,7 +384,7 @@ void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck) void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck)
{ {
ASSERT(pRoleCheck); ASSERT(pRoleCheck);
LfgDungeonSet dungeons; LfgDungeonSet dungeons;
@@ -394,9 +396,6 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
sLog.outDebug("SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); sLog.outDebug("SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID());
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1)); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1));
Player* plr;
uint8 roles;
data << uint32(pRoleCheck->state); // Check result data << uint32(pRoleCheck->state); // Check result
data << uint8(pRoleCheck->state == LFG_ROLECHECK_INITIALITING); data << uint8(pRoleCheck->state == LFG_ROLECHECK_INITIALITING);
data << uint8(dungeons.size()); // Number of dungeons data << uint8(dungeons.size()); // Number of dungeons
@@ -413,21 +412,21 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
if (pRoleCheck->roles.size()) if (pRoleCheck->roles.size())
{ {
// Leader info MUST be sent 1st :S // Leader info MUST be sent 1st :S
roles = pRoleCheck->roles[pRoleCheck->leader]; uint64 guid = pRoleCheck->leader;
uint64 guid = MAKE_NEW_GUID(pRoleCheck->leader, 0, HIGHGUID_PLAYER); uint8 roles = pRoleCheck->roles.find(guid)->second;
data << uint64(guid); // Guid data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles data << uint32(roles); // Roles
plr = sObjectMgr.GetPlayer(guid); Player* plr = sObjectMgr.GetPlayer(guid);
data << uint8(plr ? plr->getLevel() : 0); // Level data << uint8(plr ? plr->getLevel() : 0); // Level
for (LfgRolesMap::const_iterator itPlayers = pRoleCheck->roles.begin(); itPlayers != pRoleCheck->roles.end(); ++itPlayers) for (LfgRolesMap::const_iterator it = pRoleCheck->roles.begin(); it != pRoleCheck->roles.end(); ++it)
{ {
if (itPlayers->first == pRoleCheck->leader) if (it->first == pRoleCheck->leader)
continue; continue;
roles = itPlayers->second; guid = it->first;
guid = MAKE_NEW_GUID(itPlayers->first, 0, HIGHGUID_PLAYER); roles = it->second;
data << uint64(guid); // Guid data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles data << uint32(roles); // Roles
@@ -438,20 +437,17 @@ void WorldSession::SendLfgRoleCheckUpdate(LfgRoleCheck* pRoleCheck)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendLfgJoinResult(LfgJoinResultData& joinData) void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData)
{ {
uint32 size = 0; uint32 size = 0;
if (joinData.lockmap) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
{ size += 8 + 4 + uint32(it->second.size()) * (4 + 4);
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_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); 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); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
data << uint32(joinData.result); // Check Result data << uint32(joinData.result); // Check Result
data << uint32(joinData.state); // Check Value data << uint32(joinData.state); // Check Value
if (joinData.lockmap) if (!joinData.lockmap.empty())
BuildPartyLockDungeonBlock(data, joinData.lockmap); BuildPartyLockDungeonBlock(data, joinData.lockmap);
SendPacket(&data); SendPacket(&data);
} }
@@ -479,7 +475,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr
if (!rdungeonEntry || !sdungeonEntry || !qRew) if (!rdungeonEntry || !sdungeonEntry || !qRew)
return; return;
uint8 itemNum = qRew ? qRew->GetRewItemsCount() : 0; uint8 itemNum = uint8(qRew ? qRew->GetRewItemsCount() : 0);
sLog.outDebug("SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); sLog.outDebug("SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done);
WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4));
@@ -510,9 +506,10 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendLfgBootPlayer(LfgPlayerBoot* pBoot) void WorldSession::SendLfgBootPlayer(const LfgPlayerBoot* pBoot)
{ {
int8 playerVote = pBoot->votes[GetPlayer()->GetGUIDLow()]; uint64 guid = GetPlayer()->GetGUID();
LfgAnswer playerVote = pBoot->votes.find(guid)->second;
uint8 votesNum = 0; uint8 votesNum = 0;
uint8 agreeNum = 0; uint8 agreeNum = 0;
uint32 secsleft = uint8((pBoot->cancelTime - time(NULL)) / 1000); uint32 secsleft = uint8((pBoot->cancelTime - time(NULL)) / 1000);
@@ -526,7 +523,7 @@ void WorldSession::SendLfgBootPlayer(LfgPlayerBoot* pBoot)
} }
} }
sLog.outDebug("SMSG_LFG_BOOT_PLAYER [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", sLog.outDebug("SMSG_LFG_BOOT_PLAYER [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s",
GetPlayer()->GetGUID(), uint8(pBoot->inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), pBoot->victim, votesNum, agreeNum, secsleft, pBoot->votedNeeded, pBoot->reason.c_str()); guid, uint8(pBoot->inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), pBoot->victim, votesNum, agreeNum, secsleft, pBoot->votedNeeded, pBoot->reason.c_str());
WorldPacket data(SMSG_LFG_BOOT_PLAYER, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + pBoot->reason.length()); WorldPacket data(SMSG_LFG_BOOT_PLAYER, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + pBoot->reason.length());
data << uint8(pBoot->inProgress); // Vote in progress data << uint8(pBoot->inProgress); // Vote in progress
data << uint8(playerVote != LFG_ANSWER_PENDING); // Did Vote data << uint8(playerVote != LFG_ANSWER_PENDING); // Did Vote
@@ -540,15 +537,13 @@ void WorldSession::SendLfgBootPlayer(LfgPlayerBoot* pBoot)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal* pProp) void WorldSession::SendLfgUpdateProposal(uint32 proposalId, const LfgProposal* pProp)
{ {
if (!pProp) if (!pProp)
return; return;
uint32 pLogGuid = GetPlayer()->GetGUIDLow();
uint64 guid = GetPlayer()->GetGUID(); uint64 guid = GetPlayer()->GetGUID();
LfgProposalPlayerMap::const_iterator itPlayer = pProp->players.find(guid);
LfgProposalPlayerMap::const_iterator itPlayer = pProp->players.find(pLogGuid);
if (itPlayer == pProp->players.end()) // Player MUST be in the proposal if (itPlayer == pProp->players.end()) // Player MUST be in the proposal
return; return;
@@ -588,7 +583,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal* pProp)
{ {
ppPlayer = itPlayer->second; ppPlayer = itPlayer->second;
data << uint32(ppPlayer->role); // Role data << uint32(ppPlayer->role); // Role
data << uint8(itPlayer->first == pLogGuid); // Self player data << uint8(itPlayer->first == guid); // Self player
if (!ppPlayer->groupLowGuid) // Player not it a group if (!ppPlayer->groupLowGuid) // Player not it a group
{ {
data << uint8(0); // Not in dungeon data << uint8(0); // Not in dungeon
+6 -6
View File
@@ -768,16 +768,16 @@ class WorldSession
void HandleLfrSearchOpcode(WorldPacket &recv_data); void HandleLfrSearchOpcode(WorldPacket &recv_data);
void HandleLfrLeaveOpcode(WorldPacket &recv_data); void HandleLfrLeaveOpcode(WorldPacket &recv_data);
void SendLfgUpdatePlayer(LfgUpdateData updateData); void SendLfgUpdatePlayer(const LfgUpdateData& updateData);
void SendLfgUpdateParty(LfgUpdateData updateData); void SendLfgUpdateParty(const LfgUpdateData& updateData);
void SendLfgRoleChosen(uint64 guid, uint8 roles); void SendLfgRoleChosen(uint64 guid, uint8 roles);
void SendLfgRoleCheckUpdate(LfgRoleCheck *pRoleCheck); void SendLfgRoleCheckUpdate(const LfgRoleCheck *pRoleCheck);
void SendLfgUpdateSearch(bool update); void SendLfgUpdateSearch(bool update);
void SendLfgJoinResult(LfgJoinResultData& joinData); void SendLfgJoinResult(const 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 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 SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward *reward, const Quest *qRew);
void SendLfgBootPlayer(LfgPlayerBoot *pBoot); void SendLfgBootPlayer(const LfgPlayerBoot *pBoot);
void SendLfgUpdateProposal(uint32 proposalId, LfgProposal *pProp); void SendLfgUpdateProposal(uint32 proposalId, const LfgProposal *pProp);
void SendLfgDisabled(); void SendLfgDisabled();
void SendLfgOfferContinue(uint32 dungeonEntry); void SendLfgOfferContinue(uint32 dungeonEntry);
void SendLfgTeleportError(uint8 err); void SendLfgTeleportError(uint8 err);