mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-02 10:33:46 +00:00
Merge branch 'master' into Playerbot
# Conflicts: # apps/ci/ci-install-modules.sh # src/common/Collision/Management/MMapMgr.cpp # src/common/Debugging/Errors.h # src/server/game/AI/SmartScripts/SmartScript.cpp # src/server/game/Battlegrounds/Arena.cpp # src/server/game/Battlegrounds/ArenaScore.h # src/server/game/Battlegrounds/Battleground.cpp # src/server/game/Battlegrounds/BattlegroundMgr.cpp # src/server/game/Battlegrounds/BattlegroundMgr.h # src/server/game/Battlegrounds/BattlegroundQueue.cpp # src/server/game/Battlegrounds/BattlegroundQueue.h # src/server/game/Battlegrounds/Zones/BattlegroundAB.h # src/server/game/Battlegrounds/Zones/BattlegroundEY.h # src/server/game/Battlegrounds/Zones/BattlegroundIC.h # src/server/game/Conditions/ConditionMgr.cpp # src/server/game/DataStores/M2Stores.cpp # src/server/game/DungeonFinding/LFGMgr.cpp # src/server/game/Entities/Creature/Creature.cpp # src/server/game/Entities/Creature/CreatureData.h # src/server/game/Entities/GameObject/GameObject.cpp # src/server/game/Entities/GameObject/GameObject.h # src/server/game/Entities/Player/Player.cpp # src/server/game/Entities/Player/Player.h # src/server/game/Entities/Player/PlayerStorage.cpp # src/server/game/Entities/Unit/Unit.cpp # src/server/game/Entities/Unit/Unit.h # src/server/game/Globals/ObjectMgr.cpp # src/server/game/Groups/Group.cpp # src/server/game/Groups/Group.h # src/server/game/Guilds/Guild.cpp # src/server/game/Guilds/Guild.h # src/server/game/Handlers/BattleGroundHandler.cpp # src/server/game/Handlers/CharacterHandler.cpp # src/server/game/Scripting/ScriptDefines/BGScript.cpp # src/server/game/Scripting/ScriptDefines/DatabaseScript.cpp # src/server/game/Scripting/ScriptDefines/PlayerScript.cpp # src/server/game/Scripting/ScriptDefines/ServerScript.cpp # src/server/game/Scripting/ScriptMgr.cpp # src/server/game/Scripting/ScriptMgrMacros.h # src/server/game/Server/Packets/MiscPackets.cpp # src/server/game/Server/Packets/MiscPackets.h # src/server/game/Server/WorldSession.cpp # src/server/game/Spells/SpellEffects.cpp # src/server/game/World/IWorld.h # src/server/game/World/World.cpp # src/server/game/World/World.h # src/server/scripts/Commands/cs_npc.cpp # src/server/scripts/Commands/cs_server.cpp # src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp # src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/instance_blackwing_lair.cpp # src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp # src/server/scripts/EasternKingdoms/ShadowfangKeep/boss_apothecary_hummel.cpp # src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp # src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h # src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
This commit is contained in:
@@ -312,6 +312,10 @@ void Arena::EndBattleground(TeamId winnerTeamId)
|
||||
}
|
||||
}
|
||||
|
||||
// update previous opponents for arena queue
|
||||
winnerArenaTeam->SetPreviousOpponents(loserArenaTeam->GetId());
|
||||
loserArenaTeam->SetPreviousOpponents(winnerArenaTeam->GetId());
|
||||
|
||||
// save the stat changes
|
||||
if (bValidArena)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
{
|
||||
RatingChange = ratingChange;
|
||||
MatchmakerRating = matchMakerRating;
|
||||
TeamName = teamName;
|
||||
TeamName = std::string(teamName);
|
||||
}
|
||||
|
||||
void BuildRatingInfoBlock(WorldPacket& data);
|
||||
|
||||
@@ -345,7 +345,7 @@ void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb)
|
||||
WorldPacket data;
|
||||
playerMember->RemoveBattlegroundQueueId(bgQueue);
|
||||
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, nullptr, playerMember->GetBattlegroundQueueIndex(bgQueue), STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL);
|
||||
queue.RemovePlayer(playerMember->GetGUID(), true, 0);
|
||||
queue.RemovePlayer(playerMember->GetGUID(), true);
|
||||
playerMember->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +209,9 @@ public:
|
||||
void FinishWeek();
|
||||
void FinishGame(int32 mod, const Map* bgMap);
|
||||
|
||||
void SetPreviousOpponents(uint32 arenaTeamId) { PreviousOpponents = arenaTeamId; }
|
||||
uint32 GetPreviousOpponents() { return PreviousOpponents; }
|
||||
|
||||
void CreateTempArenaTeam(std::vector<Player*> playerList, uint8 type, std::string const& teamName);
|
||||
|
||||
// Containers
|
||||
@@ -233,5 +236,7 @@ protected:
|
||||
|
||||
MemberList Members;
|
||||
ArenaTeamStats Stats;
|
||||
|
||||
uint32 PreviousOpponents = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -157,7 +157,7 @@ void ArenaTeamMgr::LoadArenaTeams()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_INFO("server.loading", ">> Loaded 0 arena teams. DB table `arena_team` is empty!");
|
||||
LOG_WARN("server.loading", ">> Loaded 0 arena teams. DB table `arena_team` is empty!");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -232,6 +232,9 @@ Battleground::~Battleground()
|
||||
m_Map = nullptr;
|
||||
}
|
||||
|
||||
// remove from bg free slot queue
|
||||
RemoveFromBGFreeSlotQueue();
|
||||
|
||||
for (auto const& itr : PlayerScores)
|
||||
delete itr.second;
|
||||
}
|
||||
@@ -251,8 +254,21 @@ void Battleground::Update(uint32 diff)
|
||||
|
||||
if (!GetPlayersSize())
|
||||
{
|
||||
//BG is empty
|
||||
// if there are no players invited, delete BG
|
||||
// this will delete arena or bg object, where any player entered
|
||||
// [[ but if you use battleground object again (more battles possible to be played on 1 instance)
|
||||
// then this condition should be removed and code:
|
||||
// if (!GetInvitedCount(TEAM_HORDE) && !GetInvitedCount(TEAM_ALLIANCE))
|
||||
// AddToFreeBGObjectsQueue(); // not yet implemented
|
||||
// should be used instead of current
|
||||
// ]]
|
||||
// Battleground Template instance cannot be updated, because it would be deleted
|
||||
if (!GetInvitedCount(TEAM_HORDE) && !GetInvitedCount(TEAM_ALLIANCE))
|
||||
{
|
||||
m_SetDeleteThis = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -768,6 +784,7 @@ void Battleground::EndBattleground(PvPTeamId winnerTeamId)
|
||||
if (GetStatus() == STATUS_WAIT_LEAVE)
|
||||
return;
|
||||
|
||||
RemoveFromBGFreeSlotQueue();
|
||||
SetStatus(STATUS_WAIT_LEAVE);
|
||||
SetWinner(winnerTeamId);
|
||||
|
||||
@@ -956,13 +973,17 @@ void Battleground::RemovePlayerAtLeave(Player* player)
|
||||
// if the player was a match participant
|
||||
if (participant)
|
||||
{
|
||||
WorldPacket data;
|
||||
|
||||
player->ClearAfkReports();
|
||||
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetCurrentBattlegroundQueueSlot(), STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetBgTypeID(), GetArenaType());
|
||||
|
||||
// this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
|
||||
player->RemoveBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
// remove from raid group if player is member
|
||||
if (Group* group = GetBgRaid(teamId))
|
||||
if (group->IsMember(player->GetGUID()))
|
||||
@@ -977,6 +998,19 @@ void Battleground::RemovePlayerAtLeave(Player* player)
|
||||
if (isBattleground() && !player->IsGameMaster() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_CAST_DESERTER))
|
||||
if (status == STATUS_IN_PROGRESS || status == STATUS_WAIT_JOIN)
|
||||
player->ScheduleDelayedOperation(DELAYED_SPELL_CAST_DESERTER);
|
||||
|
||||
DecreaseInvitedCount(teamId);
|
||||
|
||||
//we should update battleground queue, but only if bg isn't ending
|
||||
if (isBattleground() && GetStatus() < STATUS_WAIT_LEAVE)
|
||||
{
|
||||
BattlegroundTypeId bgTypeId = GetBgTypeID();
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetBgTypeID(), GetArenaType());
|
||||
|
||||
// a player has left the battleground, so there are free slots -> add to queue
|
||||
AddToBGFreeSlotQueue();
|
||||
sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, GetBracketId());
|
||||
}
|
||||
}
|
||||
|
||||
// Remove shapeshift auras
|
||||
@@ -1009,6 +1043,7 @@ void Battleground::Init()
|
||||
|
||||
m_BgInvitedPlayers[TEAM_ALLIANCE] = 0;
|
||||
m_BgInvitedPlayers[TEAM_HORDE] = 0;
|
||||
_InBGFreeSlotQueue = false;
|
||||
|
||||
m_Players.clear();
|
||||
|
||||
@@ -1028,9 +1063,15 @@ void Battleground::StartBattleground()
|
||||
SetStartTime(0);
|
||||
SetLastResurrectTime(0);
|
||||
|
||||
// add BG to free slot queue
|
||||
AddToBGFreeSlotQueue();
|
||||
|
||||
// add bg to update list
|
||||
// this must be done here, because we need to have already invited some players when first Battleground::Update() method is executed
|
||||
sBattlegroundMgr->AddBattleground(this);
|
||||
|
||||
if (m_IsRated)
|
||||
LOG_DEBUG("bg.arena", "Arena match type: {} for Team1Id: {} - Team2Id: {} started.", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE]);
|
||||
}
|
||||
|
||||
void Battleground::AddPlayer(Player* player)
|
||||
@@ -1129,6 +1170,26 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, TeamId teamId)
|
||||
}
|
||||
}
|
||||
|
||||
// This method should be called only once ... it adds pointer to queue
|
||||
void Battleground::AddToBGFreeSlotQueue()
|
||||
{
|
||||
if (!_InBGFreeSlotQueue && isBattleground())
|
||||
{
|
||||
sBattlegroundMgr->AddToBGFreeSlotQueue(m_RealTypeID, this);
|
||||
_InBGFreeSlotQueue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// This method removes this battleground from free queue - it must be called when deleting battleground
|
||||
void Battleground::RemoveFromBGFreeSlotQueue()
|
||||
{
|
||||
if (_InBGFreeSlotQueue)
|
||||
{
|
||||
sBattlegroundMgr->RemoveFromBGFreeSlotQueue(m_RealTypeID, m_InstanceID);
|
||||
_InBGFreeSlotQueue = false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Battleground::GetFreeSlotsForTeam(TeamId teamId) const
|
||||
{
|
||||
if (!(GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN))
|
||||
@@ -1332,7 +1393,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float
|
||||
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
|
||||
// iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
|
||||
GameObjectData& data = sObjectMgr->NewGOData(spawnId);
|
||||
data.spawnId = spawnId;
|
||||
|
||||
data.id = entry;
|
||||
data.mapid = GetMapId();
|
||||
data.posX = x;
|
||||
@@ -1611,6 +1672,7 @@ void Battleground::SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* s
|
||||
|
||||
void Battleground::EndNow()
|
||||
{
|
||||
RemoveFromBGFreeSlotQueue();
|
||||
SetStatus(STATUS_WAIT_LEAVE);
|
||||
SetEndTime(0);
|
||||
}
|
||||
@@ -1777,6 +1839,12 @@ GraveyardStruct const* Battleground::GetClosestGraveyard(Player* player)
|
||||
return sGraveyard->GetClosestGraveyard(player, player->GetBgTeamId());
|
||||
}
|
||||
|
||||
void Battleground::SetBracket(PvPDifficultyEntry const* bracketEntry)
|
||||
{
|
||||
m_BracketId = bracketEntry->GetBracketId();
|
||||
SetLevelRange(bracketEntry->minLevel, bracketEntry->maxLevel);
|
||||
}
|
||||
|
||||
void Battleground::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
||||
{
|
||||
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
|
||||
|
||||
@@ -317,6 +317,7 @@ public:
|
||||
// Get methods:
|
||||
[[nodiscard]] std::string GetName() const { return m_Name; }
|
||||
[[nodiscard]] BattlegroundTypeId GetBgTypeID(bool GetRandom = false) const { return GetRandom ? m_RandomTypeID : m_RealTypeID; }
|
||||
[[nodiscard]] BattlegroundBracketId GetBracketId() const { return m_BracketId; }
|
||||
[[nodiscard]] uint32 GetInstanceID() const { return m_InstanceID; }
|
||||
[[nodiscard]] BattlegroundStatus GetStatus() const { return m_Status; }
|
||||
[[nodiscard]] uint32 GetClientInstanceID() const { return m_ClientInstanceID; }
|
||||
@@ -342,6 +343,7 @@ public:
|
||||
void SetName(std::string_view name) { m_Name = std::string(name); }
|
||||
void SetBgTypeID(BattlegroundTypeId TypeID) { m_RealTypeID = TypeID; }
|
||||
void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; }
|
||||
void SetBracket(PvPDifficultyEntry const* bracketEntry);
|
||||
void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
|
||||
void SetStatus(BattlegroundStatus Status) { m_Status = Status; }
|
||||
void SetClientInstanceID(uint32 InstanceID) { m_ClientInstanceID = InstanceID; }
|
||||
@@ -362,6 +364,9 @@ public:
|
||||
void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; }
|
||||
void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; }
|
||||
|
||||
void AddToBGFreeSlotQueue(); // this queue will be useful when more battlegrounds instances will be available
|
||||
void RemoveFromBGFreeSlotQueue(); // this method could delete whole BG instance, if another free is available
|
||||
|
||||
void DecreaseInvitedCount(TeamId teamId) { if (m_BgInvitedPlayers[teamId]) --m_BgInvitedPlayers[teamId]; }
|
||||
void IncreaseInvitedCount(TeamId teamId) { ++m_BgInvitedPlayers[teamId]; }
|
||||
[[nodiscard]] uint32 GetInvitedCount(TeamId teamId) const { return m_BgInvitedPlayers[teamId]; }
|
||||
@@ -643,7 +648,9 @@ private:
|
||||
uint32 m_ValidStartPositionTimer;
|
||||
int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself
|
||||
uint32 m_LastResurrectTime;
|
||||
BattlegroundBracketId m_BracketId{ BG_BRACKET_ID_FIRST };
|
||||
uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5
|
||||
bool _InBGFreeSlotQueue{ false }; // used to make sure that BG is only once inserted into the BattlegroundMgr.BGFreeSlotQueue[bgTypeId] deque
|
||||
bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave
|
||||
bool m_IsArena;
|
||||
PvPTeamId m_WinnerId;
|
||||
|
||||
@@ -48,15 +48,22 @@
|
||||
#include "WorldPacket.h"
|
||||
#include <unordered_map>
|
||||
|
||||
bool BattlegroundTemplate::IsArena() const
|
||||
{
|
||||
return BattlemasterEntry->type == MAP_ARENA;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/*** BATTLEGROUND MANAGER ***/
|
||||
/*********************************************************/
|
||||
|
||||
BattlegroundMgr::BattlegroundMgr() : m_ArenaTesting(false), m_Testing(false),
|
||||
m_lastClientVisibleInstanceId(0), m_NextAutoDistributionTime(0), m_AutoDistributionTimeChecker(0), m_NextPeriodicQueueUpdateTime(5 * IN_MILLISECONDS)
|
||||
BattlegroundMgr::BattlegroundMgr() :
|
||||
m_ArenaTesting(false),
|
||||
m_Testing(false),
|
||||
m_NextAutoDistributionTime(0),
|
||||
m_AutoDistributionTimeChecker(0),
|
||||
m_NextPeriodicQueueUpdateTime(5 * IN_MILLISECONDS)
|
||||
{
|
||||
for (uint32 qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
|
||||
m_BattlegroundQueues[qtype].SetBgTypeIdAndArenaType(BGTemplateId(BattlegroundQueueTypeId(qtype)), BGArenaType(BattlegroundQueueTypeId(qtype)));
|
||||
}
|
||||
|
||||
BattlegroundMgr::~BattlegroundMgr()
|
||||
@@ -72,47 +79,68 @@ BattlegroundMgr* BattlegroundMgr::instance()
|
||||
|
||||
void BattlegroundMgr::DeleteAllBattlegrounds()
|
||||
{
|
||||
while (!m_Battlegrounds.empty())
|
||||
delete m_Battlegrounds.begin()->second;
|
||||
m_Battlegrounds.clear();
|
||||
for (auto& [_, data] : bgDataStore)
|
||||
{
|
||||
while (!data._Battlegrounds.empty())
|
||||
delete data._Battlegrounds.begin()->second;
|
||||
|
||||
while (!m_BattlegroundTemplates.empty())
|
||||
delete m_BattlegroundTemplates.begin()->second;
|
||||
m_BattlegroundTemplates.clear();
|
||||
data._Battlegrounds.clear();
|
||||
|
||||
while (!data.BGFreeSlotQueue.empty())
|
||||
delete data.BGFreeSlotQueue.front();
|
||||
}
|
||||
|
||||
bgDataStore.clear();
|
||||
}
|
||||
|
||||
// used to update running battlegrounds, and delete finished ones
|
||||
void BattlegroundMgr::Update(uint32 diff)
|
||||
{
|
||||
// update all battlegrounds and delete if needed
|
||||
for (BattlegroundContainer::iterator itr = m_Battlegrounds.begin(), itrDelete; itr != m_Battlegrounds.end(); )
|
||||
for (auto& [_, bgData] : bgDataStore)
|
||||
{
|
||||
itrDelete = itr++;
|
||||
Battleground* bg = itrDelete->second;
|
||||
bg->Update(diff);
|
||||
if (bg->ToBeDeleted())
|
||||
auto& bgList = bgData._Battlegrounds;
|
||||
auto itrDelete = bgList.begin();
|
||||
|
||||
// first one is template and should not be deleted
|
||||
for (BattlegroundContainer::iterator itr = ++itrDelete; itr != bgList.end();)
|
||||
{
|
||||
itrDelete->second = nullptr;
|
||||
m_Battlegrounds.erase(itrDelete);
|
||||
delete bg;
|
||||
itrDelete = itr++;
|
||||
Battleground* bg = itrDelete->second;
|
||||
|
||||
bg->Update(diff);
|
||||
if (bg->ToBeDeleted())
|
||||
{
|
||||
itrDelete->second = nullptr;
|
||||
bgList.erase(itrDelete);
|
||||
|
||||
BattlegroundClientIdsContainer& clients = bgData._ClientBattlegroundIds[bg->GetBracketId()];
|
||||
if (!clients.empty())
|
||||
clients.erase(bg->GetClientInstanceID());
|
||||
|
||||
delete bg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update events
|
||||
for (int qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
|
||||
for (uint8 qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
|
||||
m_BattlegroundQueues[qtype].UpdateEvents(diff);
|
||||
|
||||
// update using scheduled tasks (used only for rated arenas, initial opponent search works differently than periodic queue update)
|
||||
if (!m_ArenaQueueUpdateScheduler.empty())
|
||||
if (!m_QueueUpdateScheduler.empty())
|
||||
{
|
||||
std::vector<uint64> scheduled;
|
||||
std::swap(scheduled, m_ArenaQueueUpdateScheduler);
|
||||
std::swap(scheduled, m_QueueUpdateScheduler);
|
||||
|
||||
for (uint8 i = 0; i < scheduled.size(); i++)
|
||||
{
|
||||
uint32 arenaRatedTeamId = scheduled[i] >> 32;
|
||||
uint32 arenaMMRating = scheduled[i] >> 32;
|
||||
uint8 arenaType = scheduled[i] >> 24 & 255;
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundQueueTypeId(scheduled[i] >> 16 & 255);
|
||||
BattlegroundTypeId bgTypeId = BattlegroundTypeId((scheduled[i] >> 8) & 255);
|
||||
BattlegroundBracketId bracket_id = BattlegroundBracketId(scheduled[i] & 255);
|
||||
m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(diff, bracket_id, true, arenaRatedTeamId); // pussywizard: looking for opponents only for this team
|
||||
m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(diff, bgTypeId, bracket_id, arenaType, arenaMMRating > 0, arenaMMRating);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,16 +149,16 @@ void BattlegroundMgr::Update(uint32 diff)
|
||||
{
|
||||
m_NextPeriodicQueueUpdateTime = 5 * IN_MILLISECONDS;
|
||||
|
||||
LOG_TRACE("bg.arena", "BattlegroundMgr: UPDATING ARENA QUEUES");
|
||||
|
||||
// for rated arenas
|
||||
for (uint32 qtype = BATTLEGROUND_QUEUE_2v2; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
|
||||
{
|
||||
for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
|
||||
m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(m_NextPeriodicQueueUpdateTime, BattlegroundBracketId(bracket), true, 0); // pussywizard: 0 for rated means looking for opponents for every team
|
||||
|
||||
// for battlegrounds and not rated arenas
|
||||
// in first loop try to fill already running battlegrounds, then in a second loop try to create new battlegrounds
|
||||
for (uint32 qtype = BATTLEGROUND_QUEUE_AV; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
|
||||
for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
|
||||
m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(m_NextPeriodicQueueUpdateTime, BattlegroundBracketId(bracket), false, 0);
|
||||
{
|
||||
m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(diff, BATTLEGROUND_AA, BattlegroundBracketId(bracket), BattlegroundMgr::BGArenaType(BattlegroundQueueTypeId(qtype)), true, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
m_NextPeriodicQueueUpdateTime -= diff;
|
||||
@@ -225,36 +253,108 @@ void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Pla
|
||||
*data << player->GetGUID();
|
||||
}
|
||||
|
||||
Battleground* BattlegroundMgr::GetBattleground(uint32 instanceId)
|
||||
Battleground* BattlegroundMgr::GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
//cause at HandleBattlegroundJoinOpcode the clients sends the instanceid he gets from
|
||||
//SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id
|
||||
Battleground* bg = GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg)
|
||||
return nullptr;
|
||||
|
||||
if (bg->isArena())
|
||||
return GetBattleground(instanceId, bgTypeId);
|
||||
|
||||
auto const& it = bgDataStore.find(bgTypeId);
|
||||
if (it == bgDataStore.end())
|
||||
return nullptr;
|
||||
|
||||
for (auto const& itr : it->second._Battlegrounds)
|
||||
{
|
||||
if (itr.second->GetClientInstanceID() == instanceId)
|
||||
return itr.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Battleground* BattlegroundMgr::GetBattleground(uint32 instanceId, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
if (!instanceId)
|
||||
return nullptr;
|
||||
|
||||
BattlegroundContainer::const_iterator itr = m_Battlegrounds.find(instanceId);
|
||||
if (itr != m_Battlegrounds.end())
|
||||
return itr->second;
|
||||
auto GetBgWithInstanceID = [instanceId](BattlegroundData const* bgData) -> Battleground*
|
||||
{
|
||||
auto const& itr = bgData->_Battlegrounds.find(instanceId);
|
||||
if (itr != bgData->_Battlegrounds.end())
|
||||
return itr->second;
|
||||
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
|
||||
{
|
||||
for (auto const& [bgType, bgData] : bgDataStore)
|
||||
{
|
||||
if (auto bg = GetBgWithInstanceID(&bgData))
|
||||
return bg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const& itr = bgDataStore.find(bgTypeId);
|
||||
if (itr == bgDataStore.end())
|
||||
return nullptr;
|
||||
|
||||
if (auto bg = GetBgWithInstanceID(&itr->second))
|
||||
return bg;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Battleground* BattlegroundMgr::GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
BattlegroundTemplateContainer::const_iterator itr = m_BattlegroundTemplates.find(bgTypeId);
|
||||
if (itr != m_BattlegroundTemplates.end())
|
||||
return itr->second;
|
||||
BattlegroundDataContainer::const_iterator itr = bgDataStore.find(bgTypeId);
|
||||
if (itr == bgDataStore.end())
|
||||
return nullptr;
|
||||
|
||||
return nullptr;
|
||||
BattlegroundContainer const& bgs = itr->second._Battlegrounds;
|
||||
|
||||
// map is sorted and we can be sure that lowest instance id has only BG template
|
||||
return bgs.empty() ? nullptr : bgs.begin()->second;
|
||||
}
|
||||
|
||||
uint32 BattlegroundMgr::GetNextClientVisibleInstanceId()
|
||||
uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
||||
{
|
||||
return ++m_lastClientVisibleInstanceId;
|
||||
if (IsArenaType(bgTypeId))
|
||||
return 0; // arenas don't have client-instanceids
|
||||
|
||||
// we create here an instanceid, which is just for
|
||||
// displaying this to the client and without any other use..
|
||||
// the client-instanceIds are unique for each battleground-type
|
||||
// the instance-id just needs to be as low as possible, beginning with 1
|
||||
// the following works, because std::set is default ordered with "<"
|
||||
// the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
|
||||
|
||||
BattlegroundClientIdsContainer& clientIds = bgDataStore[bgTypeId]._ClientBattlegroundIds[bracket_id];
|
||||
uint32 lastId = 0;
|
||||
|
||||
for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end();)
|
||||
{
|
||||
if ((++lastId) != *itr) // if there is a gap between the ids, we will break..
|
||||
break;
|
||||
|
||||
lastId = *itr;
|
||||
}
|
||||
|
||||
clientIds.emplace(++lastId);
|
||||
return lastId;
|
||||
}
|
||||
|
||||
// create a new battleground that will really be used to play
|
||||
Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId originalBgTypeId, uint32 minLevel, uint32 maxLevel, uint8 arenaType, bool isRated)
|
||||
Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId originalBgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated)
|
||||
{
|
||||
BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId, minLevel);
|
||||
BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId, bracketEntry->minLevel);
|
||||
|
||||
if (originalBgTypeId == BATTLEGROUND_AA)
|
||||
originalBgTypeId = bgTypeId;
|
||||
@@ -262,9 +362,13 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
|
||||
// get the template BG
|
||||
Battleground* bg_template = GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg_template)
|
||||
{
|
||||
LOG_ERROR("bg.battleground", "Battleground: CreateNewBattleground - bg template not found for {}", bgTypeId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Battleground* bg = nullptr;
|
||||
|
||||
// create a copy of the BG template
|
||||
if (BattlegroundMgr::bgTypeToTemplate.find(bgTypeId) == BattlegroundMgr::bgTypeToTemplate.end())
|
||||
{
|
||||
@@ -275,9 +379,9 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
|
||||
|
||||
bool isRandom = bgTypeId != originalBgTypeId && !bg->isArena();
|
||||
|
||||
bg->SetLevelRange(minLevel, maxLevel);
|
||||
bg->SetBracket(bracketEntry);
|
||||
bg->SetInstanceID(sMapMgr->GenerateInstanceId());
|
||||
bg->SetClientInstanceID(IsArenaType(originalBgTypeId) ? 0 : GetNextClientVisibleInstanceId());
|
||||
bg->SetClientInstanceID(CreateClientVisibleInstanceId(originalBgTypeId, bracketEntry->GetBracketId()));
|
||||
bg->Init();
|
||||
bg->SetStatus(STATUS_WAIT_JOIN); // start the joining of the bg
|
||||
bg->SetArenaType(arenaType);
|
||||
@@ -298,37 +402,40 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
|
||||
}
|
||||
|
||||
// used to create the BG templates
|
||||
bool BattlegroundMgr::CreateBattleground(CreateBattlegroundData& data)
|
||||
bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate)
|
||||
{
|
||||
// Create the BG
|
||||
Battleground* bg = nullptr;
|
||||
bg = BattlegroundMgr::bgtypeToBattleground[data.bgTypeId];
|
||||
Battleground* bg = GetBattlegroundTemplate(bgTemplate->Id);
|
||||
|
||||
if (bg == nullptr)
|
||||
return false;
|
||||
if (!bg)
|
||||
{
|
||||
bg = BattlegroundMgr::bgtypeToBattleground[bgTemplate->Id];
|
||||
|
||||
if (data.bgTypeId == BATTLEGROUND_RB)
|
||||
bg->SetRandom(true);
|
||||
ASSERT(bg);
|
||||
|
||||
bg->SetMapId(data.MapID);
|
||||
bg->SetBgTypeID(data.bgTypeId);
|
||||
bg->SetInstanceID(0);
|
||||
bg->SetArenaorBGType(data.IsArena);
|
||||
bg->SetMinPlayersPerTeam(data.MinPlayersPerTeam);
|
||||
bg->SetMaxPlayersPerTeam(data.MaxPlayersPerTeam);
|
||||
bg->SetName(data.BattlegroundName);
|
||||
bg->SetTeamStartPosition(TEAM_ALLIANCE, data.StartLocation[TEAM_ALLIANCE]);
|
||||
bg->SetTeamStartPosition(TEAM_HORDE, data.StartLocation[TEAM_HORDE]);
|
||||
bg->SetStartMaxDist(data.StartMaxDist);
|
||||
bg->SetLevelRange(data.LevelMin, data.LevelMax);
|
||||
bg->SetScriptId(data.scriptId);
|
||||
if (bgTemplate->Id == BATTLEGROUND_RB)
|
||||
bg->SetRandom(true);
|
||||
|
||||
AddBattleground(bg);
|
||||
bg->SetBgTypeID(bgTemplate->Id);
|
||||
bg->SetInstanceID(0);
|
||||
AddBattleground(bg);
|
||||
}
|
||||
|
||||
bg->SetMapId(bgTemplate->BattlemasterEntry->mapid[0]);
|
||||
bg->SetName(bgTemplate->BattlemasterEntry->name[sWorld->GetDefaultDbcLocale()]);
|
||||
bg->SetArenaorBGType(bgTemplate->IsArena());
|
||||
bg->SetMinPlayersPerTeam(bgTemplate->MinPlayersPerTeam);
|
||||
bg->SetMaxPlayersPerTeam(bgTemplate->MaxPlayersPerTeam);
|
||||
bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]);
|
||||
bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]);
|
||||
bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
|
||||
bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
|
||||
bg->SetScriptId(bgTemplate->ScriptId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::CreateInitialBattlegrounds()
|
||||
void BattlegroundMgr::LoadBattlegroundTemplates()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -344,13 +451,11 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 bgTypeId = fields[0].Get<uint32>();
|
||||
BattlegroundTypeId bgTypeId = static_cast<BattlegroundTypeId>(fields[0].Get<uint32>());
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
|
||||
continue;
|
||||
@@ -363,72 +468,69 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
||||
continue;
|
||||
}
|
||||
|
||||
CreateBattlegroundData data;
|
||||
data.bgTypeId = BattlegroundTypeId(bgTypeId);
|
||||
data.IsArena = (bl->type == TYPE_ARENA);
|
||||
data.MinPlayersPerTeam = fields[1].Get<uint16>();
|
||||
data.MaxPlayersPerTeam = fields[2].Get<uint16>();
|
||||
data.LevelMin = fields[3].Get<uint8>();
|
||||
data.LevelMax = fields[4].Get<uint8>();
|
||||
BattlegroundTemplate bgTemplate;
|
||||
bgTemplate.Id = bgTypeId;
|
||||
bgTemplate.MinPlayersPerTeam = fields[1].Get<uint16>();
|
||||
bgTemplate.MaxPlayersPerTeam = fields[2].Get<uint16>();
|
||||
bgTemplate.MinLevel = fields[3].Get<uint8>();
|
||||
bgTemplate.MaxLevel = fields[4].Get<uint8>();
|
||||
float dist = fields[9].Get<float>();
|
||||
data.StartMaxDist = dist * dist;
|
||||
data.Weight = fields[10].Get<uint8>();
|
||||
bgTemplate.MaxStartDistSq = dist * dist;
|
||||
bgTemplate.Weight = fields[10].Get<uint8>();
|
||||
bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].Get<std::string>());
|
||||
bgTemplate.BattlemasterEntry = bl;
|
||||
|
||||
data.scriptId = sObjectMgr->GetScriptId(fields[11].Get<std::string>());
|
||||
data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()];
|
||||
data.MapID = bl->mapid[0];
|
||||
|
||||
if (data.MaxPlayersPerTeam == 0 || data.MinPlayersPerTeam > data.MaxPlayersPerTeam)
|
||||
if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
|
||||
{
|
||||
LOG_ERROR("bg.battleground", "Table `battleground_template` for id {} has bad values for MinPlayersPerTeam ({}) and MaxPlayersPerTeam({})",
|
||||
data.bgTypeId, data.MinPlayersPerTeam, data.MaxPlayersPerTeam);
|
||||
LOG_ERROR("sql.sql", "Table `battleground_template` for id {} contains bad values for MinPlayersPerTeam ({}) and MaxPlayersPerTeam({}).",
|
||||
bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.LevelMin == 0 || data.LevelMax == 0 || data.LevelMin > data.LevelMax)
|
||||
if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel)
|
||||
{
|
||||
LOG_ERROR("bg.battleground", "Table `battleground_template` for id {} has bad values for LevelMin ({}) and LevelMax({})",
|
||||
data.bgTypeId, data.LevelMin, data.LevelMax);
|
||||
LOG_ERROR("sql.sql", "Table `battleground_template` for id {} has bad values for LevelMin ({}) and LevelMax({})",
|
||||
bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.bgTypeId != BATTLEGROUND_AA && data.bgTypeId != BATTLEGROUND_RB)
|
||||
if (bgTemplate.Id != BATTLEGROUND_AA && bgTemplate.Id != BATTLEGROUND_RB)
|
||||
{
|
||||
uint32 startId = fields[5].Get<uint32>();
|
||||
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
|
||||
{
|
||||
data.StartLocation[TEAM_ALLIANCE].Relocate(start->x, start->y, start->z, fields[6].Get<float>());
|
||||
bgTemplate.StartLocation[TEAM_ALLIANCE].Relocate(start->x, start->y, start->z, fields[6].Get<float>());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", data.bgTypeId, startId);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
||||
startId = fields[7].Get<uint32>();
|
||||
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
|
||||
{
|
||||
data.StartLocation[TEAM_HORDE].Relocate(start->x, start->y, start->z, fields[8].Get<float>());
|
||||
bgTemplate.StartLocation[TEAM_HORDE].Relocate(start->x, start->y, start->z, fields[8].Get<float>());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", data.bgTypeId, startId);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CreateBattleground(data))
|
||||
if (!CreateBattleground(&bgTemplate))
|
||||
continue;
|
||||
|
||||
_battlegroundTemplates[BattlegroundTypeId(bgTypeId)] = data;
|
||||
_battlegroundTemplates[bgTypeId] = bgTemplate;
|
||||
|
||||
if (bl->mapid[1] == -1) // in this case we have only one mapId
|
||||
_battlegroundMapTemplates[bl->mapid[0]] = &_battlegroundTemplates[BattlegroundTypeId(bgTypeId)];
|
||||
if (bgTemplate.BattlemasterEntry->mapid[1] == -1) // in this case we have only one mapId
|
||||
_battlegroundMapTemplates[bgTemplate.BattlemasterEntry->mapid[0]] = &_battlegroundTemplates[bgTypeId];
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} battlegrounds in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", ">> Loaded {} battlegrounds in {} ms", _battlegroundTemplates.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
@@ -499,23 +601,31 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid
|
||||
size_t count_pos = data->wpos();
|
||||
*data << uint32(0); // number of bg instances
|
||||
|
||||
if (Battleground* bgt = GetBattlegroundTemplate(bgTypeId))
|
||||
if (GetBattlegroundBracketByLevel(bgt->GetMapId(), player->getLevel()))
|
||||
auto const& it = bgDataStore.find(bgTypeId);
|
||||
if (it != bgDataStore.end())
|
||||
{
|
||||
// expected bracket entry
|
||||
if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(it->second._Battlegrounds.begin()->second->GetMapId(), player->getLevel()))
|
||||
{
|
||||
uint32 count = 0;
|
||||
/*for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end(); ++itr)
|
||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
BattlegroundClientIdsContainer& clientIds = it->second._ClientBattlegroundIds[bracketId];
|
||||
|
||||
for (auto const& itr : clientIds)
|
||||
{
|
||||
*data << uint32(*itr);
|
||||
*data << uint32(itr);
|
||||
++count;
|
||||
}*/
|
||||
}
|
||||
|
||||
data->put<uint32>(count_pos, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
if (Battleground* bg = GetBattleground(instanceId))
|
||||
if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
|
||||
{
|
||||
uint32 mapid = bg->GetMapId();
|
||||
Position const* pos = bg->GetTeamStartPosition(player->GetBgTeamId());
|
||||
@@ -636,11 +746,25 @@ void BattlegroundMgr::SetHolidayWeekends(uint32 mask)
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundMgr::ScheduleArenaQueueUpdate(uint32 arenaRatedTeamId, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id)
|
||||
void BattlegroundMgr::ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
||||
{
|
||||
uint64 const scheduleId = ((uint64)arenaRatedTeamId << 32) | (bgQueueTypeId << 16) | bracket_id;
|
||||
if (std::find(m_ArenaQueueUpdateScheduler.begin(), m_ArenaQueueUpdateScheduler.end(), scheduleId) == m_ArenaQueueUpdateScheduler.end())
|
||||
m_ArenaQueueUpdateScheduler.push_back(scheduleId);
|
||||
//This method must be atomic, @todo add mutex
|
||||
//we will use only 1 number created of bgTypeId and bracket_id
|
||||
uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | ((uint64)arenaType << 24) | ((uint64)bgQueueTypeId << 16) | ((uint64)bgTypeId << 8) | (uint64)bracket_id;
|
||||
if (std::find(m_QueueUpdateScheduler.begin(), m_QueueUpdateScheduler.end(), scheduleId) == m_QueueUpdateScheduler.end())
|
||||
m_QueueUpdateScheduler.emplace_back(scheduleId);
|
||||
}
|
||||
|
||||
uint32 BattlegroundMgr::GetMaxRatingDifference() const
|
||||
{
|
||||
uint32 diff = sWorld->getIntConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE);
|
||||
|
||||
if (diff == 0)
|
||||
{
|
||||
diff = 5000;
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
uint32 BattlegroundMgr::GetRatingDiscardTimer() const
|
||||
@@ -663,7 +787,7 @@ void BattlegroundMgr::LoadBattleMastersEntry()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_INFO("server.loading", ">> Loaded 0 battlemaster entries. DB table `battlemaster_entry` is empty!");
|
||||
LOG_WARN("server.loading", ">> Loaded 0 battlemaster entries. DB table `battlemaster_entry` is empty!");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
@@ -766,24 +890,23 @@ bool BattlegroundMgr::IsBGWeekend(BattlegroundTypeId bgTypeId)
|
||||
|
||||
BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId, uint32 minLevel)
|
||||
{
|
||||
if (GetBattlegroundTemplateByTypeId(bgTypeId))
|
||||
if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
|
||||
{
|
||||
std::vector<BattlegroundTypeId> ids;
|
||||
ids.reserve(16);
|
||||
std::vector<double> weights;
|
||||
weights.reserve(16);
|
||||
BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
|
||||
|
||||
for (int32 mapId : bl->mapid)
|
||||
for (int32 mapId : bgTemplate->BattlemasterEntry->mapid)
|
||||
{
|
||||
if (mapId == -1)
|
||||
break;
|
||||
|
||||
if (CreateBattlegroundData const* bg = GetBattlegroundTemplateByMapId(mapId))
|
||||
if (BattlegroundTemplate const* bg = GetBattlegroundTemplateByMapId(mapId))
|
||||
{
|
||||
if (bg->LevelMin <= minLevel)
|
||||
if (bg->MinLevel <= minLevel)
|
||||
{
|
||||
ids.push_back(bg->bgTypeId);
|
||||
ids.push_back(bg->Id);
|
||||
weights.push_back(bg->Weight);
|
||||
}
|
||||
}
|
||||
@@ -795,30 +918,38 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId, uin
|
||||
return BATTLEGROUND_TYPE_NONE;
|
||||
}
|
||||
|
||||
BGFreeSlotQueueContainer& BattlegroundMgr::GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
return bgDataStore[bgTypeId].BGFreeSlotQueue;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground* bg)
|
||||
{
|
||||
bgDataStore[bgTypeId].BGFreeSlotQueue.push_front(bg);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId)
|
||||
{
|
||||
BGFreeSlotQueueContainer& queues = bgDataStore[bgTypeId].BGFreeSlotQueue;
|
||||
for (BGFreeSlotQueueContainer::iterator itr = queues.begin(); itr != queues.end(); ++itr)
|
||||
if ((*itr)->GetInstanceID() == instanceId)
|
||||
{
|
||||
queues.erase(itr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundMgr::AddBattleground(Battleground* bg)
|
||||
{
|
||||
if (bg->GetInstanceID() == 0)
|
||||
m_BattlegroundTemplates[bg->GetBgTypeID()] = bg;
|
||||
else
|
||||
m_Battlegrounds[bg->GetInstanceID()] = bg;
|
||||
if (bg)
|
||||
bgDataStore[bg->GetBgTypeID()]._Battlegrounds[bg->GetInstanceID()] = bg;
|
||||
|
||||
sScriptMgr->OnBattlegroundCreate(bg);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
|
||||
{
|
||||
if (instanceId == 0)
|
||||
m_BattlegroundTemplates.erase(bgTypeId);
|
||||
else
|
||||
m_Battlegrounds.erase(instanceId);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::DoForAllBattlegrounds(std::function<void(Battleground*)> const& worker)
|
||||
{
|
||||
for (auto const& [_, bg] : m_Battlegrounds)
|
||||
{
|
||||
worker(bg);
|
||||
}
|
||||
bgDataStore[bgTypeId]._Battlegrounds.erase(instanceId);
|
||||
}
|
||||
|
||||
// init/update unordered_map
|
||||
|
||||
@@ -27,29 +27,38 @@
|
||||
#include <functional>
|
||||
|
||||
typedef std::map<uint32, Battleground*> BattlegroundContainer;
|
||||
typedef std::set<uint32> BattlegroundClientIdsContainer;
|
||||
typedef std::unordered_map<uint32, BattlegroundTypeId> BattleMastersMap;
|
||||
typedef Battleground* (*bgRef)(Battleground*);
|
||||
|
||||
typedef void(*bgMapRef)(WorldPacket*, Battleground::BattlegroundScoreMap::const_iterator);
|
||||
typedef void(*bgTypeRef)(WorldPacket*, Battleground::BattlegroundScoreMap::const_iterator, Battleground*);
|
||||
|
||||
struct CreateBattlegroundData
|
||||
// this container can't be deque, because deque doesn't like removing the last element - if you remove it, it invalidates next iterator and crash appears
|
||||
using BGFreeSlotQueueContainer = std::list<Battleground*>;
|
||||
|
||||
struct BattlegroundData
|
||||
{
|
||||
BattlegroundTypeId bgTypeId;
|
||||
bool IsArena;
|
||||
uint32 MinPlayersPerTeam;
|
||||
uint32 MaxPlayersPerTeam;
|
||||
uint32 LevelMin;
|
||||
uint32 LevelMax;
|
||||
char const* BattlegroundName;
|
||||
uint32 MapID;
|
||||
float StartMaxDist;
|
||||
std::array<Position, PVP_TEAMS_COUNT> StartLocation;
|
||||
uint32 scriptId;
|
||||
uint8 Weight;
|
||||
BattlegroundContainer _Battlegrounds;
|
||||
std::array<BattlegroundClientIdsContainer, MAX_BATTLEGROUND_BRACKETS> _ClientBattlegroundIds;
|
||||
BGFreeSlotQueueContainer BGFreeSlotQueue;
|
||||
};
|
||||
|
||||
struct GroupQueueInfo;
|
||||
struct BattlegroundTemplate
|
||||
{
|
||||
BattlegroundTypeId Id;
|
||||
uint16 MinPlayersPerTeam;
|
||||
uint16 MaxPlayersPerTeam;
|
||||
uint8 MinLevel;
|
||||
uint8 MaxLevel;
|
||||
std::array<Position, PVP_TEAMS_COUNT> StartLocation;
|
||||
float MaxStartDistSq;
|
||||
uint8 Weight;
|
||||
uint32 ScriptId;
|
||||
BattlemasterListEntry const* BattlemasterEntry;
|
||||
|
||||
bool IsArena() const;
|
||||
};
|
||||
|
||||
class BattlegroundMgr
|
||||
{
|
||||
@@ -71,21 +80,25 @@ public:
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
|
||||
|
||||
/* Battlegrounds */
|
||||
Battleground* GetBattleground(uint32 InstanceID);
|
||||
Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
|
||||
Battleground* GetBattleground(uint32 instanceID, BattlegroundTypeId bgTypeId);
|
||||
Battleground* GetBattlegroundTemplate(BattlegroundTypeId bgTypeId);
|
||||
Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, uint32 minLevel, uint32 maxLevel, uint8 arenaType, bool isRated);
|
||||
Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
|
||||
|
||||
void AddBattleground(Battleground* bg);
|
||||
void RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId);
|
||||
void AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground* bg);
|
||||
void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
|
||||
BGFreeSlotQueueContainer& GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId);
|
||||
|
||||
void CreateInitialBattlegrounds();
|
||||
void LoadBattlegroundTemplates();
|
||||
void DeleteAllBattlegrounds();
|
||||
|
||||
void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
|
||||
|
||||
/* Battleground queues */
|
||||
BattlegroundQueue& GetBattlegroundQueue(BattlegroundQueueTypeId bgQueueTypeId) { return m_BattlegroundQueues[bgQueueTypeId]; }
|
||||
void ScheduleArenaQueueUpdate(uint32 arenaRatedTeamId, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id);
|
||||
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
|
||||
uint32 GetPrematureFinishTime() const;
|
||||
|
||||
void ToggleArenaTesting();
|
||||
@@ -105,10 +118,12 @@ public:
|
||||
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday);
|
||||
static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
|
||||
|
||||
uint32 GetRatingDiscardTimer() const;
|
||||
uint32 GetMaxRatingDifference() const;
|
||||
uint32 GetRatingDiscardTimer() const;
|
||||
void InitAutomaticArenaPointDistribution();
|
||||
void LoadBattleMastersEntry();
|
||||
void CheckBattleMasters();
|
||||
|
||||
BattlegroundTypeId GetBattleMasterBG(uint32 entry) const
|
||||
{
|
||||
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
|
||||
@@ -117,8 +132,6 @@ public:
|
||||
return BATTLEGROUND_TYPE_NONE;
|
||||
}
|
||||
|
||||
const BattlegroundContainer& GetBattlegroundList() { return m_Battlegrounds; } // pussywizard
|
||||
|
||||
static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
|
||||
static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
|
||||
static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
|
||||
@@ -128,48 +141,46 @@ public:
|
||||
static std::unordered_map<uint32, BattlegroundQueueTypeId> ArenaTypeToQueue; // ArenaType -> BattlegroundQueueTypeId
|
||||
static std::unordered_map<uint32, ArenaType> QueueToArenaType; // BattlegroundQueueTypeId -> ArenaType
|
||||
|
||||
void DoForAllBattlegrounds(std::function<void(Battleground*)> const& worker);
|
||||
|
||||
private:
|
||||
bool CreateBattleground(CreateBattlegroundData& data);
|
||||
uint32 GetNextClientVisibleInstanceId();
|
||||
bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
|
||||
uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
|
||||
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id, uint32 minLevel);
|
||||
|
||||
typedef std::map<BattlegroundTypeId, Battleground*> BattlegroundTemplateContainer;
|
||||
BattlegroundTemplateContainer m_BattlegroundTemplates;
|
||||
BattlegroundContainer m_Battlegrounds;
|
||||
typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
|
||||
BattlegroundDataContainer bgDataStore;
|
||||
|
||||
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES];
|
||||
|
||||
std::vector<uint64> m_ArenaQueueUpdateScheduler;
|
||||
std::vector<uint64> m_QueueUpdateScheduler;
|
||||
bool m_ArenaTesting;
|
||||
bool m_Testing;
|
||||
uint32 m_lastClientVisibleInstanceId;
|
||||
Seconds m_NextAutoDistributionTime;
|
||||
uint32 m_AutoDistributionTimeChecker;
|
||||
uint32 m_NextPeriodicQueueUpdateTime;
|
||||
BattleMastersMap mBattleMastersMap;
|
||||
|
||||
CreateBattlegroundData const* GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
|
||||
BattlegroundTemplate const* GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
|
||||
{
|
||||
BattlegroundTemplateMap::const_iterator itr = _battlegroundTemplates.find(id);
|
||||
auto const& itr = _battlegroundTemplates.find(id);
|
||||
if (itr != _battlegroundTemplates.end())
|
||||
return &itr->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CreateBattlegroundData const* GetBattlegroundTemplateByMapId(uint32 mapId)
|
||||
BattlegroundTemplate const* GetBattlegroundTemplateByMapId(uint32 mapId)
|
||||
{
|
||||
BattlegroundMapTemplateContainer::const_iterator itr = _battlegroundMapTemplates.find(mapId);
|
||||
auto const& itr = _battlegroundMapTemplates.find(mapId);
|
||||
if (itr != _battlegroundMapTemplates.end())
|
||||
return itr->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
|
||||
|
||||
typedef std::map<BattlegroundTypeId, CreateBattlegroundData> BattlegroundTemplateMap;
|
||||
typedef std::map<uint32 /*mapId*/, CreateBattlegroundData*> BattlegroundMapTemplateContainer;
|
||||
typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
|
||||
typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
|
||||
BattlegroundTemplateMap _battlegroundTemplates;
|
||||
BattlegroundMapTemplateContainer _battlegroundMapTemplates;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@
|
||||
#include <array>
|
||||
#include <deque>
|
||||
|
||||
#define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10
|
||||
constexpr auto COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME = 10;
|
||||
|
||||
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
|
||||
{
|
||||
@@ -43,10 +43,9 @@ struct GroupQueueInfo // stores informatio
|
||||
uint32 ArenaMatchmakerRating; // if rated match, inited to the rating of the team
|
||||
uint32 OpponentsTeamRating; // for rated arena matches
|
||||
uint32 OpponentsMatchmakerRating; // for rated arena matches
|
||||
|
||||
// pussywizard: for internal use
|
||||
uint8 _bracketId;
|
||||
uint8 _groupType;
|
||||
uint32 PreviousOpponentsTeamId; // excluded from the current queue until the timer is met
|
||||
uint8 BracketId; // BattlegroundBracketId
|
||||
uint8 GroupType; // BattlegroundQueueGroupTypes
|
||||
};
|
||||
|
||||
enum BattlegroundQueueGroupTypes
|
||||
@@ -61,22 +60,21 @@ enum BattlegroundQueueGroupTypes
|
||||
BG_QUEUE_MAX = 10
|
||||
};
|
||||
|
||||
class Battleground;
|
||||
class BattlegroundQueue
|
||||
{
|
||||
public:
|
||||
BattlegroundQueue();
|
||||
~BattlegroundQueue();
|
||||
|
||||
void BattlegroundQueueUpdate(uint32 diff, BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId);
|
||||
void BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating);
|
||||
void UpdateEvents(uint32 diff);
|
||||
|
||||
void FillPlayersToBG(Battleground* bg, int32 aliFree, int32 hordeFree, BattlegroundBracketId bracket_id);
|
||||
void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id);
|
||||
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
|
||||
bool CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
|
||||
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);
|
||||
void RemovePlayer(ObjectGuid guid, bool sentToBg, uint32 playerQueueSlot);
|
||||
GroupQueueInfo* AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 matchmakerRating, uint32 arenaTeamId = 0, uint32 opponentsArenaTeamId = 0);
|
||||
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount);
|
||||
bool IsPlayerInvitedToRatedArena(ObjectGuid pl_guid);
|
||||
bool IsPlayerInvited(ObjectGuid pl_guid, uint32 bgInstanceGuid, uint32 removeTime);
|
||||
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);
|
||||
@@ -89,7 +87,6 @@ public:
|
||||
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 AddEvent(BasicEvent* Event, uint64 e_time);
|
||||
|
||||
typedef std::map<ObjectGuid, GroupQueueInfo*> QueuedPlayersMap;
|
||||
@@ -127,15 +124,10 @@ public:
|
||||
//one selection pool for horde, other one for alliance
|
||||
SelectionPool m_SelectionPools[PVP_TEAMS_COUNT];
|
||||
|
||||
ArenaType GetArenaType() { return m_arenaType; }
|
||||
BattlegroundTypeId GetBGTypeID() { return m_bgTypeId; }
|
||||
|
||||
void SetQueueAnnouncementTimer(uint32 bracketId, int32 timer, bool isCrossFactionBG = true);
|
||||
[[nodiscard]] int32 GetQueueAnnouncementTimer(uint32 bracketId) const;
|
||||
|
||||
private:
|
||||
BattlegroundTypeId m_bgTypeId;
|
||||
ArenaType m_arenaType;
|
||||
uint32 m_WaitTimes[PVP_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME];
|
||||
uint32 m_WaitTimeLastIndex[PVP_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS];
|
||||
|
||||
@@ -176,9 +168,8 @@ private:
|
||||
class BGQueueRemoveEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
BGQueueRemoveEvent(ObjectGuid pl_guid, uint32 bgInstanceGUID, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime)
|
||||
: m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgQueueTypeId(bgQueueTypeId)
|
||||
{}
|
||||
BGQueueRemoveEvent(ObjectGuid pl_guid, uint32 bgInstanceGUID, BattlegroundTypeId BgTypeId, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime) :
|
||||
m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId) { }
|
||||
|
||||
~BGQueueRemoveEvent() override = default;
|
||||
|
||||
@@ -188,6 +179,7 @@ private:
|
||||
ObjectGuid m_PlayerGuid;
|
||||
uint32 m_BgInstanceGUID;
|
||||
uint32 m_RemoveTime;
|
||||
BattlegroundTypeId m_BgTypeId;
|
||||
BattlegroundQueueTypeId m_BgQueueTypeId;
|
||||
};
|
||||
|
||||
|
||||
@@ -287,18 +287,6 @@ protected:
|
||||
uint32 BasesDefended = 0;
|
||||
};
|
||||
|
||||
struct CaptureABPointInfo
|
||||
{
|
||||
CaptureABPointInfo() : _ownerTeamId(TEAM_NEUTRAL), _iconNone(0), _iconCapture(0), _state(BG_AB_NODE_STATE_NEUTRAL), _captured(false) {}
|
||||
|
||||
TeamId _ownerTeamId;
|
||||
uint32 _iconNone;
|
||||
uint32 _iconCapture;
|
||||
uint8 _state;
|
||||
|
||||
bool _captured;
|
||||
};
|
||||
|
||||
class AC_GAME_API BattlegroundAB : public Battleground
|
||||
{
|
||||
public:
|
||||
@@ -323,10 +311,7 @@ public:
|
||||
bool IsTeamScores500Disadvantage(TeamId teamId) const { return _teamScores500Disadvantage[teamId]; }
|
||||
|
||||
TeamId GetPrematureWinner() override;
|
||||
|
||||
[[nodiscard]] CaptureABPointInfo const& GetCapturePointInfo(uint32 node) const { return _capturePointInfo[node]; }
|
||||
|
||||
private :
|
||||
private:
|
||||
void PostUpdateImpl(uint32 diff) override;
|
||||
|
||||
void DeleteBanner(uint8 node);
|
||||
@@ -336,7 +321,21 @@ private :
|
||||
void NodeDeoccupied(uint8 node);
|
||||
void ApplyPhaseMask();
|
||||
|
||||
CaptureABPointInfo _capturePointInfo[BG_AB_DYNAMIC_NODES_COUNT];
|
||||
struct CapturePointInfo
|
||||
{
|
||||
CapturePointInfo() : _ownerTeamId(TEAM_NEUTRAL), _iconNone(0), _iconCapture(0), _state(BG_AB_NODE_STATE_NEUTRAL), _captured(false)
|
||||
{
|
||||
}
|
||||
|
||||
TeamId _ownerTeamId;
|
||||
uint32 _iconNone;
|
||||
uint32 _iconCapture;
|
||||
uint8 _state;
|
||||
|
||||
bool _captured;
|
||||
};
|
||||
|
||||
CapturePointInfo _capturePointInfo[BG_AB_DYNAMIC_NODES_COUNT];
|
||||
EventMap _bgEvents;
|
||||
uint32 _honorTics;
|
||||
uint32 _reputationTics;
|
||||
|
||||
@@ -376,25 +376,6 @@ protected:
|
||||
uint32 FlagCaptures = 0;
|
||||
};
|
||||
|
||||
struct CaptureEYPointInfo
|
||||
{
|
||||
CaptureEYPointInfo() : _ownerTeamId(TEAM_NEUTRAL), _barStatus(BG_EY_PROGRESS_BAR_STATE_MIDDLE), _areaTrigger(0)
|
||||
{
|
||||
_playersCount[TEAM_ALLIANCE] = 0;
|
||||
_playersCount[TEAM_HORDE] = 0;
|
||||
}
|
||||
|
||||
Player* player = nullptr;
|
||||
TeamId _ownerTeamId;
|
||||
int8 _barStatus;
|
||||
uint32 _areaTrigger;
|
||||
int8 _playersCount[PVP_TEAMS_COUNT];
|
||||
|
||||
bool IsUnderControl(TeamId teamId) const { return _ownerTeamId == teamId; }
|
||||
bool IsUnderControl() const { return _ownerTeamId != TEAM_NEUTRAL; }
|
||||
bool IsUncontrolled() const { return _ownerTeamId == TEAM_NEUTRAL; }
|
||||
};
|
||||
|
||||
class AC_GAME_API BattlegroundEY : public Battleground
|
||||
{
|
||||
public:
|
||||
@@ -434,8 +415,6 @@ public:
|
||||
bool AllNodesConrolledByTeam(TeamId teamId) const override;
|
||||
TeamId GetPrematureWinner() override;
|
||||
|
||||
[[nodiscard]] CaptureEYPointInfo const& GetCapturePointInfo(uint32 node) const { return _capturePointInfo[node]; }
|
||||
|
||||
private:
|
||||
void PostUpdateImpl(uint32 diff) override;
|
||||
|
||||
@@ -451,7 +430,26 @@ private:
|
||||
/* Scorekeeping */
|
||||
void AddPoints(TeamId teamId, uint32 points);
|
||||
|
||||
CaptureEYPointInfo _capturePointInfo[EY_POINTS_MAX];
|
||||
struct CapturePointInfo
|
||||
{
|
||||
CapturePointInfo() : _ownerTeamId(TEAM_NEUTRAL), _barStatus(BG_EY_PROGRESS_BAR_STATE_MIDDLE), _areaTrigger(0)
|
||||
{
|
||||
_playersCount[TEAM_ALLIANCE] = 0;
|
||||
_playersCount[TEAM_HORDE] = 0;
|
||||
}
|
||||
|
||||
TeamId _ownerTeamId;
|
||||
int8 _barStatus;
|
||||
uint32 _areaTrigger;
|
||||
int8 _playersCount[PVP_TEAMS_COUNT];
|
||||
Player* player = nullptr;
|
||||
|
||||
bool IsUnderControl(TeamId teamId) const { return _ownerTeamId == teamId; }
|
||||
bool IsUnderControl() const { return _ownerTeamId != TEAM_NEUTRAL; }
|
||||
bool IsUncontrolled() const { return _ownerTeamId == TEAM_NEUTRAL; }
|
||||
};
|
||||
|
||||
CapturePointInfo _capturePointInfo[EY_POINTS_MAX];
|
||||
EventMap _bgEvents;
|
||||
uint32 _honorTics;
|
||||
uint8 _ownedPointsCount[PVP_TEAMS_COUNT];
|
||||
|
||||
@@ -983,9 +983,6 @@ public:
|
||||
bool AllNodesConrolledByTeam(TeamId teamId) const override; // overwrited
|
||||
bool IsResourceGlutAllowed(TeamId teamId) const;
|
||||
void DoAction(uint32 action, ObjectGuid guid) override;
|
||||
|
||||
[[nodiscard]] ICNodePoint const& GetICNodePoint(uint8 index) { return nodePoint[index]; }
|
||||
|
||||
private:
|
||||
uint32 closeFortressDoorsTimer;
|
||||
bool doorsClosed;
|
||||
|
||||
Reference in New Issue
Block a user