77 m_UpdateTimer(0), m_ArenaTesting(false), m_Testing(false)
106 BattlegroundContainer::iterator itrDelete =
bgs.begin();
107 for (BattlegroundContainer::iterator itr = itrDelete; itr !=
bgs.end();)
116 if (!clients.empty())
122 bgs.erase(itrDelete);
132 pair.second.UpdateEvents(diff);
137 std::vector<ScheduledQueueUpdate> scheduled;
140 for (
uint8 i = 0; i < scheduled.size(); i++)
142 uint32 arenaMMRating = scheduled[i].ArenaMatchmakerRating;
156 TC_LOG_TRACE(
"bg.arena",
"BattlegroundMgr: UPDATING ARENA QUEUES");
189 battlefieldStatus->
Ticket.
Id = ticketId;
198 battlefieldStatus->
Timeout = timeout;
199 battlefieldStatus->
Role = 0;
216 battlefieldStatus->
AsGroup = asGroup;
225 battlefieldStatus->
Ticket.
Id = ticketId;
229 battlefieldStatus->
Reason = result;
231 battlefieldStatus->
ClientID = *errorGuid;
239 BattlegroundDataContainer::const_iterator begin, end;
254 for (BattlegroundDataContainer::const_iterator it = begin; it != end; ++it)
257 BattlegroundContainer::const_iterator itr =
bgs.find(instanceId);
258 if (itr !=
bgs.end())
259 return itr->second.get();
279 for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end();)
281 if ((++lastId) != *itr)
286 clientIds.insert(++lastId);
300 TC_LOG_ERROR(
"bg.battleground",
"Battleground: CreateNewBattleground - bg template not found for {}", bgTypeId);
307 TC_LOG_ERROR(
"bg.battleground",
"Battleground: CreateNewBattleground: bg bracket entry not found for map {} bracket id {}", bg_template->
BattlemasterEntry->
MapID[0], bracketId);
381 QueryResult result =
WorldDatabase.Query(
"SELECT ID, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template");
384 TC_LOG_INFO(
"server.loading",
">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
392 Field* fields = result->Fetch();
403 TC_LOG_ERROR(
"bg.battleground",
"Battleground ID {} could not be found in BattlemasterList.dbc. The battleground was not created.", bgTypeId);
408 bgTemplate.
Id = bgTypeId;
421 TC_LOG_ERROR(
"sql.sql",
"Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `AllianceStartLoc`. Ignoring.", bgTemplate.
Id, startId);
424 TC_LOG_ERROR(
"sql.sql",
"Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `AllianceStartLoc`. BG not created.", bgTemplate.
Id, startId);
433 TC_LOG_ERROR(
"sql.sql",
"Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `HordeStartLoc`. Ignoring.", bgTemplate.
Id, startId);
436 TC_LOG_ERROR(
"sql.sql",
"Table `battleground_template` for id {} contains a non-existing WorldSafeLocs.dbc id {} in field `HordeStartLoc`. BG not created.", bgTemplate.
Id, startId);
447 while (result->NextRow());
472 uint32 mapid = bg->GetMapId();
476 TC_LOG_DEBUG(
"bg.battleground",
"BattlegroundMgr::SendToBattleground: Sending {} to map {}, {} (bgType {})", player->
GetName(), mapid, pos->
Loc.
ToString(), bgTypeId);
480 TC_LOG_ERROR(
"bg.battleground",
"BattlegroundMgr::SendToBattleground: Instance {} (bgType {}) not found while trying to teleport player {}", instanceId, bgTypeId, player->
GetName());
518 if (!battlemasterList)
532 if (!bgQueueTypeId.
Rated)
538 if (bgQueueTypeId.
Rated)
544 if (!bgQueueTypeId.
Rated)
594 TC_LOG_INFO(
"server.loading",
">> Loaded 0 battlemaster entries. DB table `battlemaster_entry` is empty!");
604 Field* fields = result->Fetch();
610 TC_LOG_ERROR(
"sql.sql",
"Creature (Entry: {}) listed in `battlemaster_entry` is not a battlemaster.", entry);
614 TC_LOG_ERROR(
"sql.sql",
"Creature (Entry: {}) listed in `battlemaster_entry` does not exist.", entry);
621 TC_LOG_ERROR(
"sql.sql",
"Table `battlemaster_entry` contains entry {} for a non-existing battleground type {}, ignored.", entry, bgTypeId);
627 while (result->NextRow());
637 for (
auto const& creatureTemplatePair : ctc)
641 TC_LOG_ERROR(
"sql.sql",
"Creature_Template Entry: {} has UNIT_NPC_FLAG_BATTLEMASTER, but no data in the `battlemaster_entry` table. Removing flag.", creatureTemplatePair.first);
688 std::vector<BattlegroundTypeId> ids;
690 std::vector<double> weights;
692 for (
int32 mapId : bgTemplate->BattlemasterEntry->MapID)
699 ids.push_back(bg->Id);
700 weights.push_back(bg->Weight);
723 for (BGFreeSlotQueueContainer::iterator itr = queues.begin(); itr != queues.end(); ++itr)
724 if ((*itr)->GetInstanceID() == instanceId)
@ BATTLEGROUND_OBJECTIVE_UPDATE_INTERVAL
std::set< uint32 > BattlegroundClientIdsContainer
std::map< uint32, Trinity::unique_trackable_ptr< Battleground > > BattlegroundContainer
std::list< Battleground * > BGFreeSlotQueueContainer
DB2Storage< BattlemasterListEntry > sBattlemasterListStore("BattlemasterList.db2", &BattlemasterListLoadInfo::Instance)
@ MAX_BATTLEGROUND_BRACKETS
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
@ DISABLE_TYPE_BATTLEGROUND
bool IsHolidayActive(HolidayIds id)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_TRACE(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
std::unordered_map< uint32, CreatureTemplate > CreatureTemplateContainer
GroupJoinBattlegroundResult
@ ERR_BATTLEGROUND_JOIN_TIMED_OUT
@ ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND
@ BATTLEGROUND_RANDOM_EPIC
@ HOLIDAY_CALL_TO_ARMS_AB
@ HOLIDAY_CALL_TO_ARMS_ES
@ HOLIDAY_CALL_TO_ARMS_SA
@ HOLIDAY_CALL_TO_ARMS_IC
@ HOLIDAY_CALL_TO_ARMS_BG
@ HOLIDAY_CALL_TO_ARMS_AV
@ HOLIDAY_CALL_TO_ARMS_WG
@ HOLIDAY_CALL_TO_ARMS_TP
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ UNIT_NPC_FLAG_BATTLEMASTER
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
BattlegroundMapTemplateContainer _battlegroundMapTemplates
void BuildBattlegroundStatusNone(WorldPackets::Battleground::BattlefieldStatusNone *battlefieldStatus, Player *player, uint32 ticketId, uint32 joinTime)
void LoadBattleMastersEntry()
std::map< BattlegroundQueueTypeId, BattlegroundQueue > m_BattlegroundQueues
BattlegroundTemplate const * GetBattlegroundTemplateByMapId(uint32 mapId)
void BuildBattlegroundStatusActive(WorldPackets::Battleground::BattlefieldStatusActive *battlefieldStatus, Battleground *bg, Player *player, uint32 ticketId, uint32 joinTime, BattlegroundQueueTypeId queueId)
std::vector< ScheduledQueueUpdate > m_QueueUpdateScheduler
void DeleteAllBattlegrounds()
Battleground * GetBattleground(uint32 InstanceID, BattlegroundTypeId bgTypeId)
BattlegroundTemplateMap _battlegroundTemplates
static BattlegroundQueueTypeId BGQueueTypeId(uint16 battlemasterListId, BattlegroundQueueIdType type, bool rated, uint8 teamSize)
uint32 GetMaxRatingDifference() const
static BattlegroundMgr * instance()
BGFreeSlotQueueContainer & GetBGFreeSlotQueueStore(uint32 mapId)
static bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id)
static bool IsArenaType(BattlegroundTypeId bgTypeId)
BattlegroundQueue & GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId)
void AddBattleground(Battleground *bg)
void AddToBGFreeSlotQueue(Battleground *bg)
void ToggleArenaTesting()
BattleMastersMap mBattleMastersMap
std::map< uint32, BGFreeSlotQueueContainer > m_BGFreeSlotQueue
static bool IsRandomBattleground(uint32 battlemasterListId)
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id)
void SendBattlegroundList(Player *player, ObjectGuid const &guid, BattlegroundTypeId bgTypeId)
BattlegroundTemplate const * GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
Battleground * CreateNewBattleground(BattlegroundQueueTypeId queueId, BattlegroundBracketId bracketId)
void SendToBattleground(Player *player, uint32 InstanceID, BattlegroundTypeId bgTypeId)
void BuildBattlegroundStatusHeader(WorldPackets::Battleground::BattlefieldStatusHeader *battlefieldStatus, Player *player, uint32 ticketId, uint32 joinTime, BattlegroundQueueTypeId queueId)
void RemoveFromBGFreeSlotQueue(uint32 mapId, uint32 instanceId)
uint32 GetRatingDiscardTimer() const
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
void BuildBattlegroundStatusNeedConfirmation(WorldPackets::Battleground::BattlefieldStatusNeedConfirmation *battlefieldStatus, Battleground *bg, Player *player, uint32 ticketId, uint32 joinTime, uint32 timeout, BattlegroundQueueTypeId queueId)
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
uint32 GetPrematureFinishTime() const
uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
uint32 m_NextRatedArenaUpdate
void BuildBattlegroundStatusFailed(WorldPackets::Battleground::BattlefieldStatusFailed *battlefieldStatus, BattlegroundQueueTypeId queueId, Player *pPlayer, uint32 ticketId, GroupJoinBattlegroundResult result, ObjectGuid const *errorGuid=nullptr)
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
void BuildBattlegroundStatusQueued(WorldPackets::Battleground::BattlefieldStatusQueued *battlefieldStatus, Player *player, uint32 ticketId, uint32 joinTime, BattlegroundQueueTypeId queueId, uint32 avgWaitTime, bool asGroup)
BattlegroundDataContainer bgDataStore
void CheckBattleMasters()
void LoadBattlegroundTemplates()
void BattlegroundQueueUpdate(uint32 diff, BattlegroundBracketId bracket_id, uint32 minRating=0)
Class for manage Strand of Ancient battleground.
void SetInstanceID(uint32 InstanceID)
void SetRated(bool state)
uint32 GetRemainingTime() const
BattlegroundTypeId GetTypeID() const
uint32 GetInstanceID() const
uint32 GetClientInstanceID() const
void SetClientInstanceID(uint32 InstanceID)
static TeamId GetTeamIndexByTeamId(Team team)
void SetStatus(BattlegroundStatus Status)
void SetArenaType(uint8 type)
BattlegroundBracketId GetBracketId() const
uint32 GetElapsedTime() const
void SetBracket(PVPDifficultyEntry const *bracketEntry)
void SetWeakPtr(Trinity::unique_weak_ptr< Battleground > weakRef)
static PVPDifficultyEntry const * GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id)
Class used to access individual fields of database query result.
static ObjectGuid GetGUID(Object const *o)
void SendDirectMessage(WorldPacket const *data) const
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={})
uint32 GetBattlegroundQueueJoinTime(BattlegroundQueueTypeId bgQueueTypeId) const
bool GetRandomWinner() const
std::string const & GetName() const
WorldPacket const * Write() override
ObjectGuid BattlemasterGuid
BattlefieldStatusHeader Hdr
WorldPackets::LFG::RideTicket Ticket
BattlefieldStatusHeader Hdr
WorldPackets::LFG::RideTicket Ticket
bool EligibleForMatchmaking
BattlefieldStatusHeader Hdr
@ CONFIG_ARENA_MAX_RATING_DIFFERENCE
@ CONFIG_ARENA_RATED_UPDATE_TIMER
@ CONFIG_ARENA_RATING_DISCARD_TIMER
@ CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
auto SelectRandomWeightedContainerElement(C const &container, std::span< double > const &weights) -> decltype(std::begin(container))
constexpr uint64 GetPacked() const
uint16 BattlemasterListId
uint8 GetMinLevel() const
BattlemasterListEntry const * BattlemasterEntry
uint16 GetMaxPlayersPerTeam() const
WorldSafeLocsEntry const * StartLocation[PVP_TEAMS_COUNT]
uint16 GetMinPlayersPerTeam() const
uint8 GetMaxLevel() const
std::array< int16, 16 > MapID
BattlegroundBracketId GetBracketId() const
std::string ToString() const