mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[7336] Implemented new BattleGroundQueue invitation system. Now it supports premade group versus premade group matches.
Added 2 new config options - InvitationType and PremadeGroupWaitForMatch - you can find more info in default config file. This patch can cause crashes. Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
872d791ca6
commit
8f995ce904
14 changed files with 860 additions and 940 deletions
|
|
@ -39,7 +39,7 @@ BattleGround::BattleGround()
|
|||
m_Status = 0;
|
||||
m_EndTime = 0;
|
||||
m_LastResurrectTime = 0;
|
||||
m_QueueId = MAX_BATTLEGROUND_QUEUES;
|
||||
m_QueueId = QUEUE_ID_MAX_LEVEL_19;
|
||||
m_InvitedAlliance = 0;
|
||||
m_InvitedHorde = 0;
|
||||
m_ArenaType = 0;
|
||||
|
|
@ -130,8 +130,6 @@ void BattleGround::Update(uint32 diff)
|
|||
//BG is empty
|
||||
return;
|
||||
|
||||
WorldPacket data;
|
||||
|
||||
if(GetRemovedPlayersSize())
|
||||
{
|
||||
for(std::map<uint64, uint8>::iterator itr = m_RemovedPlayers.begin(); itr != m_RemovedPlayers.end(); ++itr)
|
||||
|
|
@ -139,16 +137,6 @@ void BattleGround::Update(uint32 diff)
|
|||
Player *plr = objmgr.GetPlayer(itr->first);
|
||||
switch(itr->second)
|
||||
{
|
||||
//following code is handled by event:
|
||||
/*case 0:
|
||||
sBattleGroundMgr.m_BattleGroundQueues[GetTypeID()].RemovePlayer(itr->first);
|
||||
//RemovePlayerFromQueue(itr->first);
|
||||
if(plr)
|
||||
{
|
||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattleGroundQueueIndex(m_TypeID), STATUS_NONE, 0, 0);
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
break;*/
|
||||
case 1: // currently in bg and was removed from bg
|
||||
if(plr)
|
||||
RemovePlayerAtLeave(itr->first, true, true);
|
||||
|
|
@ -874,7 +862,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
|
|||
// this method is called when no players remains in battleground
|
||||
void BattleGround::Reset()
|
||||
{
|
||||
SetQueueId(MAX_BATTLEGROUND_QUEUES);
|
||||
SetQueueId(QUEUE_ID_MAX_LEVEL_19);
|
||||
SetWinner(WINNER_NONE);
|
||||
SetStatus(STATUS_WAIT_QUEUE);
|
||||
SetStartTime(0);
|
||||
|
|
@ -1009,7 +997,7 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid,
|
|||
void BattleGround::AddToBGFreeSlotQueue()
|
||||
{
|
||||
// make sure to add only once
|
||||
if(!m_InBGFreeSlotQueue)
|
||||
if(!m_InBGFreeSlotQueue && isBattleGround())
|
||||
{
|
||||
sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].push_front(this);
|
||||
m_InBGFreeSlotQueue = true;
|
||||
|
|
@ -1033,61 +1021,12 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
|
|||
}
|
||||
|
||||
// get the number of free slots for team
|
||||
// works in similar way that HasFreeSlotsForTeam did, but this is needed for join as group
|
||||
// returns the number how many players can join battleground to MaxPlayersPerTeam
|
||||
uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
|
||||
{
|
||||
//if BG is starting ... invite anyone
|
||||
if (GetStatus() == STATUS_WAIT_JOIN)
|
||||
if (GetStatus() == STATUS_WAIT_JOIN || GetStatus() == STATUS_IN_PROGRESS)
|
||||
return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
|
||||
//if BG is already started .. do not allow to join too much players of one faction
|
||||
uint32 otherTeam;
|
||||
uint32 otherIn;
|
||||
if (Team == ALLIANCE)
|
||||
{
|
||||
otherTeam = GetInvitedCount(HORDE);
|
||||
otherIn = GetPlayersCountByTeam(HORDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
otherTeam = GetInvitedCount(ALLIANCE);
|
||||
otherIn = GetPlayersCountByTeam(ALLIANCE);
|
||||
}
|
||||
if (GetStatus() == STATUS_IN_PROGRESS)
|
||||
{
|
||||
// difference based on ppl invited (not necessarily entered battle)
|
||||
// default: allow 0
|
||||
uint32 diff = 0;
|
||||
// allow join one person if the sides are equal (to fill up bg to minplayersperteam)
|
||||
if (otherTeam == GetInvitedCount(Team))
|
||||
diff = 1;
|
||||
// allow join more ppl if the other side has more players
|
||||
else if(otherTeam > GetInvitedCount(Team))
|
||||
diff = otherTeam - GetInvitedCount(Team);
|
||||
|
||||
// difference based on max players per team (don't allow inviting more)
|
||||
uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
|
||||
|
||||
// difference based on players who already entered
|
||||
// default: allow 0
|
||||
uint32 diff3 = 0;
|
||||
// allow join one person if the sides are equal (to fill up bg minplayersperteam)
|
||||
if (otherIn == GetPlayersCountByTeam(Team))
|
||||
diff3 = 1;
|
||||
// allow join more ppl if the other side has more players
|
||||
else if (otherIn > GetPlayersCountByTeam(Team))
|
||||
diff3 = otherIn - GetPlayersCountByTeam(Team);
|
||||
// or other side has less than minPlayersPerTeam
|
||||
else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
|
||||
diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
|
||||
|
||||
// return the minimum of the 3 differences
|
||||
|
||||
// min of diff and diff 2
|
||||
diff = diff < diff2 ? diff : diff2;
|
||||
|
||||
// min of diff, diff2 and diff3
|
||||
return diff < diff3 ? diff : diff3 ;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue