mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Battlegrounds): make it compatible with custom arena type (#18679)
* feat(Battlegrounds): make it compatible with custom arena type * fix(BattlegroundQueue.cpp): ignore bg for arena condition * feat(Scripting): add OnQueueUpdateValidity hook * fix: codestyle
This commit is contained in:
@@ -1034,7 +1034,10 @@ void ArenaTeam::CreateTempArenaTeam(std::vector<Player*> playerList, uint8 type,
|
||||
{
|
||||
auto playerCountInTeam = static_cast<uint32>(playerList.size());
|
||||
|
||||
ASSERT(playerCountInTeam == GetReqPlayersForType(type));
|
||||
const auto standardArenaType = { ARENA_TYPE_2v2, ARENA_TYPE_3v3, ARENA_TYPE_5v5 };
|
||||
bool isStandardArenaType = std::find(std::begin(standardArenaType), std::end(standardArenaType), type) != std::end(standardArenaType);
|
||||
if (isStandardArenaType)
|
||||
ASSERT(playerCountInTeam == GetReqPlayersForType(type));
|
||||
|
||||
// Generate new arena team id
|
||||
TeamId = sArenaTeamMgr->GenerateTempArenaTeamId();
|
||||
|
||||
@@ -773,6 +773,10 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
|
||||
|
||||
sScriptMgr->OnQueueUpdate(this, diff, bgTypeId, bracket_id, arenaType, isRated, arenaRating);
|
||||
|
||||
if (!sScriptMgr->OnQueueUpdateValidity(this, diff, bgTypeId, bracket_id, arenaType, isRated, arenaRating)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_SelectionPools[TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[TEAM_HORDE].Init();
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ void ScriptMgr::OnQueueUpdate(BattlegroundQueue* queue, uint32 diff, Battlegroun
|
||||
CALL_ENABLED_HOOKS(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_ON_QUEUE_UPDATE, script->OnQueueUpdate(queue, diff, bgTypeId, bracket_id, arenaType, isRated, arenaRating));
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnQueueUpdateValidity(BattlegroundQueue* queue, uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_ON_QUEUE_UPDATE_VALIDITY, !script->OnQueueUpdateValidity(queue, diff, bgTypeId, bracket_id, arenaType, isRated, arenaRating));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAddGroup(BattlegroundQueue* queue, GroupQueueInfo* ginfo, uint32& index, Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 matchmakerRating, uint32 arenaTeamId, uint32 opponentsArenaTeamId)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(AllBattlegroundScript, ALLBATTLEGROUNDHOOK_ON_ADD_GROUP, script->OnAddGroup(queue, ginfo, index, leader, group, bgTypeId, bracketEntry, arenaType, isRated, isPremade, arenaRating, matchmakerRating, arenaTeamId, opponentsArenaTeamId));
|
||||
|
||||
@@ -30,6 +30,7 @@ enum AllBattlegroundHook
|
||||
ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_BEFORE_ADD_PLAYER,
|
||||
ALLBATTLEGROUNDHOOK_ON_BATTLEGROUND_REMOVE_PLAYER_AT_LEAVE,
|
||||
ALLBATTLEGROUNDHOOK_ON_QUEUE_UPDATE,
|
||||
ALLBATTLEGROUNDHOOK_ON_QUEUE_UPDATE_VALIDITY,
|
||||
ALLBATTLEGROUNDHOOK_ON_ADD_GROUP,
|
||||
ALLBATTLEGROUNDHOOK_CAN_FILL_PLAYERS_TO_BG,
|
||||
ALLBATTLEGROUNDHOOK_IS_CHECK_NORMAL_MATCH,
|
||||
@@ -78,6 +79,8 @@ public:
|
||||
|
||||
virtual void OnQueueUpdate(BattlegroundQueue* /*queue*/, uint32 /* diff */, BattlegroundTypeId /* bgTypeId */, BattlegroundBracketId /* bracket_id */, uint8 /* arenaType */, bool /* isRated */, uint32 /* arenaRating */) { }
|
||||
|
||||
[[nodiscard]] virtual bool OnQueueUpdateValidity(BattlegroundQueue* /*queue*/, uint32 /* diff */, BattlegroundTypeId /* bgTypeId */, BattlegroundBracketId /* bracket_id */, uint8 /* arenaType */, bool /* isRated */, uint32 /* arenaRating */) { return true; }
|
||||
|
||||
virtual void OnAddGroup(BattlegroundQueue* /*queue*/, GroupQueueInfo* /*ginfo*/, uint32& /*index*/, Player* /*leader*/, Group* /*group*/, BattlegroundTypeId /* bgTypeId */, PvPDifficultyEntry const* /* bracketEntry */,
|
||||
uint8 /* arenaType */, bool /* isRated */, bool /* isPremade */, uint32 /* arenaRating */, uint32 /* matchmakerRating */, uint32 /* arenaTeamId */, uint32 /* opponentsArenaTeamId */) { }
|
||||
|
||||
|
||||
@@ -584,6 +584,7 @@ public: /* BGScript */
|
||||
void OnBattlegroundBeforeAddPlayer(Battleground* bg, Player* player);
|
||||
void OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player);
|
||||
void OnQueueUpdate(BattlegroundQueue* queue, uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating);
|
||||
bool OnQueueUpdateValidity(BattlegroundQueue* queue, uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating);
|
||||
void OnAddGroup(BattlegroundQueue* queue, GroupQueueInfo* ginfo, uint32& index, Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry,
|
||||
uint8 arenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 matchmakerRating, uint32 arenaTeamId, uint32 opponentsArenaTeamId);
|
||||
bool CanFillPlayersToBG(BattlegroundQueue* queue, Battleground* bg, BattlegroundBracketId bracket_id);
|
||||
|
||||
Reference in New Issue
Block a user