mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Reduce code differences between branches
This commit is contained in:
@@ -126,13 +126,8 @@ void BattlegroundMgr::Update(uint32 diff)
|
||||
std::vector<ScheduledQueueUpdate> scheduled;
|
||||
std::swap(scheduled, m_QueueUpdateScheduler);
|
||||
|
||||
for (uint8 i = 0; i < scheduled.size(); i++)
|
||||
{
|
||||
uint32 arenaMMRating = scheduled[i].ArenaMatchmakerRating;
|
||||
BattlegroundQueueTypeId bgQueueTypeId = scheduled[i].QueueId;
|
||||
BattlegroundBracketId bracket_id = scheduled[i].BracketId;
|
||||
for (auto& [arenaMMRating, bgQueueTypeId, bracket_id] : scheduled)
|
||||
GetBattlegroundQueue(bgQueueTypeId).BattlegroundQueueUpdate(diff, bracket_id, arenaMMRating);
|
||||
}
|
||||
}
|
||||
|
||||
// if rating difference counts, maybe force-update queues
|
||||
@@ -499,7 +494,7 @@ bool BattlegroundMgr::IsRandomBattleground(uint32 battlemasterListId)
|
||||
|
||||
BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId(uint16 battlemasterListId, BattlegroundQueueIdType type, bool rated, uint8 teamSize)
|
||||
{
|
||||
return { battlemasterListId, AsUnderlyingType(type), rated, teamSize };
|
||||
return { .BattlemasterListId = battlemasterListId, .Type = AsUnderlyingType(type), .Rated = rated, .TeamSize = teamSize };
|
||||
}
|
||||
|
||||
void BattlegroundMgr::ToggleTesting()
|
||||
@@ -687,23 +682,14 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
|
||||
{
|
||||
std::vector<BattlegroundTypeId> ids;
|
||||
std::vector<BattlegroundTemplate const*> ids;
|
||||
ids.reserve(bgTemplate->MapIDs.size());
|
||||
std::vector<double> weights;
|
||||
weights.reserve(bgTemplate->MapIDs.size());
|
||||
double totalWeight = 0.0;
|
||||
for (int32 mapId : bgTemplate->MapIDs)
|
||||
{
|
||||
if (BattlegroundTemplate const* bg = GetBattlegroundTemplateByMapId(mapId))
|
||||
{
|
||||
ids.push_back(bg->Id);
|
||||
weights.push_back(bg->Weight);
|
||||
totalWeight += bg->Weight;
|
||||
}
|
||||
}
|
||||
ids.push_back(bg);
|
||||
|
||||
if (totalWeight > 0.0)
|
||||
return *Trinity::Containers::SelectRandomWeightedContainerElement(ids, std::span(weights));
|
||||
if (!ids.empty())
|
||||
return (*Trinity::Containers::SelectRandomWeightedContainerElement(ids, [](BattlegroundTemplate const* bg) { return bg->Weight; }))->Id;
|
||||
}
|
||||
|
||||
return BATTLEGROUND_TYPE_NONE;
|
||||
|
||||
@@ -122,7 +122,7 @@ class TC_GAME_API BattlegroundQueue
|
||||
SelectionPool m_SelectionPools[PVP_TEAMS_COUNT];
|
||||
uint32 GetPlayersInQueue(TeamId id);
|
||||
|
||||
BattlegroundQueueTypeId const GetQueueId() const { return m_queueId; }
|
||||
BattlegroundQueueTypeId GetQueueId() const { return m_queueId; }
|
||||
private:
|
||||
|
||||
BattlegroundQueueTypeId m_queueId;
|
||||
|
||||
@@ -1194,6 +1194,8 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed)
|
||||
|
||||
GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(BattlegroundTemplate const* bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 /*MaxPlayerCount*/, bool isRated, uint32 arenaSlot, ObjectGuid& errorGuid) const
|
||||
{
|
||||
errorGuid = ObjectGuid::Empty;
|
||||
|
||||
// check if this group is LFG group
|
||||
if (isLFGGroup())
|
||||
return ERR_LFG_CANT_USE_BATTLEGROUND;
|
||||
@@ -1230,15 +1232,13 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(BattlegroundTemplate
|
||||
// offline member? don't let join
|
||||
if (!member)
|
||||
return ERR_BATTLEGROUND_JOIN_FAILED;
|
||||
errorGuid = member->GetGUID();
|
||||
// rbac permissions
|
||||
if (!member->CanJoinToBattleground(bgOrTemplate))
|
||||
return ERR_BATTLEGROUND_JOIN_TIMED_OUT;
|
||||
// don't allow cross-faction join as group
|
||||
if (member->GetTeam() != team)
|
||||
{
|
||||
errorGuid = member->GetGUID();
|
||||
return ERR_BATTLEGROUND_JOIN_TIMED_OUT;
|
||||
}
|
||||
// not in the same battleground level braket, don't let join
|
||||
PVPDifficultyEntry const* memberBracketEntry = DB2Manager::GetBattlegroundBracketByLevel(bracketEntry->MapID, member->GetLevel());
|
||||
if (memberBracketEntry != bracketEntry)
|
||||
@@ -1273,6 +1273,8 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(BattlegroundTemplate
|
||||
return ERR_BATTLEGROUND_JOIN_MERCENARY;
|
||||
}
|
||||
|
||||
errorGuid = ObjectGuid::Empty;
|
||||
|
||||
// only check for MinPlayerCount since MinPlayerCount == MaxPlayerCount for arenas...
|
||||
if (bgOrTemplate->IsArena() && memberscount != MinPlayerCount)
|
||||
return ERR_ARENA_TEAM_PARTY_SIZE;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "Creature.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "GameTime.h"
|
||||
#include "Group.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
@@ -491,7 +492,7 @@ void WorldSession::HandleRequestBattlefieldStatusOpcode(WorldPackets::Battlegrou
|
||||
continue;
|
||||
|
||||
WorldPackets::Battleground::BattlefieldStatusNeedConfirmation battlefieldStatus;
|
||||
BattlegroundMgr::BuildBattlegroundStatusNeedConfirmation(&battlefieldStatus, bg, _player, i, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), getMSTimeDiff(getMSTime(), ginfo.RemoveInviteTime), bgQueueTypeId);
|
||||
BattlegroundMgr::BuildBattlegroundStatusNeedConfirmation(&battlefieldStatus, bg, _player, i, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), getMSTimeDiff(GameTime::GetGameTimeMS(), ginfo.RemoveInviteTime), bgQueueTypeId);
|
||||
SendPacket(battlefieldStatus.Write());
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user