mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-15 08:16:08 +00:00
feat(Core/Battleground): rework bg queue system (#10817)
This commit is contained in:
@@ -248,7 +248,10 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
|
||||
m_swingErrorMsg = 0;
|
||||
|
||||
for (uint8 j = 0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; ++j)
|
||||
m_bgBattlegroundQueueID[j] = BATTLEGROUND_QUEUE_NONE;
|
||||
{
|
||||
_BgBattlegroundQueueID[j].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
|
||||
_BgBattlegroundQueueID[j].invitedToInstance = 0;
|
||||
}
|
||||
|
||||
m_logintime = GameTime::GetGameTime().count();
|
||||
m_Last_tick = m_logintime;
|
||||
@@ -11025,6 +11028,8 @@ void Player::LeaveBattleground(Battleground* bg)
|
||||
sScriptMgr->OnBattlegroundDesertion(this, BG_DESERTION_TYPE_LEAVE_BG);
|
||||
}
|
||||
|
||||
bg->RemovePlayerAtLeave(this);
|
||||
|
||||
// xinef: reset corpse reclaim time
|
||||
m_deathExpireTime = GameTime::GetGameTime().count();
|
||||
|
||||
@@ -11853,10 +11858,102 @@ Battleground* Player::GetBattleground(bool create) const
|
||||
if (GetBattlegroundId() == 0)
|
||||
return nullptr;
|
||||
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(GetBattlegroundId());
|
||||
Battleground* bg = sBattlegroundMgr->GetBattleground(GetBattlegroundId(), GetBattlegroundTypeId());
|
||||
return (create || (bg && bg->FindBgMap()) ? bg : nullptr);
|
||||
}
|
||||
|
||||
bool Player::InBattlegroundQueue(bool ignoreArena) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE &&
|
||||
(!ignoreArena || (_BgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_2v2 &&
|
||||
_BgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_3v3 &&
|
||||
_BgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_5v5)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BattlegroundQueueTypeId Player::GetBattlegroundQueueTypeId(uint32 index) const
|
||||
{
|
||||
return _BgBattlegroundQueueID[index].bgQueueTypeId;
|
||||
}
|
||||
|
||||
uint32 Player::GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return i;
|
||||
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
bool Player::IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
return _BgBattlegroundQueueID[i].invitedToInstance != 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const
|
||||
{
|
||||
return GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || _BgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
_BgBattlegroundQueueID[i].bgQueueTypeId = val;
|
||||
_BgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return PLAYER_MAX_BATTLEGROUND_QUEUES;
|
||||
}
|
||||
|
||||
bool Player::HasFreeBattlegroundQueueId() const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Player::RemoveBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
{
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == val)
|
||||
{
|
||||
_BgBattlegroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
|
||||
_BgBattlegroundQueueID[i].invitedToInstance = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId)
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
|
||||
_BgBattlegroundQueueID[i].invitedToInstance = instanceId;
|
||||
}
|
||||
|
||||
bool Player::IsInvitedForBattlegroundInstance(uint32 instanceId) const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (_BgBattlegroundQueueID[i].invitedToInstance == instanceId)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::InArena() const
|
||||
{
|
||||
Battleground* bg = GetBattleground();
|
||||
@@ -11868,16 +11965,6 @@ bool Player::InArena() const
|
||||
|
||||
void Player::SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
|
||||
{
|
||||
// if leaving current bg (and was invited) - decrease invited count for current one
|
||||
if (m_bgData.bgInstanceID && m_bgData.isInvited)
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattleground(m_bgData.bgInstanceID))
|
||||
bg->DecreaseInvitedCount(m_bgData.bgTeamId);
|
||||
|
||||
// if entering new bg (and is invited) - increase invited count for new one
|
||||
if (id && invited)
|
||||
if (Battleground* bg = sBattlegroundMgr->GetBattleground(id))
|
||||
bg->IncreaseInvitedCount(teamId);
|
||||
|
||||
m_bgData.bgInstanceID = id;
|
||||
m_bgData.bgTypeID = bgTypeId;
|
||||
m_bgData.bgQueueSlot = queueSlot;
|
||||
|
||||
Reference in New Issue
Block a user