feat(Core/BGQueue): rework queue announce (#6114)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1622504741914151600');
|
||||||
|
|
||||||
|
DELETE FROM `acore_string` WHERE `entry` IN (713, 726);
|
||||||
|
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
|
||||||
|
(713, 'Queue status for %s (skirmish %s) (Lvl: %u to %u)\nQueued: %u (Need at least %u more)'),
|
||||||
|
(726, '|cffff0000[Arena Queue]:|r %s (skirmish %s) -- [%u-%u] [%u/%u]|r');
|
||||||
@@ -4,10 +4,11 @@
|
|||||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "BattlegroundQueue.h"
|
||||||
#include "ArenaTeam.h"
|
#include "ArenaTeam.h"
|
||||||
#include "ArenaTeamMgr.h"
|
#include "ArenaTeamMgr.h"
|
||||||
#include "BattlegroundMgr.h"
|
#include "BattlegroundMgr.h"
|
||||||
#include "BattlegroundQueue.h"
|
#include "BattlegroundSpamProtect.h"
|
||||||
#include "Channel.h"
|
#include "Channel.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
@@ -18,8 +19,6 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
std::unordered_map<ObjectGuid, uint32> BGSpamProtection;
|
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
/*** BATTLEGROUND QUEUE SYSTEM ***/
|
/*** BATTLEGROUND QUEUE SYSTEM ***/
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
@@ -147,13 +146,12 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi
|
|||||||
|
|
||||||
sScriptMgr->OnAddGroup(this, ginfo, index, leader, grp, bracketEntry, isPremade);
|
sScriptMgr->OnAddGroup(this, ginfo, index, leader, grp, bracketEntry, isPremade);
|
||||||
|
|
||||||
|
LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId: %u, bracket_id: %u, index: %u", m_bgTypeId, bracketId, index);
|
||||||
|
|
||||||
// pussywizard: store indices at which GroupQueueInfo is in m_QueuedGroups
|
// pussywizard: store indices at which GroupQueueInfo is in m_QueuedGroups
|
||||||
ginfo->_bracketId = bracketId;
|
ginfo->_bracketId = bracketId;
|
||||||
ginfo->_groupType = index;
|
ginfo->_groupType = index;
|
||||||
|
|
||||||
// announce world (this doesn't need mutex)
|
|
||||||
SendMessageArenaQueue(ginfo, true);
|
|
||||||
|
|
||||||
//add players from group to ginfo
|
//add players from group to ginfo
|
||||||
if (grp)
|
if (grp)
|
||||||
{
|
{
|
||||||
@@ -178,6 +176,9 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi
|
|||||||
//add GroupInfo to m_QueuedGroups
|
//add GroupInfo to m_QueuedGroups
|
||||||
m_QueuedGroups[bracketId][index].push_back(ginfo);
|
m_QueuedGroups[bracketId][index].push_back(ginfo);
|
||||||
|
|
||||||
|
// announce world (this doesn't need mutex)
|
||||||
|
SendJoinMessageArenaQueue(leader, ginfo, bracketEntry, isRated);
|
||||||
|
|
||||||
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId);
|
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId);
|
||||||
if (!bg)
|
if (!bg)
|
||||||
return ginfo;
|
return ginfo;
|
||||||
@@ -296,7 +297,7 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 play
|
|||||||
m_QueuedPlayers.erase(itr);
|
m_QueuedPlayers.erase(itr);
|
||||||
|
|
||||||
// announce to world if arena team left queue for rated match, show only once
|
// announce to world if arena team left queue for rated match, show only once
|
||||||
SendMessageArenaQueue(groupInfo, false);
|
SendExitMessageArenaQueue(groupInfo);
|
||||||
|
|
||||||
// if player leaves queue and he is invited to a rated arena match, then count it as he lost
|
// if player leaves queue and he is invited to a rated arena match, then count it as he lost
|
||||||
if (groupInfo->IsInvitedToBGInstanceGUID && groupInfo->IsRated && !sentToBg)
|
if (groupInfo->IsInvitedToBGInstanceGUID && groupInfo->IsRated && !sentToBg)
|
||||||
@@ -716,6 +717,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id
|
|||||||
// get min and max players per team
|
// get min and max players per team
|
||||||
uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam();
|
uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam();
|
||||||
uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam();
|
uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam();
|
||||||
|
|
||||||
if (bg_template->isArena())
|
if (bg_template->isArena())
|
||||||
{
|
{
|
||||||
MinPlayersPerTeam = sBattlegroundMgr->isArenaTesting() ? 1 : m_arenaType;
|
MinPlayersPerTeam = sBattlegroundMgr->isArenaTesting() ? 1 : m_arenaType;
|
||||||
@@ -968,6 +970,12 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bg->isArena())
|
||||||
|
{
|
||||||
|
// Skip announce for arena skirmish
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||||
char const* bgName = bg->GetName();
|
char const* bgName = bg->GetName();
|
||||||
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
|
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
|
||||||
@@ -978,51 +986,101 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP
|
|||||||
uint32 qAlliance = GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_ALLIANCE);
|
uint32 qAlliance = GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_ALLIANCE);
|
||||||
auto qTotal = qHorde + qAlliance;
|
auto qTotal = qHorde + qAlliance;
|
||||||
|
|
||||||
|
LOG_DEBUG("bg.battleground", "> Queue status for %s (Lvl: %u to %u) Queued: %u (Need at least %u more)",
|
||||||
|
bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers - qTotal);
|
||||||
|
|
||||||
// Show queue status to player only (when joining battleground queue or Arena and arena world announcer is disabled)
|
// Show queue status to player only (when joining battleground queue or Arena and arena world announcer is disabled)
|
||||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY) || (bg->isArena() && !sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE)))
|
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||||
{
|
{
|
||||||
ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
|
ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
|
||||||
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
|
qAlliance,
|
||||||
|
(MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0,
|
||||||
|
qHorde,
|
||||||
|
(MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (!bg->isArena()) // Show queue status to server (when joining battleground queue)
|
else // Show queue status to server (when joining battleground queue)
|
||||||
{
|
{
|
||||||
auto searchGUID = BGSpamProtection.find(leader->GetGUID());
|
if (!sBGSpam->CanAnnounce(leader, bg, q_min_level, qTotal))
|
||||||
|
|
||||||
if (searchGUID == BGSpamProtection.end())
|
|
||||||
{
|
|
||||||
BGSpamProtection[leader->GetGUID()] = 0; // Leader GUID not found, initialize with 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip if spam time < 30 secs (default)
|
|
||||||
if (sWorld->GetGameTime() - BGSpamProtection[leader->GetGUID()] < sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_SPAM_DELAY))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When limited, it announces only if there are at least CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS in queue
|
|
||||||
auto limitQueueMinLevel = sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_LEVEL);
|
|
||||||
if (limitQueueMinLevel != 0 && q_min_level >= limitQueueMinLevel)
|
|
||||||
{
|
|
||||||
// limit only RBG for 80, WSG for lower levels
|
|
||||||
auto bgTypeToLimit = q_min_level == 80 ? BATTLEGROUND_RB : BATTLEGROUND_WS;
|
|
||||||
|
|
||||||
if (bg->GetBgTypeID() == bgTypeToLimit && qTotal < sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BGSpamProtection[leader->GetGUID()] = sWorld->GetGameTime();
|
|
||||||
sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers);
|
sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattlegroundQueue::SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin)
|
void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated)
|
||||||
{
|
{
|
||||||
if (!sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
if (!sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!sScriptMgr->CanSendMessageArenaQueue(this, ginfo, IsJoin))
|
if (!sScriptMgr->CanSendJoinMessageArenaQueue(this, leader, ginfo, bracketEntry, isRated))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!isRated)
|
||||||
|
{
|
||||||
|
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId);
|
||||||
|
if (!bg)
|
||||||
|
{
|
||||||
|
LOG_ERROR("bg.arena", "> Not found bg template for bgtype id %u", uint32(ginfo->BgTypeId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bg->isArena())
|
||||||
|
{
|
||||||
|
// Skip announce for non arena
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||||
|
auto bgName = bg->GetName();
|
||||||
|
auto arenatype = Acore::StringFormat("%uv%u", ginfo->ArenaType, ginfo->ArenaType);
|
||||||
|
uint32 playersNeed = ArenaTeam::GetReqPlayersForType(ginfo->ArenaType);
|
||||||
|
uint32 q_min_level = std::min(bracketEntry->minLevel, (uint32)80);
|
||||||
|
uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32)80);
|
||||||
|
uint32 qPlayers = GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_HORDE) + GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_ALLIANCE);
|
||||||
|
|
||||||
|
LOG_DEBUG("bg.arena", "> Queue status for %s (skirmish %s) (Lvl: %u to %u) Queued: %u (Need at least %u more)",
|
||||||
|
bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed - qPlayers);
|
||||||
|
|
||||||
|
if (sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY))
|
||||||
|
{
|
||||||
|
ChatHandler(leader->GetSession()).PSendSysMessage(LANG_ARENA_QUEUE_ANNOUNCE_SELF,
|
||||||
|
bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed - qPlayers);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!sBGSpam->CanAnnounce(leader, bg, q_min_level, qPlayers))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD, bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(ginfo->ArenaTeamId);
|
||||||
|
if (!team || !ginfo->IsRated)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 ArenaType = ginfo->ArenaType;
|
||||||
|
uint32 ArenaTeamRating = ginfo->ArenaTeamRating;
|
||||||
|
std::string TeamName = team->GetName();
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattlegroundQueue::SendExitMessageArenaQueue(GroupQueueInfo* ginfo)
|
||||||
|
{
|
||||||
|
if (!sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!sScriptMgr->CanExitJoinMessageArenaQueue(this, ginfo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(ginfo->ArenaTeamId);
|
ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(ginfo->ArenaTeamId);
|
||||||
@@ -1036,10 +1094,7 @@ void BattlegroundQueue::SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin
|
|||||||
uint32 ArenaTeamRating = ginfo->ArenaTeamRating;
|
uint32 ArenaTeamRating = ginfo->ArenaTeamRating;
|
||||||
std::string TeamName = team->GetName();
|
std::string TeamName = team->GetName();
|
||||||
|
|
||||||
if (IsJoin)
|
if (ArenaType && ginfo->Players.empty())
|
||||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
|
||||||
|
|
||||||
if (!IsJoin && ArenaType && ginfo->Players.empty())
|
|
||||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
|
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
|
||||||
bool CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
|
bool CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
|
||||||
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
|
bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam);
|
||||||
GroupQueueInfo* AddGroup(Player* leader, Group* group, PvPDifficultyEntry const* bracketEntry, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId);
|
GroupQueueInfo* AddGroup(Player* leader, Group* group, PvPDifficultyEntry const* bracketEntry, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId);
|
||||||
void RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot);
|
void RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot);
|
||||||
bool IsPlayerInvitedToRatedArena(ObjectGuid pl_guid);
|
bool IsPlayerInvitedToRatedArena(ObjectGuid pl_guid);
|
||||||
bool IsPlayerInvited(ObjectGuid pl_guid, uint32 bgInstanceGuid, uint32 removeTime);
|
bool IsPlayerInvited(ObjectGuid pl_guid, uint32 bgInstanceGuid, uint32 removeTime);
|
||||||
@@ -72,7 +72,8 @@ public:
|
|||||||
[[nodiscard]] uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue);
|
[[nodiscard]] uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue);
|
||||||
[[nodiscard]] bool IsAllQueuesEmpty(BattlegroundBracketId bracket_id);
|
[[nodiscard]] bool IsAllQueuesEmpty(BattlegroundBracketId bracket_id);
|
||||||
void SendMessageBGQueue(Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
|
void SendMessageBGQueue(Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
|
||||||
void SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin);
|
void SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated);
|
||||||
|
void SendExitMessageArenaQueue(GroupQueueInfo* ginfo);
|
||||||
|
|
||||||
void SetBgTypeIdAndArenaType(BattlegroundTypeId b, uint8 a) { m_bgTypeId = b; m_arenaType = ArenaType(a); } // pussywizard
|
void SetBgTypeIdAndArenaType(BattlegroundTypeId b, uint8 a) { m_bgTypeId = b; m_arenaType = ArenaType(a); } // pussywizard
|
||||||
void AddEvent(BasicEvent* Event, uint64 e_time);
|
void AddEvent(BasicEvent* Event, uint64 e_time);
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||||
|
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BattlegroundSpamProtect.h"
|
||||||
|
#include "Battleground.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::unordered_map<ObjectGuid /*player guid*/, uint32 /*time*/> _players;
|
||||||
|
|
||||||
|
void AddTime(ObjectGuid guid)
|
||||||
|
{
|
||||||
|
_players.insert_or_assign(guid, sWorld->GetGameTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 GetTime(ObjectGuid guid)
|
||||||
|
{
|
||||||
|
auto const& itr = _players.find(guid);
|
||||||
|
if (itr != _players.end())
|
||||||
|
{
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsCorrectDelay(ObjectGuid guid)
|
||||||
|
{
|
||||||
|
// Skip if spam time < 30 secs (default)
|
||||||
|
return sWorld->GetGameTime() - GetTime(guid) >= sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_SPAM_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BGSpamProtect* BGSpamProtect::instance()
|
||||||
|
{
|
||||||
|
static BGSpamProtect instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BGSpamProtect::CanAnnounce(Player* player, Battleground* bg, uint32 minLevel, uint32 queueTotal)
|
||||||
|
{
|
||||||
|
ObjectGuid guid = player->GetGUID();
|
||||||
|
|
||||||
|
// Check prev time
|
||||||
|
if (!IsCorrectDelay(guid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bg)
|
||||||
|
{
|
||||||
|
// When limited, it announces only if there are at least CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS in queue
|
||||||
|
auto limitQueueMinLevel = sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_LEVEL);
|
||||||
|
if (limitQueueMinLevel && minLevel >= limitQueueMinLevel)
|
||||||
|
{
|
||||||
|
// limit only RBG for 80, WSG for lower levels
|
||||||
|
auto bgTypeToLimit = minLevel == 80 ? BATTLEGROUND_RB : BATTLEGROUND_WS;
|
||||||
|
|
||||||
|
if (bg->GetBgTypeID() == bgTypeToLimit && queueTotal < sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTime(guid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||||
|
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BATTLEGROUND_SPAM_PROTECT_H_
|
||||||
|
#define _BATTLEGROUND_SPAM_PROTECT_H_
|
||||||
|
|
||||||
|
#include "Define.h"
|
||||||
|
|
||||||
|
class Player;
|
||||||
|
class Battleground;
|
||||||
|
|
||||||
|
class AC_GAME_API BGSpamProtect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static BGSpamProtect* instance();
|
||||||
|
|
||||||
|
bool CanAnnounce(Player* player, Battleground* bg, uint32 minLevel, uint32 queueTotal);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define sBGSpam BGSpamProtect::instance()
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -700,9 +700,14 @@ enum AcoreStrings
|
|||||||
LANG_PLAYER_DND_DEFAULT = 709,
|
LANG_PLAYER_DND_DEFAULT = 709,
|
||||||
LANG_PLAYER_AFK_DEFAULT = 710,
|
LANG_PLAYER_AFK_DEFAULT = 710,
|
||||||
|
|
||||||
|
// BG announce
|
||||||
LANG_BG_QUEUE_ANNOUNCE_SELF = 711,
|
LANG_BG_QUEUE_ANNOUNCE_SELF = 711,
|
||||||
LANG_BG_QUEUE_ANNOUNCE_WORLD = 712,
|
LANG_BG_QUEUE_ANNOUNCE_WORLD = 712,
|
||||||
// = 713, not used
|
|
||||||
|
// Arena announce
|
||||||
|
LANG_ARENA_QUEUE_ANNOUNCE_SELF = 713,
|
||||||
|
LANG_ARENA_QUEUE_ANNOUNCE_WORLD = 726,
|
||||||
|
|
||||||
// = 714, see LANG_PINFO_MAP_ONLINE
|
// = 714, see LANG_PINFO_MAP_ONLINE
|
||||||
LANG_YOUR_BG_LEVEL_REQ_ERROR = 715,
|
LANG_YOUR_BG_LEVEL_REQ_ERROR = 715,
|
||||||
// = 716, see LANG_PINFO_MAP_OFFLINE
|
// = 716, see LANG_PINFO_MAP_OFFLINE
|
||||||
@@ -716,7 +721,7 @@ enum AcoreStrings
|
|||||||
LANG_ARENA_NOT_ENOUGH_PLAYERS = 723, // "Your group does not have enough players to join this match."
|
LANG_ARENA_NOT_ENOUGH_PLAYERS = 723, // "Your group does not have enough players to join this match."
|
||||||
LANG_ARENA_GOLD_WINS = 724, // "The Gold Team wins!"
|
LANG_ARENA_GOLD_WINS = 724, // "The Gold Team wins!"
|
||||||
LANG_ARENA_GREEN_WINS = 725, // "The Green Team wins!"
|
LANG_ARENA_GREEN_WINS = 725, // "The Green Team wins!"
|
||||||
// = 726, not used
|
// = 726, see LANG_ARENA_QUEUE_ANNOUNCE_WORLD
|
||||||
LANG_BG_GROUP_OFFLINE_MEMBER = 727, // "Your group has an offline member. Please remove him before joining."
|
LANG_BG_GROUP_OFFLINE_MEMBER = 727, // "Your group has an offline member. Please remove him before joining."
|
||||||
LANG_BG_GROUP_MIXED_FACTION = 728, // "Your group has players from the opposing faction. You can't join the battleground as a group."
|
LANG_BG_GROUP_MIXED_FACTION = 728, // "Your group has players from the opposing faction. You can't join the battleground as a group."
|
||||||
LANG_BG_GROUP_MIXED_LEVELS = 729, // "Your group has players from different battleground brakets. You can't join as group."
|
LANG_BG_GROUP_MIXED_LEVELS = 729, // "Your group has players from different battleground brakets. You can't join as group."
|
||||||
|
|||||||
@@ -2841,12 +2841,23 @@ bool ScriptMgr::CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptMgr::CanSendMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo, bool IsJoin)
|
bool ScriptMgr::CanSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
||||||
if (!itr->second->CanSendMessageArenaQueue(queue, ginfo, IsJoin))
|
if (!itr->second->CanSendJoinMessageArenaQueue(queue, leader, ginfo, bracketEntry, isRated))
|
||||||
|
ret = false; // we change ret value only when scripts return false
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScriptMgr::CanExitJoinMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
||||||
|
if (!itr->second->CanExitJoinMessageArenaQueue(queue, ginfo))
|
||||||
ret = false; // we change ret value only when scripts return false
|
ret = false; // we change ret value only when scripts return false
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -1199,7 +1199,9 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] virtual bool CanSendMessageBGQueue(BattlegroundQueue* /*queue*/, Player* /*leader*/, Battleground* /*bg*/, PvPDifficultyEntry const* /*bracketEntry*/) { return true; }
|
[[nodiscard]] virtual bool CanSendMessageBGQueue(BattlegroundQueue* /*queue*/, Player* /*leader*/, Battleground* /*bg*/, PvPDifficultyEntry const* /*bracketEntry*/) { return true; }
|
||||||
|
|
||||||
[[nodiscard]] virtual bool CanSendMessageArenaQueue(BattlegroundQueue* /*queue*/, GroupQueueInfo* /*ginfo*/, bool /*IsJoin*/) { return true; }
|
[[nodiscard]] bool CanSendJoinMessageArenaQueue(BattlegroundQueue* /*queue*/, Player* /*leader*/, GroupQueueInfo* /*ginfo*/, PvPDifficultyEntry const* /*bracketEntry*/, bool /*isRated*/) { return true; }
|
||||||
|
|
||||||
|
[[nodiscard]] bool CanExitJoinMessageArenaQueue(BattlegroundQueue* /*queue*/, GroupQueueInfo* /*ginfo*/) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArenaTeamScript : public ScriptObject
|
class ArenaTeamScript : public ScriptObject
|
||||||
@@ -1791,7 +1793,8 @@ public: /* BGScript */
|
|||||||
BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId);
|
BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId);
|
||||||
void OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers);
|
void OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers);
|
||||||
bool CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
|
bool CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
|
||||||
bool CanSendMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo, bool IsJoin);
|
bool CanSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated);
|
||||||
|
bool CanExitJoinMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo);
|
||||||
|
|
||||||
public: /* Arena Team Script */
|
public: /* Arena Team Script */
|
||||||
void OnGetSlotByType(const uint32 type, uint8& slot);
|
void OnGetSlotByType(const uint32 type, uint8& slot);
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ enum WorldBoolConfigs
|
|||||||
CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS,
|
CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS,
|
||||||
CONFIG_ARENA_SEASON_IN_PROGRESS,
|
CONFIG_ARENA_SEASON_IN_PROGRESS,
|
||||||
CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE,
|
CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE,
|
||||||
|
CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY,
|
||||||
CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN,
|
CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN,
|
||||||
CONFIG_VMAP_INDOOR_CHECK,
|
CONFIG_VMAP_INDOOR_CHECK,
|
||||||
CONFIG_PET_LOS,
|
CONFIG_PET_LOS,
|
||||||
|
|||||||
@@ -1174,6 +1174,7 @@ void World::LoadConfigSettings(bool reload)
|
|||||||
m_float_configs[CONFIG_ARENA_LOSE_RATING_MODIFIER] = sConfigMgr->GetOption<float>("Arena.ArenaLoseRatingModifier", 24.0f);
|
m_float_configs[CONFIG_ARENA_LOSE_RATING_MODIFIER] = sConfigMgr->GetOption<float>("Arena.ArenaLoseRatingModifier", 24.0f);
|
||||||
m_float_configs[CONFIG_ARENA_MATCHMAKER_RATING_MODIFIER] = sConfigMgr->GetOption<float>("Arena.ArenaMatchmakerRatingModifier", 24.0f);
|
m_float_configs[CONFIG_ARENA_MATCHMAKER_RATING_MODIFIER] = sConfigMgr->GetOption<float>("Arena.ArenaMatchmakerRatingModifier", 24.0f);
|
||||||
m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetOption<bool> ("Arena.QueueAnnouncer.Enable", false);
|
m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetOption<bool> ("Arena.QueueAnnouncer.Enable", false);
|
||||||
|
m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY] = sConfigMgr->GetOption<bool> ("Arena.QueueAnnouncer.PlayerOnly", false);
|
||||||
|
|
||||||
m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfigMgr->GetOption<bool>("OffhandCheckAtSpellUnlearn", true);
|
m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = sConfigMgr->GetOption<bool>("OffhandCheckAtSpellUnlearn", true);
|
||||||
|
|
||||||
|
|||||||
@@ -2656,6 +2656,15 @@ Arena.GamesRequired = 10
|
|||||||
|
|
||||||
Arena.QueueAnnouncer.Enable = 0
|
Arena.QueueAnnouncer.Enable = 0
|
||||||
|
|
||||||
|
#
|
||||||
|
# Battleground.QueueAnnouncer.PlayerOnly
|
||||||
|
# Description: Battleground queue announcement type.
|
||||||
|
# Default: 0 - (System message, Anyone can see it)
|
||||||
|
# 1 - (Private, Only queued players can see it)
|
||||||
|
#
|
||||||
|
|
||||||
|
Arena.QueueAnnouncer.PlayerOnly = 0
|
||||||
|
|
||||||
#
|
#
|
||||||
# Arena.ArenaSeason.ID
|
# Arena.ArenaSeason.ID
|
||||||
# Description: Current arena season id shown in clients.
|
# Description: Current arena season id shown in clients.
|
||||||
|
|||||||
Reference in New Issue
Block a user