本文整理汇总了C++中Group::GetMembersCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::GetMembersCount方法的具体用法?C++ Group::GetMembersCount怎么用?C++ Group::GetMembersCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::GetMembersCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Join
/// <summary>
/// Adds the player to lfg queue
/// </summary>
/// <param name="plr">Player</param>
void LFGMgr::Join(Player *plr)
{
Group *grp = plr->GetGroup();
// TODO - 2010-05-27 Anyone can init rolecheck when already in a LFD Group?
if (grp && grp->GetLeaderGUID() != plr->GetGUID())
return;
// Previous checks before joining
LfgJoinResult result = LFG_JOIN_OK;
if (plr->InBattleGround() || plr->InArena())
result = LFG_JOIN_USING_BG_SYSTEM;
else if (plr->HasAura(LFG_SPELL_DESERTER))
result = LFG_JOIN_DESERTER;
else if (plr->HasAura(LFG_SPELL_COOLDOWN))
result = LFG_JOIN_RANDOM_COOLDOWN;
else
{
// Check if all dungeons are valid
for (LfgDungeonSet::const_iterator it = plr->m_lookingForGroup.applyDungeons.begin(); it != plr->m_lookingForGroup.applyDungeons.end(); ++it)
{
if ((m_DungeonsMap[LFG_ALL_DUNGEONS])->find(*it) == (m_DungeonsMap[LFG_ALL_DUNGEONS])->end())
{
result = LFG_JOIN_DUNGEON_INVALID;
break;
}
}
}
if (grp && result == LFG_JOIN_OK)
{
if (grp->GetMembersCount() > MAX_GROUP_SIZE)
result = LFG_JOIN_TOO_MUCH_MEMBERS;
else if (grp->isRaidGroup())
result = LFG_JOIN_MIXED_RAID_DUNGEON;
else
{
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL && result == LFG_JOIN_OK; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
if (plrg->HasAura(LFG_SPELL_DESERTER))
result = LFG_JOIN_PARTY_DESERTER;
else if (plrg->HasAura(LFG_SPELL_COOLDOWN))
result = LFG_JOIN_PARTY_RANDOM_COOLDOWN;
}
else
result = LFG_JOIN_DISCONNECTED;
}
}
}
if (result != LFG_JOIN_OK)
{
plr->m_lookingForGroup.applyDungeons.clear();
plr->m_lookingForGroup.roles = 0;
plr->GetSession()->SendLfgJoinResult(result, 0);
return;
}
if (grp)
{
Player *plrg = NULL;
for (GroupReference *itr = plr->GetGroup()->GetFirstMember(); itr != NULL; itr = itr->next())
{
plrg = itr->getSource(); // Not null, checked earlier
plrg->m_lookingForGroup.applyDungeons = plr->m_lookingForGroup.applyDungeons;
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL);
}
UpdateRoleCheck(grp, plr);
}
else
{
plr->GetSession()->SendLfgJoinResult(LFG_JOIN_OK, 0);
plr->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_JOIN_PROPOSAL);
// Add player to queue
LfgQueueInfo *pqInfo;
uint8 groupType = 0;
uint8 tanks = LFG_TANKS_NEEDED;
uint8 healers = LFG_HEALERS_NEEDED;
uint8 dps = LFG_DPS_NEEDED;
if (plr->m_lookingForGroup.roles & ROLE_TANK)
--tanks;
else if (plr->m_lookingForGroup.roles & ROLE_HEALER)
--healers;
else
--dps;
m_update = false;
for (LfgDungeonSet::const_iterator it = plr->m_lookingForGroup.applyDungeons.begin(); it != plr->m_lookingForGroup.applyDungeons.end(); ++it)
{
groupType = GetDungeonGroupType(*it);
pqInfo = m_Queues[groupType] ? m_Queues[groupType]->GetQueueInfo(plr->GetGUID()) : NULL;
// if exist we have already added the player with another dungeon sharing same GroupType
if (pqInfo)
continue;
//.........这里部分代码省略.........
示例2: HandleBattlemasterJoinOpcode
void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
{
uint64 guid;
uint32 bgTypeId_;
uint32 instanceId;
uint8 joinAsGroup;
bool isPremade = false;
Group * grp;
recv_data >> guid; // battlemaster guid
recv_data >> bgTypeId_; // battleground type id (DBC id)
recv_data >> instanceId; // instance id, 0 if First Available selected
recv_data >> joinAsGroup; // join as group
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u",bgTypeId_,_player->GetGUIDLow());
return;
}
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)));
// can do this, since it's battleground, not arena
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, 0);
// ignore if player is already in BG
if (_player->InBattleGround())
return;
// get bg instance or bg template if instance not found
BattleGround *bg = NULL;
if (instanceId)
bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId);
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
sLog.outError("Battleground: no available bg / template found");
return;
}
// check queueing conditions
if (!joinAsGroup)
{
// check Deserter debuff
if (!_player->CanJoinToBattleground())
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << uint32(0xFFFFFFFE);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
uint32 err = grp->CanJoinBattleGroundQueue(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
if (err != BG_JOIN_ERR_OK)
{
SendBattleGroundOrArenaJoinError(err);
return;
}
}
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
// _player->GetGroup() was already checked, grp is already initialized
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, 0, false, isPremade, 0);
uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
if (joinAsGroup /* && _player->GetGroup()*/)
{
sLog.outDebug("Battleground: the following players are joining as group:");
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
if(!member) continue; // this should never happen
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(member, ginfo);
sLog.outDebug("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,member->GetGUIDLow(), member->GetName());
}
sLog.outDebug("Battleground: group end");
//.........这里部分代码省略.........
示例3: HandleBattlemasterJoinArena
//.........这里部分代码省略.........
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
uint32 err = grp->CanJoinBattleGroundQueue(bgTypeId, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
if (err != BG_JOIN_ERR_OK)
{
SendBattleGroundOrArenaJoinError(err);
return;
}
}
uint32 ateamId = 0;
if (isRated)
{
ateamId = _player->GetArenaTeamId(arenaslot);
// check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice)
ArenaTeam* at = sObjectMgr.GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queue
arenaRating = at->GetRating();
// the arena team id must match for everyone in the group
// get the personal ratings for queue
uint32 avg_pers_rating = 0;
for (Group::member_citerator citr = grp->GetMemberSlots().begin(); citr != grp->GetMemberSlots().end(); ++citr)
{
ArenaTeamMember const* at_member = at->GetMember(citr->guid);
if (!at_member) // group member joining to arena must be in leader arena team
return;
// calc avg personal rating
avg_pers_rating += at_member->personal_rating;
}
avg_pers_rating /= grp->GetMembersCount();
// if avg personal rating is more than 150 points below the teams rating, the team will be queued against an opponent matching or similar to the average personal rating
if (avg_pers_rating + 150 < arenaRating)
arenaRating = avg_pers_rating;
}
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
if (asGroup)
{
DEBUG_LOG("Battleground: arena join as group start");
if (isRated)
DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), arenaRating, arenatype);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bgBracketId, arenatype, isRated, false, arenaRating, ateamId);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue;
// add to queue
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);
// store entry point coords (same as leader entry point)
member->SetBattleGroundEntryPoint(_player);
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
member->GetSession()->SendPacket(&data);
DEBUG_LOG("Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName());
}
DEBUG_LOG("Battleground: arena join as group end");
}
else
{
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bgBracketId, arenatype, isRated, false, arenaRating, ateamId);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId));
uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
// store entry point coords
_player->SetBattleGroundEntryPoint();
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
SendPacket(&data);
DEBUG_LOG("Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName());
}
sBattleGroundMgr.ScheduleQueueUpdate(arenaRating, arenatype, bgQueueTypeId, bgTypeId, _player->GetBattleGroundBracketIdFromLevel(bgTypeId));
}
示例4: HandleBattlemasterJoinOpcode
void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
uint32 bgTypeId_;
uint32 instanceId;
uint8 joinAsGroup;
bool isPremade = false;
Group* grp;
recv_data >> guid; // battlemaster guid
recv_data >> bgTypeId_; // battleground type id (DBC id)
recv_data >> instanceId; // instance id, 0 if First Available selected
recv_data >> joinAsGroup; // join as group
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUIDLow());
return;
}
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
DEBUG_LOG("WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from %s", guid.GetString().c_str());
// can do this, since it's battleground, not arena
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, ARENA_TYPE_NONE);
// ignore if player is already in BG
if (_player->InBattleGround())
return;
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
if (!unit->isBattleMaster()) // it's not battlemaster
return;
// get bg instance or bg template if instance not found
BattleGround* bg = NULL;
if (instanceId)
bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId);
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
sLog.outError("Battleground: no available bg / template found");
return;
}
BattleGroundBracketId bgBracketId = _player->GetBattleGroundBracketIdFromLevel(bgTypeId);
// check queue conditions
if (!joinAsGroup)
{
// check Deserter debuff
if (!_player->CanJoinToBattleground())
{
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << uint32(0xFFFFFFFE);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
uint32 err = grp->CanJoinBattleGroundQueue(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) &&
(grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
if (err != BG_JOIN_ERR_OK)
{
SendBattleGroundOrArenaJoinError(err);
return;
}
}
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
// _player->GetGroup() was already checked, grp is already initialized
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
if (joinAsGroup)
{
DEBUG_LOG("Battleground: the following players are joining as group:");
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bgBracketId, ARENA_TYPE_NONE, false, isPremade, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
//.........这里部分代码省略.........
示例5: Join
void LFGMgr::Join(Player* player)
{
// LfgDungeonSet* dungeons = NULL;
if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE) && !sWorld.getConfig(CONFIG_BOOL_LFR_ENABLE))
return;
ObjectGuid guid;
Group* group = player->GetGroup();
if (group)
{
if (player->GetObjectGuid() != group->GetLeaderGuid())
{
player->GetSession()->SendLfgJoinResult(ERR_LFG_NO_SLOTS_PLAYER);
return;
}
else
guid = group->GetObjectGuid();
}
else
guid = player->GetObjectGuid();
if (guid.IsEmpty())
return;
LFGType type = player->GetLFGState()->GetType();
if (type == LFG_TYPE_NONE)
{
DEBUG_LOG("LFGMgr::Join: %u trying to join without dungeon type. Aborting.", guid.GetCounter());
player->GetSession()->SendLfgJoinResult(ERR_LFG_INVALID_SLOT);
return;
}
else if (group && type == LFG_TYPE_RAID && !group->isRaidGroup())
{
DEBUG_LOG("LFGMgr::Join: %u trying to join to raid finder, but group is not raid. Aborting.", guid.GetCounter());
player->GetSession()->SendLfgJoinResult(ERR_LFG_MISMATCHED_SLOTS);
return;
}
else if (group && type != LFG_TYPE_RAID && group->isRaidGroup())
{
DEBUG_LOG("LFGMgr::Join: %u trying to join to dungeon finder, but group is raid. Aborting.", guid.GetCounter());
player->GetSession()->SendLfgJoinResult(ERR_LFG_MISMATCHED_SLOTS);
return;
}
LFGQueueInfoMap::iterator queue = (guid.IsGroup() ? m_groupQueueInfoMap[type].find(guid) : m_queueInfoMap[type].find(guid));
LFGJoinResult result = ERR_LFG_OK;
if (queue != (guid.IsGroup() ? m_groupQueueInfoMap[type].end() : m_queueInfoMap[type].end()))
{
DEBUG_LOG("LFGMgr::Join: %u trying to join but is already in queue!", guid.GetCounter());
result = ERR_LFG_NO_LFG_OBJECT;
player->GetSession()->SendLfgJoinResult(result);
_Leave(guid);
_LeaveGroup(guid);
return;
}
result = guid.IsGroup() ? GetGroupJoinResult(group) : GetPlayerJoinResult(player);
if (result != ERR_LFG_OK) // Someone can't join. Clear all stuf
{
DEBUG_LOG("LFGMgr::Join: %u joining with %u members. result: %u", guid.GetCounter(), group ? group->GetMembersCount() : 1, result);
player->GetLFGState()->Clear();
player->GetSession()->SendLfgJoinResult(result);
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_ROLECHECK_FAILED, type);
return;
}
if (!guid.IsGroup() && player->GetLFGState()->GetRoles() == LFG_ROLE_MASK_NONE)
{
sLog.outError("LFGMgr::Join: %u has no roles", guid.GetCounter());
}
// Joining process
if (guid.IsGroup())
{
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player* player = itr->getSource())
_Leave(player->GetObjectGuid());
}
_LeaveGroup(guid, type);
_JoinGroup(guid, type);
}
else
{
_Leave(guid, type);
_Join(guid, type);
}
player->GetLFGState()->SetState((type == LFG_TYPE_RAID) ? LFG_STATE_LFR : LFG_STATE_LFG);
player->GetSession()->SendLfgJoinResult(ERR_LFG_OK, 0);
if (group)
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_JOIN_PROPOSAL, type);
//.........这里部分代码省略.........
示例6: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
WorldPacket data;
sBattlegroundMgr->BuildStatusFailedPacket(&data, bg, _player, 0, ERR_IN_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
// player is already in queue, can't start random queue
WorldPacket data;
sBattlegroundMgr->BuildStatusFailedPacket(&data, bg, _player, 0, ERR_IN_NON_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPacket data;
sBattlegroundMgr->BuildStatusFailedPacket(&data, bg, _player, 0, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
_player->GetSession()->SendPacket(&data);
return;
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
// add joined time data
_player->AddBattlegroundQueueJoinTime(bgTypeId, ginfo->JoinTime);
WorldPacket data; // send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, _player, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, ginfo->ArenaType);
SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",
bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str());
}
else
{
grp = _player->GetGroup();
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = NULL;
uint32 avgTime = 0;
if (!err)
{
TC_LOG_DEBUG("bg.battleground", "Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue; // this should never happen
if (err)
{
WorldPacket data;
sBattlegroundMgr->BuildStatusFailedPacket(&data, bg, _player, 0, err);
member->GetSession()->SendPacket(&data);
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// add joined time data
member->AddBattlegroundQueueJoinTime(bgTypeId, ginfo->JoinTime);
WorldPacket data; // send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, member, queueSlot, STATUS_WAIT_QUEUE, avgTime, ginfo->JoinTime, ginfo->ArenaType);
member->GetSession()->SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",
bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str());
}
TC_LOG_DEBUG("bg.battleground", "Battleground: group end");
}
sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例7: HandleBattlemasterJoinArena
void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
// recv_data.hexlike();
uint8 arenaslot; // 2v2, 3v3 or 5v5
recv_data >> arenaslot;
// ignore if we already in BG or BG queue
if (_player->InBattleGround())
return;
ArenaType arenatype = ArenaTeam::GetTypeBySlot(arenaslot);
uint32 arenaRating = 0;
if (!IsArenaTypeValid(arenatype))
{
sLog.outError("Unknown arena slot %u at HandleBattlemasterJoinArena()", arenaslot);
return;
}
// check existence
BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog.outError("Battleground: template bg (all arenas) not found");
return;
}
BattleGroundTypeId bgTypeId = bg->GetTypeID();
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
Group* grp = _player->GetGroup();
// no group found, error
if (!grp || grp->isLFDGroup())
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
uint32 ateamId = _player->GetArenaTeamId(arenaslot);
// check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice)
ArenaTeam* at = sObjectMgr.GetArenaTeamById(ateamId);
if (!at)
{
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
return;
}
// get the team rating for queue
arenaRating = at->GetRating();
// the arena team id must match for everyone in the group
// get the personal ratings for queue
uint32 avg_pers_rating = 0;
for (Group::member_citerator citr = grp->GetMemberSlots().begin(); citr != grp->GetMemberSlots().end(); ++citr)
{
ArenaTeamMember const* at_member = at->GetMember(citr->guid);
if (!at_member) // group member joining to arena must be in leader arena team
return;
avg_pers_rating += at_member->matchmaker_rating;
}
avg_pers_rating /= grp->GetMembersCount();
/* Save mmr before enter arena (matchmaker rating fix) */
at->SetBattleRating(avg_pers_rating);
arenaRating = avg_pers_rating;
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
uint32 avgTime = 0;
// may be Group::CanJoinBattleGroundQueue should be moved to player class...
GroupJoinBattlegroundResult err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, arenaslot);
if (!err)
{
DEBUG_LOG("Battleground: arena join as group start");
DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), arenaRating, arenatype);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, ateamId);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue;
WorldPacket data;
if (err)
{
sBattleGroundMgr.BuildBattleGroundStatusFailedPacket(&data, bg, member, 0, err);
member->GetSession()->SendPacket(&data);
continue;
//.........这里部分代码省略.........
示例8: GetTradeDiscount
uint32 RandomPlayerbotMgr::GetTradeDiscount(Player* bot)
{
Group* group = bot->GetGroup();
return GetLootAmount(bot) / (group ? group->GetMembersCount() : 10);
}
示例9: SendLfgRoleCheckUpdate
void WorldSession::SendLfgRoleCheckUpdate()
{
if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLE))
{
DEBUG_LOG("SendLfgRoleCheckUpdate %u failed - Dungeon finder disabled", GetPlayer()->GetObjectGuid().GetCounter());
return;
}
Group* pGroup = GetPlayer()->GetGroup();
if (!pGroup)
return;
LFGDungeonSet const* dungeons = sLFGMgr.GetLFGGroupState(pGroup->GetObjectGuid())->GetDungeons();
if (!dungeons)
return;
DEBUG_LOG("SMSG_LFG_ROLE_CHECK_UPDATE %u, dugeons size " SIZEFMTD, GetPlayer()->GetObjectGuid().GetCounter(), dungeons->size());
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons->size() * 4 + 1 + pGroup->GetMembersCount() * (8 + 1 + 4 + 1));
data << uint32(sLFGMgr.GetLFGGroupState(pGroup->GetObjectGuid())->GetRoleCheckState()); // Check result
data << uint8(sLFGMgr.GetLFGGroupState(pGroup->GetObjectGuid())->GetRoleCheckState() == LFG_ROLECHECK_INITIALITING);
data << uint8(dungeons->size()); // Number of dungeons
if (dungeons->size())
{
for (LFGDungeonSet::const_iterator itr = dungeons->begin(); itr != dungeons->end(); ++itr)
{
data << uint32(*itr ? (*itr)->Entry() : 0); // Dungeon Entry
}
}
data << uint8(pGroup->GetMembersCount()); // Players in group
if (pGroup->GetMembersCount())
{
// Leader info MUST be sent 1st :S
ObjectGuid leaderguid = pGroup->GetLeaderGuid();
Player* pLeader = sObjectMgr.GetPlayer(leaderguid);
LFGRoleMask roles = LFG_ROLE_MASK_NONE;
uint8 leaderLevel = 1;
if (pLeader)
{
roles = sLFGMgr.GetLFGPlayerState(pLeader->GetObjectGuid())->GetRoles();
leaderLevel = pLeader->getLevel();
}
data << leaderguid; // Guid
data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready
data << uint32(roles); // Roles
data << uint8(leaderLevel); // Level
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player* pGroupMember = itr->getSource())
{
ObjectGuid guid = pGroupMember->GetObjectGuid();
// Leader data handle first
if (guid == leaderguid)
continue;
roles = sLFGMgr.GetLFGPlayerState(pGroupMember->GetObjectGuid())->GetRoles();
data << guid; // Guid
data << uint8(roles != LFG_ROLE_MASK_NONE); // Ready
data << uint32(roles); // Roles
data << uint8(pGroupMember->getLevel()); // Level
}
}
}
SendPacket(&data);
}
示例10: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
// player is already in random queue
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_RANDOM_BG);
SendPacket(battlefieldStatus.Write());
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
// player is already in queue, can't start random queue
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_NON_RANDOM_BG);
SendPacket(battlefieldStatus.Write());
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
SendPacket(battlefieldStatus.Write());
return;
}
// check Freeze debuff
if (_player->HasAura(9454))
return;
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, false);
SendPacket(battlefieldStatus.Write());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
bgQueueTypeId, bgTypeId, _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
}
else
{
grp = _player->GetGroup();
if (!grp)
return;
if (grp->GetLeaderGUID() != _player->GetGUID())
return;
ObjectGuid errorGuid;
err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0, errorGuid);
isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = NULL;
uint32 avgTime = 0;
if (!err)
{
TC_LOG_DEBUG("bg.battleground", "Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue; // this should never happen
if (err)
{
WorldPackets::Battleground::BattlefieldStatusFailed battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, err, &errorGuid);
member->SendDirectMessage(battlefieldStatus.Write());
continue;
}
// add to queue
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
WorldPackets::Battleground::BattlefieldStatusQueued battlefieldStatus;
sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, true);
member->SendDirectMessage(battlefieldStatus.Write());
TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
bgQueueTypeId, bgTypeId, member->GetGUID().ToString().c_str(), member->GetName().c_str());
}
TC_LOG_DEBUG("bg.battleground", "Battleground: group end");
}
sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例11: HandleRaidConfirmReadyCheck
void WorldSession::HandleRaidConfirmReadyCheck(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_RAID_CONFIRM_READY_CHECK");
ObjectGuid guid; // currently unused
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
recvData.read_skip<uint8>();
guid[2] = recvData.ReadBit();
guid[1] = recvData.ReadBit();
guid[0] = recvData.ReadBit();
guid[3] = recvData.ReadBit();
guid[6] = recvData.ReadBit();
bool status = recvData.ReadBit();
guid[7] = recvData.ReadBit();
guid[4] = recvData.ReadBit();
guid[5] = recvData.ReadBit();
recvData.ReadByteSeq(guid[1]);
recvData.ReadByteSeq(guid[0]);
recvData.ReadByteSeq(guid[3]);
recvData.ReadByteSeq(guid[2]);
recvData.ReadByteSeq(guid[4]);
recvData.ReadByteSeq(guid[5]);
recvData.ReadByteSeq(guid[7]);
recvData.ReadByteSeq(guid[6]);
ObjectGuid playerGuid = GetPlayer()->GetGUID();
ObjectGuid groupGuid = group->GetGUID();
group->SetReadyCheckCount(group->GetReadyCheckCount() + 1);
WorldPacket data(SMSG_RAID_READY_CHECK_CONFIRM, 1 + 1 + 8 + 1 + 8);
data.WriteBit(groupGuid[4]);
data.WriteBit(playerGuid[5]);
data.WriteBit(playerGuid[3]);
data.WriteBit(status);
data.WriteBit(groupGuid[2]);
data.WriteBit(playerGuid[6]);
data.WriteBit(groupGuid[3]);
data.WriteBit(playerGuid[0]);
data.WriteBit(playerGuid[1]);
data.WriteBit(groupGuid[1]);
data.WriteBit(groupGuid[5]);
data.WriteBit(playerGuid[7]);
data.WriteBit(playerGuid[4]);
data.WriteBit(groupGuid[6]);
data.WriteBit(playerGuid[2]);
data.WriteBit(groupGuid[0]);
data.WriteBit(groupGuid[7]);
data.FlushBits();
data.WriteByteSeq(playerGuid[4]);
data.WriteByteSeq(playerGuid[2]);
data.WriteByteSeq(playerGuid[1]);
data.WriteByteSeq(groupGuid[4]);
data.WriteByteSeq(groupGuid[2]);
data.WriteByteSeq(playerGuid[0]);
data.WriteByteSeq(groupGuid[5]);
data.WriteByteSeq(groupGuid[3]);
data.WriteByteSeq(playerGuid[7]);
data.WriteByteSeq(groupGuid[6]);
data.WriteByteSeq(groupGuid[1]);
data.WriteByteSeq(playerGuid[6]);
data.WriteByteSeq(playerGuid[3]);
data.WriteByteSeq(playerGuid[5]);
data.WriteByteSeq(groupGuid[0]);
data.WriteByteSeq(groupGuid[7]);
group->BroadcastPacket(&data, true);
// Send SMSG_RAID_READY_CHECK_COMPLETED
if (group->GetReadyCheckCount() >= group->GetMembersCount())
{
ObjectGuid grpGUID = group->GetGUID();
data.Initialize(SMSG_RAID_READY_CHECK_COMPLETED, 1 + 8 + 1);
uint8 bitOrder[8] = { 4, 2, 5, 7, 1, 0, 3, 6 };
data.WriteBitInOrder(grpGUID, bitOrder);
data.WriteByteSeq(grpGUID[6]);
data.WriteByteSeq(grpGUID[0]);
data.WriteByteSeq(grpGUID[3]);
data.WriteByteSeq(grpGUID[1]);
data.WriteByteSeq(grpGUID[5]);
data << uint8(1); // or 0
data.WriteByteSeq(grpGUID[7]);
data.WriteByteSeq(grpGUID[2]);
data.WriteByteSeq(grpGUID[4]);
group->BroadcastPacket(&data, true);
}
//.........这里部分代码省略.........
示例12: HandleRaidConfirmReadyCheck
void WorldSession::HandleRaidConfirmReadyCheck(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_RAID_CONFIRM_READY_CHECK");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
recvData.read_skip<uint8>(); // unk, 0x00
bool ready = recvData.ReadBit();
// ========== Unknown guid reading here - probably for group guid ? ========
ObjectGuid unknownGuid;
unknownGuid[0] = recvData.ReadBit();
unknownGuid[6] = recvData.ReadBit();
unknownGuid[5] = recvData.ReadBit();
unknownGuid[2] = recvData.ReadBit();
unknownGuid[4] = recvData.ReadBit();
unknownGuid[7] = recvData.ReadBit();
unknownGuid[3] = recvData.ReadBit();
unknownGuid[1] = recvData.ReadBit();
recvData.FlushBits();
recvData.ReadByteSeq(unknownGuid[2]);
recvData.ReadByteSeq(unknownGuid[0]);
recvData.ReadByteSeq(unknownGuid[7]);
recvData.ReadByteSeq(unknownGuid[6]);
recvData.ReadByteSeq(unknownGuid[5]);
recvData.ReadByteSeq(unknownGuid[3]);
recvData.ReadByteSeq(unknownGuid[1]);
recvData.ReadByteSeq(unknownGuid[4]);
// =========================================================================
ObjectGuid playerGuid = GetPlayer()->GetGUID();
ObjectGuid groupGuid = group->GetGUID();
// Confirmed the check, increase the count.
group->SetReadyCheckCount(group->GetReadyCheckCount() + 1);
WorldPacket data(SMSG_RAID_READY_CHECK_RESPONSE, 1 + 1 + 8 + 1 + 8);
data.WriteBit(groupGuid[0]);
data.WriteBit(groupGuid[2]);
data.WriteBit(ready);
data.WriteBit(playerGuid[7]);
data.WriteBit(playerGuid[6]);
data.WriteBit(playerGuid[2]);
data.WriteBit(groupGuid[4]);
data.WriteBit(groupGuid[3]);
data.WriteBit(groupGuid[5]);
data.WriteBit(playerGuid[3]);
data.WriteBit(groupGuid[7]);
data.WriteBit(playerGuid[5]);
data.WriteBit(groupGuid[6]);
data.WriteBit(groupGuid[1]);
data.WriteBit(playerGuid[0]);
data.WriteBit(playerGuid[1]);
data.WriteBit(playerGuid[4]);
data.FlushBits();
data.WriteByteSeq(playerGuid[1]);
data.WriteByteSeq(groupGuid[5]);
data.WriteByteSeq(playerGuid[2]);
data.WriteByteSeq(groupGuid[7]);
data.WriteByteSeq(groupGuid[0]);
data.WriteByteSeq(playerGuid[4]);
data.WriteByteSeq(playerGuid[3]);
data.WriteByteSeq(groupGuid[4]);
data.WriteByteSeq(playerGuid[7]);
data.WriteByteSeq(groupGuid[6]);
data.WriteByteSeq(playerGuid[5]);
data.WriteByteSeq(groupGuid[2]);
data.WriteByteSeq(groupGuid[1]);
data.WriteByteSeq(groupGuid[3]);
data.WriteByteSeq(playerGuid[0]);
data.WriteByteSeq(playerGuid[6]);
group->BroadcastReadyCheck(&data); // BroadcastPacket(&data, true);
// Send SMSG_RAID_READY_CHECK_COMPLETED if needed.
if (group->GetReadyCheckCount() >= group->GetMembersCount())
{
ObjectGuid grpGUID = group->GetGUID();
bool checkCompleted = true;
data.Initialize(SMSG_RAID_READY_CHECK_COMPLETED);
uint8 bitOrder[8] = { 1, 5, 6, 3, 2, 7, 0, 4 };
data.WriteBitInOrder(grpGUID, bitOrder);
data.FlushBits();
data.WriteByteSeq(grpGUID[4]);
//.........这里部分代码省略.........
示例13: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
if (err <= 0)
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
SendPacket(&data);
return;
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bracketEntry, false, false, 0, 0, 0);
uint32 avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet
WorldPacket data;
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, queueSlot, STATUS_WAIT_QUEUE, avgWaitTime, 0, 0, TEAM_NEUTRAL);
SendPacket(&data);
}
// check if group can queue:
else
{
Group* grp = _player->GetGroup();
// no group or not a leader
if (!grp || grp->GetLeaderGUID() != _player->GetGUID())
return;
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
err = ERR_IN_RANDOM_BG;
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
err = ERR_IN_NON_RANDOM_BG;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
if (err > 0)
err = grp->CanJoinBattlegroundQueue(bgt, bgQueueTypeId, 0, bgt->GetMaxPlayersPerTeam(), false, 0);
bool isPremade = (grp->GetMembersCount() >= bgt->GetMinPlayersPerTeam() && bgTypeId != BATTLEGROUND_RB);
uint32 avgWaitTime = 0;
if (err > 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, false, isPremade, 0, 0, 0);
avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
}
WorldPacket data;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member)
continue;
if (err <= 0)
{
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
continue;
}
uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, queueSlot, STATUS_WAIT_QUEUE, avgWaitTime, 0, 0, TEAM_NEUTRAL);
member->GetSession()->SendPacket(&data);
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
}
}
}
示例14: HandleBattlemasterJoinOpcode
//.........这里部分代码省略.........
{
//player is already in random queue
WorldPacket data;
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
if(_player->InBattleGroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
//player is already in queue, can't start random queue
WorldPacket data;
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_NON_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
{
WorldPacket data;
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
_player->GetSession()->SendPacket(&data);
return;
}
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) &&
(grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
}
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
// _player->GetGroup() was already checked, grp is already initialized
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
if (joinAsGroup)
{
GroupQueueInfo * ginfo;
uint32 avgTime;
if(err > 0)
{
DEBUG_LOG("Battleground: the following players are joining as group:");
ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0);
avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
}
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player *member = itr->getSource();
if(!member)
continue; // this should never happen
WorldPacket data;
if(err <= 0)
{
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
continue;
}
// add to queue
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
member->GetSession()->SendPacket(&data);
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err);
member->GetSession()->SendPacket(&data);
DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,member->GetGUIDLow(), member->GetName());
}
DEBUG_LOG("Battleground: group end");
}
else
{
GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, 0, false, isPremade, 0);
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
// already checked if queueSlot is valid, now just get it
uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType);
SendPacket(&data);
DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName());
}
sBattleGroundMgr.ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
示例15: BattleGroundMsg
void ChatLog::BattleGroundMsg(Player *player, std::string &msg, uint32 type)
{
if (!_ChatCommon(CHAT_LOG_BATTLEGROUND, player, msg)) return;
CheckDateSwitch();
std::string log_str = "";
log_str.append("[");
log_str.append(player->GetName());
switch (type)
{
case CHAT_MSG_BATTLEGROUND:
log_str.append("]->BG:");
break;
case CHAT_MSG_BATTLEGROUND_LEADER:
log_str.append("]->BG_LEADER:");
break;
default:
log_str.append("]->BG_UNKNOWN:");
}
Group *group = player->GetGroup();
if (!group)
{
log_str.append("[unknown group] ");
}
else
{
// obtain group information
log_str.append("[");
uint8 gm_count = group->GetMembersCount();
uint8 gm_count_m1 = gm_count - 1;
ObjectGuid gm_leader_GUID = group->GetLeaderGuid();
Player *gm_member;
gm_member = sObjectMgr.GetPlayer(gm_leader_GUID);
if (gm_member)
{
log_str.append(gm_member->GetName());
log_str.append(",");
}
Group::MemberSlotList g_members = group->GetMemberSlots();
for (Group::member_citerator itr = g_members.begin(); itr != g_members.end(); itr++)
{
if (itr->guid == gm_leader_GUID) continue;
gm_member = sObjectMgr.GetPlayer(itr->guid);
if (gm_member)
{
log_str.append(itr->name);
log_str.append(",");
}
}
log_str.erase(log_str.length() - 1);
log_str.append("] ");
}
log_str.append(msg);
log_str.append("\n");
if (screenflag[CHAT_LOG_BATTLEGROUND]) printf("%s", log_str.c_str());
if (files[CHAT_LOG_BATTLEGROUND])
{
OutTimestamp(files[CHAT_LOG_BATTLEGROUND]);
fprintf(files[CHAT_LOG_BATTLEGROUND], "%s", log_str.c_str());
fflush(files[CHAT_LOG_BATTLEGROUND]);
}
}