mirror of
https://github.com/mangosfour/server.git
synced 2025-12-24 01:37:02 +00:00
[7436] Fixed Average Wait time for all BG/arena queue types. Patch has been made together with Balrok. Thx for help.
Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
2c787373c5
commit
6a24242cb5
4 changed files with 110 additions and 95 deletions
|
|
@ -156,10 +156,11 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
// if we're here, then the conditions to join a bg are met. We can proceed in joining.
|
// 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
|
// _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()*/)
|
if(joinAsGroup /* && _player->GetGroup()*/)
|
||||||
{
|
{
|
||||||
sLog.outDebug("Battleground: the following players are joining as group:");
|
sLog.outDebug("Battleground: the following players are joining as group:");
|
||||||
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, 0, false, isPremade, 0);
|
|
||||||
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||||
{
|
{
|
||||||
Player *member = itr->getSource();
|
Player *member = itr->getSource();
|
||||||
|
|
@ -172,7 +173,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
// send status packet (in queue)
|
// send status packet (in queue)
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0);
|
||||||
member->GetSession()->SendPacket(&data);
|
member->GetSession()->SendPacket(&data);
|
||||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
||||||
member->GetSession()->SendPacket(&data);
|
member->GetSession()->SendPacket(&data);
|
||||||
|
|
@ -180,9 +181,6 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
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: 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");
|
sLog.outDebug("Battleground: group end");
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
|
||||||
if(!ginfo->IsInvitedToBGInstanceGUID)
|
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -193,16 +191,15 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
// send status packet (in queue)
|
// send status packet (in queue)
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
|
|
||||||
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, 0, false, false, 0);
|
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(_player, ginfo);
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(_player, ginfo);
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
|
||||||
if(!ginfo->IsInvitedToBGInstanceGUID)
|
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
|
|
||||||
sLog.outDebug("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName());
|
sLog.outDebug("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName());
|
||||||
}
|
}
|
||||||
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
||||||
|
if(!ginfo->IsInvitedToBGInstanceGUID)
|
||||||
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv_data*/ )
|
void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv_data*/ )
|
||||||
|
|
@ -319,22 +316,16 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
|
||||||
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
||||||
// if the player is not in queue, continue
|
// if the player is not in queue, continue or no group information - this should never happen
|
||||||
if(itrPlayerStatus == qpMap.end())
|
if(itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo)
|
||||||
continue;
|
|
||||||
|
|
||||||
// no group information, this should never happen
|
|
||||||
if(!itrPlayerStatus->second.GroupInfo)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BattleGround * bg = NULL;
|
BattleGround * bg = NULL;
|
||||||
|
|
||||||
// get possibly needed data from groupinfo
|
// get possibly needed data from groupinfo
|
||||||
uint8 arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
|
uint8 arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
|
||||||
uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated;
|
uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated;
|
||||||
uint8 status = 0;
|
uint8 status = 0;
|
||||||
|
|
||||||
|
|
||||||
if(!itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID)
|
if(!itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID)
|
||||||
{
|
{
|
||||||
// not invited to bg, get template
|
// not invited to bg, get template
|
||||||
|
|
@ -530,75 +521,40 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
|
||||||
sLog.outDebug( "WORLD: Battleground status" );
|
sLog.outDebug( "WORLD: Battleground status" );
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
|
uint32 queueSlot = PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||||
|
|
||||||
// TODO: we must put player back to battleground in case disconnect (< 5 minutes offline time) or teleport player on login(!) from battleground map to entry point
|
|
||||||
if(_player->InBattleGround())
|
if(_player->InBattleGround())
|
||||||
{
|
{
|
||||||
BattleGround *bg = _player->GetBattleGround();
|
BattleGround *bg = _player->GetBattleGround();
|
||||||
if(bg)
|
if(!bg)
|
||||||
|
return;
|
||||||
|
BattleGroundQueueTypeId bgQueueTypeId_tmp = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
|
||||||
|
queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId_tmp);
|
||||||
|
if((bg->GetStatus() <= STATUS_IN_PROGRESS))
|
||||||
{
|
{
|
||||||
BattleGroundQueueTypeId bgQueueTypeId_tmp = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
|
||||||
uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId_tmp);
|
SendPacket(&data);
|
||||||
if((bg->GetStatus() <= STATUS_IN_PROGRESS))
|
|
||||||
{
|
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
|
|
||||||
SendPacket(&data);
|
|
||||||
}
|
|
||||||
for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
|
|
||||||
{
|
|
||||||
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
|
|
||||||
if (i == queueSlot || !bgQueueTypeId)
|
|
||||||
continue;
|
|
||||||
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
|
||||||
uint8 arenatype = BattleGroundMgr::BGArenaType(bgQueueTypeId);
|
|
||||||
uint8 isRated = 0;
|
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
|
||||||
if(itrPlayerStatus == qpMap.end())
|
|
||||||
continue;
|
|
||||||
if(itrPlayerStatus->second.GroupInfo)
|
|
||||||
{
|
|
||||||
arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
|
|
||||||
isRated = itrPlayerStatus->second.GroupInfo->IsRated;
|
|
||||||
}
|
|
||||||
BattleGround *bg2 = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
|
||||||
if(bg2)
|
|
||||||
{
|
|
||||||
//in this call is small bug, this call should be filled by player's waiting time in queue
|
|
||||||
//this call nulls all timers for client :
|
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg2, i, STATUS_WAIT_QUEUE, 0, 0,arenatype);
|
|
||||||
SendPacket(&data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
// we should update all queues? .. i'm not sure if this code is correct
|
||||||
|
for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
|
||||||
{
|
{
|
||||||
// we should update all queues? .. i'm not sure if this code is correct
|
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
|
||||||
for (uint32 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
|
if(!bgQueueTypeId || i == queueSlot) //queueslot check in case we already send it in the above code
|
||||||
{
|
continue;
|
||||||
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
|
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
||||||
if(!bgQueueTypeId)
|
uint8 arenatype = BattleGroundMgr::BGArenaType(bgQueueTypeId);
|
||||||
continue;
|
BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
||||||
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
|
if(!bg)
|
||||||
uint8 arenatype = BattleGroundMgr::BGArenaType(bgQueueTypeId);
|
continue;
|
||||||
uint8 isRated = 0;
|
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
||||||
BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
|
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
||||||
BattleGroundQueue::QueuedPlayersMap& qpMap = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].m_QueuedPlayers;
|
if(itrPlayerStatus == qpMap.end() || !itrPlayerStatus->second.GroupInfo)
|
||||||
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus = qpMap.find(_player->GetGUID());
|
continue;
|
||||||
if(itrPlayerStatus == qpMap.end())
|
arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
|
||||||
continue;
|
uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(itrPlayerStatus->second.GroupInfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
||||||
if(itrPlayerStatus->second.GroupInfo)
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_QUEUE, avgTime, getMSTime()-itrPlayerStatus->second.GroupInfo->JoinTime, arenatype);
|
||||||
{
|
SendPacket(&data);
|
||||||
arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
|
|
||||||
isRated = itrPlayerStatus->second.GroupInfo->IsRated;
|
|
||||||
}
|
|
||||||
if(bg)
|
|
||||||
{
|
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_QUEUE, 0, 0, arenatype);
|
|
||||||
SendPacket(&data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -762,9 +718,10 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data )
|
||||||
arenaRating = avg_pers_rating;
|
arenaRating = avg_pers_rating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, arenatype, isRated, false, arenaRating, ateamId);
|
||||||
|
uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
||||||
if(asGroup)
|
if(asGroup)
|
||||||
{
|
{
|
||||||
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, arenatype, isRated, false, arenaRating, ateamId);
|
|
||||||
sLog.outDebug("Battleground: arena join as group start");
|
sLog.outDebug("Battleground: arena join as group start");
|
||||||
if(isRated)
|
if(isRated)
|
||||||
sLog.outDebug("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype);
|
sLog.outDebug("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype);
|
||||||
|
|
@ -780,7 +737,7 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data )
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
// send status packet (in queue)
|
// send status packet (in queue)
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0, arenatype);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
|
||||||
member->GetSession()->SendPacket(&data);
|
member->GetSession()->SendPacket(&data);
|
||||||
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bgTypeId);
|
||||||
member->GetSession()->SendPacket(&data);
|
member->GetSession()->SendPacket(&data);
|
||||||
|
|
@ -788,7 +745,6 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data )
|
||||||
sLog.outDebug("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());
|
sLog.outDebug("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());
|
||||||
}
|
}
|
||||||
sLog.outDebug("Battleground: arena join as group end");
|
sLog.outDebug("Battleground: arena join as group end");
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenatype, isRated, arenaRating);
|
|
||||||
if(isRated)
|
if(isRated)
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AnnounceWorld(ginfo, _player->GetGUID(), true);
|
||||||
}
|
}
|
||||||
|
|
@ -801,13 +757,12 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data )
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
// send status packet (in queue)
|
// send status packet (in queue)
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0, arenatype);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
GroupQueueInfo * ginfo = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddGroup(_player, bgTypeId, arenatype, isRated, false, arenaRating);
|
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(_player, ginfo);
|
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].AddPlayer(_player, ginfo);
|
||||||
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenatype, isRated, arenaRating);
|
|
||||||
sLog.outDebug("Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName());
|
sLog.outDebug("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.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId), arenatype, isRated, arenaRating);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleBattleGroundReportAFK( WorldPacket & recv_data )
|
void WorldSession::HandleBattleGroundReportAFK( WorldPacket & recv_data )
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,16 @@ INSTANTIATE_SINGLETON_1( BattleGroundMgr );
|
||||||
|
|
||||||
BattleGroundQueue::BattleGroundQueue()
|
BattleGroundQueue::BattleGroundQueue()
|
||||||
{
|
{
|
||||||
|
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
for(uint32 j = 0; j < MAX_BATTLEGROUND_QUEUES; j++)
|
||||||
|
{
|
||||||
|
m_SumOfWaitTimes[i][j] = 0;
|
||||||
|
m_WaitTimeLastPlayer[i][j] = 0;
|
||||||
|
for(uint32 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; k++)
|
||||||
|
m_WaitTimes[i][j][k] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleGroundQueue::~BattleGroundQueue()
|
BattleGroundQueue::~BattleGroundQueue()
|
||||||
|
|
@ -149,7 +159,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId
|
||||||
ginfo->ArenaTeamId = arenateamid;
|
ginfo->ArenaTeamId = arenateamid;
|
||||||
ginfo->IsRated = isRated;
|
ginfo->IsRated = isRated;
|
||||||
ginfo->IsInvitedToBGInstanceGUID = 0;
|
ginfo->IsInvitedToBGInstanceGUID = 0;
|
||||||
ginfo->JoinTime = getMSTime();
|
ginfo->JoinTime = sWorld.GetGameTime() * IN_MILISECONDS;
|
||||||
ginfo->Team = leader->GetTeam();
|
ginfo->Team = leader->GetTeam();
|
||||||
ginfo->ArenaTeamRating = arenaRating;
|
ginfo->ArenaTeamRating = arenaRating;
|
||||||
ginfo->OpponentsTeamRating = 0;
|
ginfo->OpponentsTeamRating = 0;
|
||||||
|
|
@ -175,8 +185,6 @@ void BattleGroundQueue::AddPlayer(Player *plr, GroupQueueInfo *ginfo)
|
||||||
{
|
{
|
||||||
//if player isn't in queue, he is added, if already is, then values are overwritten, no memory leak
|
//if player isn't in queue, he is added, if already is, then values are overwritten, no memory leak
|
||||||
PlayerQueueInfo& info = m_QueuedPlayers[plr->GetGUID()];
|
PlayerQueueInfo& info = m_QueuedPlayers[plr->GetGUID()];
|
||||||
info.InviteTime = 0;
|
|
||||||
info.LastInviteTime = 0;
|
|
||||||
info.LastOnlineTime = getMSTime();
|
info.LastOnlineTime = getMSTime();
|
||||||
info.GroupInfo = ginfo;
|
info.GroupInfo = ginfo;
|
||||||
|
|
||||||
|
|
@ -184,6 +192,55 @@ void BattleGroundQueue::AddPlayer(Player *plr, GroupQueueInfo *ginfo)
|
||||||
ginfo->Players[plr->GetGUID()] = &info;
|
ginfo->Players[plr->GetGUID()] = &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
|
||||||
|
{
|
||||||
|
uint32 timeInQueue = (sWorld.GetGameTime() * IN_MILISECONDS) - ginfo->JoinTime;
|
||||||
|
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||||
|
if( !ginfo->ArenaType )
|
||||||
|
{
|
||||||
|
if( ginfo->Team == HORDE )
|
||||||
|
team_index = BG_TEAM_HORDE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( ginfo->IsRated )
|
||||||
|
team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE
|
||||||
|
}
|
||||||
|
|
||||||
|
//store pointer to arrayindex of player that was added first
|
||||||
|
uint32* lastPlayerAddedPointer = &(m_WaitTimeLastPlayer[team_index][queue_id]);
|
||||||
|
//remove his time from sum
|
||||||
|
m_SumOfWaitTimes[team_index][queue_id] -= m_WaitTimes[team_index][queue_id][(*lastPlayerAddedPointer)];
|
||||||
|
//set average time to new
|
||||||
|
m_WaitTimes[team_index][queue_id][(*lastPlayerAddedPointer)] = timeInQueue;
|
||||||
|
//add new time to sum
|
||||||
|
m_SumOfWaitTimes[team_index][queue_id] += timeInQueue;
|
||||||
|
//set index of last player added to next one
|
||||||
|
(*lastPlayerAddedPointer)++;
|
||||||
|
(*lastPlayerAddedPointer) %= COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id)
|
||||||
|
{
|
||||||
|
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||||
|
if( !ginfo->ArenaType )
|
||||||
|
{
|
||||||
|
if( ginfo->Team == HORDE )
|
||||||
|
team_index = BG_TEAM_HORDE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( ginfo->IsRated )
|
||||||
|
team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE
|
||||||
|
}
|
||||||
|
//check if there is enought values(we always add values > 0)
|
||||||
|
if(m_WaitTimes[team_index][queue_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1] )
|
||||||
|
return (m_SumOfWaitTimes[team_index][queue_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME);
|
||||||
|
else
|
||||||
|
//if there aren't enough values return 0 - not available
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//remove player from queue and from group info, if group info is empty then remove it too
|
//remove player from queue and from group info, if group info is empty then remove it too
|
||||||
void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCount)
|
void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCount)
|
||||||
{
|
{
|
||||||
|
|
@ -373,13 +430,10 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||||
// set invitation
|
// set invitation
|
||||||
ginfo->IsInvitedToBGInstanceGUID = bg->GetInstanceID();
|
ginfo->IsInvitedToBGInstanceGUID = bg->GetInstanceID();
|
||||||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
|
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
|
||||||
|
BGQueueIdBasedOnLevel queue_id = bg->GetQueueId();
|
||||||
// loop through the players
|
// loop through the players
|
||||||
for(std::map<uint64,PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
|
for(std::map<uint64,PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
|
||||||
{
|
{
|
||||||
// set status
|
|
||||||
itr->second->InviteTime = getMSTime();
|
|
||||||
itr->second->LastInviteTime = getMSTime();
|
|
||||||
|
|
||||||
// get the player
|
// get the player
|
||||||
Player* plr = objmgr.GetPlayer(itr->first);
|
Player* plr = objmgr.GetPlayer(itr->first);
|
||||||
// if offline, skip him, this should not happen - player is removed from queue when he logs out
|
// if offline, skip him, this should not happen - player is removed from queue when he logs out
|
||||||
|
|
@ -387,6 +441,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// invite the player
|
// invite the player
|
||||||
|
PlayerInvitedToBGUpdateAverageWaitTime(ginfo, queue_id);
|
||||||
sBattleGroundMgr.InvitePlayer(plr, bg->GetInstanceID(), bg->GetTypeID(), ginfo->Team);
|
sBattleGroundMgr.InvitePlayer(plr, bg->GetInstanceID(), bg->GetTypeID(), ginfo->Team);
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,11 @@ typedef std::list<BattleGround*> BGFreeSlotQueueType;
|
||||||
typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
|
typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
|
||||||
|
|
||||||
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
|
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
|
||||||
|
#define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10
|
||||||
|
|
||||||
struct GroupQueueInfo; // type predefinition
|
struct GroupQueueInfo; // type predefinition
|
||||||
struct PlayerQueueInfo // stores information for players in queue
|
struct PlayerQueueInfo // stores information for players in queue
|
||||||
{
|
{
|
||||||
uint32 InviteTime; // first invite time
|
|
||||||
uint32 LastInviteTime; // last invite time
|
|
||||||
uint32 LastOnlineTime; // for tracking and removing offline players from queue after 5 minutes
|
uint32 LastOnlineTime; // for tracking and removing offline players from queue after 5 minutes
|
||||||
GroupQueueInfo * GroupInfo; // pointer to the associated groupqueueinfo
|
GroupQueueInfo * GroupInfo; // pointer to the associated groupqueueinfo
|
||||||
};
|
};
|
||||||
|
|
@ -79,6 +78,9 @@ class BattleGroundQueue
|
||||||
GroupQueueInfo * AddGroup(Player * leader, BattleGroundTypeId bgTypeId, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 ArenaTeamId = 0);
|
GroupQueueInfo * AddGroup(Player * leader, BattleGroundTypeId bgTypeId, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 ArenaTeamId = 0);
|
||||||
void AddPlayer(Player *plr, GroupQueueInfo *ginfo);
|
void AddPlayer(Player *plr, GroupQueueInfo *ginfo);
|
||||||
void RemovePlayer(const uint64& guid, bool decreaseInvitedCount);
|
void RemovePlayer(const uint64& guid, bool decreaseInvitedCount);
|
||||||
|
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id);
|
||||||
|
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BGQueueIdBasedOnLevel queue_id);
|
||||||
|
|
||||||
void DecreaseGroupLength(uint32 queueId, uint32 AsGroup);
|
void DecreaseGroupLength(uint32 queueId, uint32 AsGroup);
|
||||||
void BGEndedRemoveInvites(BattleGround * bg);
|
void BGEndedRemoveInvites(BattleGround * bg);
|
||||||
void AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playerGUID, bool isAddedToQueue);
|
void AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playerGUID, bool isAddedToQueue);
|
||||||
|
|
@ -120,6 +122,9 @@ class BattleGroundQueue
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side);
|
bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, uint32 side);
|
||||||
|
uint32 m_WaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME];
|
||||||
|
uint32 m_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES];
|
||||||
|
uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_QUEUES];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7435"
|
#define REVISION_NR "7436"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue