Core/Battlegrounds: Rework queues
* No more copies of Battleground classes * FreesSlotQueues now have as key the MapId instead of queue id * Random queues can now popup already busy specific battelgrounds (queues are NOT merged) * Removed Holiday handling, this should already be handled in BattlegroundMgr::IsBGWeekend Port From (https://github.com/TrinityCore/TrinityCore/commit/0ede6c155605da602b3bafaa3a1212d9f924759b)
This commit is contained in:
@@ -278,13 +278,6 @@ namespace Framework.Constants
|
||||
WaitLeave = 4 // means some faction has won BG and it is ending
|
||||
}
|
||||
|
||||
public enum BGHonorMode
|
||||
{
|
||||
Normal = 0,
|
||||
Holiday,
|
||||
HonorModeNum
|
||||
}
|
||||
|
||||
public enum GroupJoinBattlegroundResult
|
||||
{
|
||||
None = 0,
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Framework.Constants
|
||||
/// </summary>
|
||||
public const int PvpTeamsCount = 2;
|
||||
public const uint CountOfPlayersToAverageWaitTime = 10;
|
||||
public const uint MaxPlayerBGQueues = 2;
|
||||
public const uint MaxPlayerBGQueues = 3;
|
||||
public const uint BGAwardArenaPointsMinLevel = 71;
|
||||
public const int ArenaTimeLimitPointsLoss = -16;
|
||||
public const int MaxArenaSlot = 3;
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_TRANSMOG_OUTFITS, "SELECT setguid, setindex, name, iconname, ignore_mask, appearance0, appearance1, appearance2, appearance3, appearance4, " +
|
||||
"appearance5, appearance6, appearance7, appearance8, appearance9, appearance10, appearance11, appearance12, appearance13, appearance14, appearance15, appearance16, " +
|
||||
"appearance17, appearance18, mainHandEnchant, offHandEnchant FROM character_transmog_outfits WHERE guid = ? ORDER BY setindex");
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell, queueId FROM character_battleground_data WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_GLYPHS, "SELECT talentGroup, glyphId FROM character_glyphs WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_TALENTS, "SELECT talentId, talentGroup FROM character_talent WHERE guid = ?");
|
||||
PrepareStatement(CharStatements.SEL_CHARACTER_PVP_TALENTS, "SELECT talentId0, talentId1, talentId2, talentId3, talentGroup FROM character_pvp_talent WHERE guid = ?");
|
||||
@@ -387,7 +387,7 @@ namespace Framework.Database
|
||||
PrepareStatement(CharStatements.UPD_ARENA_TEAM_NAME, "UPDATE arena_team SET name = ? WHERE arenaTeamId = ?");
|
||||
|
||||
// Character battleground data
|
||||
PrepareStatement(CharStatements.INS_PLAYER_BGDATA, "INSERT INTO character_battleground_data (guid, instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(CharStatements.INS_PLAYER_BGDATA, "INSERT INTO character_battleground_data (guid, instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell, queueId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PrepareStatement(CharStatements.DEL_PLAYER_BGDATA, "DELETE FROM character_battleground_data WHERE guid = ?");
|
||||
|
||||
// Character homebind
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace Game.Arenas
|
||||
StartMessageIds[BattlegroundConst.EventIdFourth] = ArenaBroadcastTexts.HasBegun;
|
||||
}
|
||||
|
||||
public override void AddPlayer(Player player)
|
||||
public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
base.AddPlayer(player);
|
||||
base.AddPlayer(player, queueId);
|
||||
if (!isInBattleground)
|
||||
PlayerScores[player.GetGUID()] = new ArenaScore(player.GetGUID(), player.GetBGTeam());
|
||||
|
||||
|
||||
@@ -24,12 +24,9 @@ namespace Game.BattleGrounds
|
||||
public Battleground(BattlegroundTemplate battlegroundTemplate)
|
||||
{
|
||||
_battlegroundTemplate = battlegroundTemplate;
|
||||
m_RandomTypeID = BattlegroundTypeId.None;
|
||||
m_Status = BattlegroundStatus.None;
|
||||
_winnerTeamId = PvPTeamId.Neutral;
|
||||
|
||||
m_HonorMode = BGHonorMode.Normal;
|
||||
|
||||
StartDelayTimes[BattlegroundConst.EventIdFirst] = BattlegroundStartTimeIntervals.Delay2m;
|
||||
StartDelayTimes[BattlegroundConst.EventIdSecond] = BattlegroundStartTimeIntervals.Delay1m;
|
||||
StartDelayTimes[BattlegroundConst.EventIdThird] = BattlegroundStartTimeIntervals.Delay30s;
|
||||
@@ -632,7 +629,7 @@ namespace Game.BattleGrounds
|
||||
stmt.AddValue(0, battlegroundId);
|
||||
stmt.AddValue(1, (byte)GetWinner());
|
||||
stmt.AddValue(2, GetUniqueBracketId());
|
||||
stmt.AddValue(3, (byte)GetTypeID(true));
|
||||
stmt.AddValue(3, (uint)GetTypeID());
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -702,18 +699,23 @@ namespace Game.BattleGrounds
|
||||
// Reward winner team
|
||||
if (team == winner)
|
||||
{
|
||||
if (IsRandom() || Global.BattlegroundMgr.IsBGWeekend(GetTypeID()))
|
||||
BattlegroundPlayer bgPlayer = GetBattlegroundPlayerData(player.GetGUID());
|
||||
if (bgPlayer != null)
|
||||
{
|
||||
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(winnerKills));
|
||||
if (!player.GetRandomWinner())
|
||||
if (Global.BattlegroundMgr.IsRandomBattleground((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId)
|
||||
|| Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId))
|
||||
{
|
||||
player.SetRandomWinner(true);
|
||||
// TODO: win honor xp
|
||||
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(winnerKills));
|
||||
if (!player.GetRandomWinner())
|
||||
{
|
||||
player.SetRandomWinner(true);
|
||||
// TODO: win honor xp
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: loss honor xp
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: lose honor xp
|
||||
}
|
||||
|
||||
player.UpdateCriteria(CriteriaType.WinBattleground, player.GetMapId());
|
||||
@@ -731,8 +733,13 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsRandom() || Global.BattlegroundMgr.IsBGWeekend(GetTypeID()))
|
||||
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(loserKills));
|
||||
BattlegroundPlayer bgPlayer = GetBattlegroundPlayerData(player.GetGUID());
|
||||
if (bgPlayer != null)
|
||||
{
|
||||
if (Global.BattlegroundMgr.IsRandomBattleground((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId)
|
||||
|| Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId))
|
||||
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(loserKills));
|
||||
}
|
||||
}
|
||||
|
||||
player.ResetAllPowers();
|
||||
@@ -770,8 +777,10 @@ namespace Game.BattleGrounds
|
||||
bool participant = false;
|
||||
// Remove from lists/maps
|
||||
var bgPlayer = m_Players.LookupByKey(guid);
|
||||
BattlegroundQueueTypeId? bgQueueTypeId = null;
|
||||
if (bgPlayer != null)
|
||||
{
|
||||
bgQueueTypeId = bgPlayer.queueTypeId;
|
||||
UpdatePlayersCountByTeam(team, true); // -1 player
|
||||
m_Players.Remove(guid);
|
||||
// check if the player was a participant of the match, or only entered through gm command (goname)
|
||||
@@ -811,8 +820,6 @@ namespace Game.BattleGrounds
|
||||
|
||||
RemovePlayer(player, guid, team); // BG subclass specific code
|
||||
|
||||
BattlegroundQueueTypeId bgQueueTypeId = GetQueueId();
|
||||
|
||||
if (participant) // if the player was a match participant, remove auras, calc rating, update queue
|
||||
{
|
||||
if (player)
|
||||
@@ -826,15 +833,16 @@ namespace Game.BattleGrounds
|
||||
player.RemovePet(null, PetSaveMode.NotInSlot);
|
||||
player.ResummonPetTemporaryUnSummonedIfAny();
|
||||
}
|
||||
if (SendPacket)
|
||||
if (SendPacket && bgQueueTypeId.HasValue)
|
||||
{
|
||||
BattlefieldStatusNone battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNone(out battlefieldStatus, player, player.GetBattlegroundQueueIndex(bgQueueTypeId), player.GetBattlegroundQueueJoinTime(bgQueueTypeId));
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNone(out battlefieldStatus, player, player.GetBattlegroundQueueIndex(bgQueueTypeId.Value), player.GetBattlegroundQueueJoinTime(bgQueueTypeId.Value));
|
||||
player.SendPacket(battlefieldStatus);
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (bgQueueTypeId.HasValue)
|
||||
player.RemoveBattlegroundQueueId(bgQueueTypeId.Value);
|
||||
}
|
||||
|
||||
// remove from raid group if player is member
|
||||
@@ -846,11 +854,11 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
DecreaseInvitedCount(team);
|
||||
//we should update Battleground queue, but only if bg isn't ending
|
||||
if (IsBattleground() && GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
if (IsBattleground() && GetStatus() < BattlegroundStatus.WaitLeave && bgQueueTypeId.HasValue)
|
||||
{
|
||||
// a player has left the Battleground, so there are free slots . add to queue
|
||||
AddToBGFreeSlotQueue();
|
||||
Global.BattlegroundMgr.ScheduleQueueUpdate(0, bgQueueTypeId, GetBracketId());
|
||||
Global.BattlegroundMgr.ScheduleQueueUpdate(0, bgQueueTypeId.Value, GetBracketId());
|
||||
}
|
||||
// Let others know
|
||||
BattlegroundPlayerLeft playerLeft = new();
|
||||
@@ -922,7 +930,7 @@ namespace Game.BattleGrounds
|
||||
player.TeleportTo(loc.Loc);
|
||||
}
|
||||
|
||||
public virtual void AddPlayer(Player player)
|
||||
public virtual void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
// remove afk from player
|
||||
if (player.IsAFK())
|
||||
@@ -936,7 +944,8 @@ namespace Game.BattleGrounds
|
||||
BattlegroundPlayer bp = new();
|
||||
bp.OfflineRemoveTime = 0;
|
||||
bp.Team = team;
|
||||
bp.Mercenary = player.IsMercenaryForBattlegroundQueueType(GetQueueId());
|
||||
bp.Mercenary = player.IsMercenaryForBattlegroundQueueType(queueId);
|
||||
bp.queueTypeId = queueId;
|
||||
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
// Add to list/maps
|
||||
@@ -975,8 +984,9 @@ namespace Game.BattleGrounds
|
||||
pvpMatchInitialize.Duration = (int)(GetElapsedTime() - (int)BattlegroundStartTimeIntervals.Delay2m) / Time.InMilliseconds;
|
||||
pvpMatchInitialize.StartTime = GameTime.GetGameTime() - pvpMatchInitialize.Duration;
|
||||
}
|
||||
|
||||
pvpMatchInitialize.ArenaFaction = (byte)(player.GetBGTeam() == Team.Horde ? PvPTeamId.Horde : PvPTeamId.Alliance);
|
||||
pvpMatchInitialize.BattlemasterListID = (uint)GetTypeID();
|
||||
pvpMatchInitialize.BattlemasterListID = queueId.BattlemasterListId;
|
||||
pvpMatchInitialize.Registered = false;
|
||||
pvpMatchInitialize.AffectsRating = IsRated();
|
||||
|
||||
@@ -1118,7 +1128,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
if (!m_InBGFreeSlotQueue && IsBattleground())
|
||||
{
|
||||
Global.BattlegroundMgr.AddToBGFreeSlotQueue(GetQueueId(), this);
|
||||
Global.BattlegroundMgr.AddToBGFreeSlotQueue(this);
|
||||
m_InBGFreeSlotQueue = true;
|
||||
}
|
||||
}
|
||||
@@ -1128,7 +1138,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
if (m_InBGFreeSlotQueue)
|
||||
{
|
||||
Global.BattlegroundMgr.RemoveFromBGFreeSlotQueue(GetQueueId(), m_InstanceID);
|
||||
Global.BattlegroundMgr.RemoveFromBGFreeSlotQueue(GetMapId(), m_InstanceID);
|
||||
m_InBGFreeSlotQueue = false;
|
||||
}
|
||||
}
|
||||
@@ -1647,11 +1657,6 @@ namespace Game.BattleGrounds
|
||||
return count;
|
||||
}
|
||||
|
||||
public void SetHoliday(bool is_holiday)
|
||||
{
|
||||
m_HonorMode = is_holiday ? BGHonorMode.Holiday : BGHonorMode.Normal;
|
||||
}
|
||||
|
||||
int GetObjectType(ObjectGuid guid)
|
||||
{
|
||||
for (int i = 0; i < BgObjects.Length; ++i)
|
||||
@@ -1724,9 +1729,9 @@ namespace Game.BattleGrounds
|
||||
return _battlegroundTemplate.BattlemasterEntry.Name[Global.WorldMgr.GetDefaultDbcLocale()];
|
||||
}
|
||||
|
||||
public BattlegroundTypeId GetTypeID(bool getRandom = false)
|
||||
public BattlegroundTypeId GetTypeID()
|
||||
{
|
||||
return getRandom ? m_RandomTypeID : _battlegroundTemplate.Id;
|
||||
return _battlegroundTemplate.Id;
|
||||
}
|
||||
|
||||
public BattlegroundBracketId GetBracketId()
|
||||
@@ -1790,12 +1795,16 @@ namespace Game.BattleGrounds
|
||||
return _battlegroundTemplate.GetMinPlayersPerTeam();
|
||||
}
|
||||
|
||||
public BattlegroundPlayer GetBattlegroundPlayerData(ObjectGuid playerGuid)
|
||||
{
|
||||
return m_Players.LookupByKey(playerGuid);
|
||||
}
|
||||
|
||||
public virtual void StartingEventCloseDoors() { }
|
||||
public virtual void StartingEventOpenDoors() { }
|
||||
|
||||
public virtual void DestroyGate(Player player, GameObject go) { }
|
||||
|
||||
public BattlegroundQueueTypeId GetQueueId() { return m_queueId; }
|
||||
public uint GetInstanceID() { return m_InstanceID; }
|
||||
public BattlegroundStatus GetStatus() { return m_Status; }
|
||||
public uint GetClientInstanceID() { return m_ClientInstanceID; }
|
||||
@@ -1805,10 +1814,7 @@ namespace Game.BattleGrounds
|
||||
int GetStartDelayTime() { return m_StartDelayTime; }
|
||||
public ArenaTypes GetArenaType() { return m_ArenaType; }
|
||||
PvPTeamId GetWinner() { return _winnerTeamId; }
|
||||
public bool IsRandom() { return m_IsRandom; }
|
||||
|
||||
public void SetQueueId(BattlegroundQueueTypeId queueId) { m_queueId = queueId; }
|
||||
public void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; }
|
||||
//here we can count minlevel and maxlevel for players
|
||||
public void SetInstanceID(uint InstanceID) { m_InstanceID = InstanceID; }
|
||||
public void SetStatus(BattlegroundStatus Status) { m_Status = Status; }
|
||||
@@ -1837,7 +1843,6 @@ namespace Game.BattleGrounds
|
||||
++m_InvitedHorde;
|
||||
}
|
||||
|
||||
public void SetRandom(bool isRandom) { m_IsRandom = isRandom; }
|
||||
uint GetInvitedCount(Team team) { return (team == Team.Alliance) ? m_InvitedAlliance : m_InvitedHorde; }
|
||||
|
||||
public bool IsRated() { return m_IsRated; }
|
||||
@@ -1927,9 +1932,6 @@ namespace Game.BattleGrounds
|
||||
// this must be filled inructors!
|
||||
public uint[] StartMessageIds = new uint[4];
|
||||
|
||||
bool m_IsRandom;
|
||||
|
||||
public BGHonorMode m_HonorMode;
|
||||
public uint[] m_TeamScores = new uint[SharedConst.PvpTeamsCount];
|
||||
|
||||
protected ObjectGuid[] BgObjects;// = new Dictionary<int, ObjectGuid>();
|
||||
@@ -1938,8 +1940,6 @@ namespace Game.BattleGrounds
|
||||
public uint[] Buff_Entries = { BattlegroundConst.SpeedBuff, BattlegroundConst.RegenBuff, BattlegroundConst.BerserkerBuff };
|
||||
|
||||
// Battleground
|
||||
BattlegroundQueueTypeId m_queueId;
|
||||
BattlegroundTypeId m_RandomTypeID;
|
||||
uint m_InstanceID; // Battleground Instance's GUID!
|
||||
BattlegroundStatus m_Status;
|
||||
uint m_ClientInstanceID; // the instance-id which is sent to the client and without any other internal use
|
||||
@@ -1993,5 +1993,6 @@ namespace Game.BattleGrounds
|
||||
public long OfflineRemoveTime; // for tracking and removing offline players from queue after 5 Time.Minutes
|
||||
public Team Team; // Player's team
|
||||
public bool Mercenary;
|
||||
public BattlegroundQueueTypeId queueTypeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
}
|
||||
|
||||
void BuildBattlegroundStatusHeader(BattlefieldStatusHeader header, Battleground bg, Player player, uint ticketId, uint joinTime, BattlegroundQueueTypeId queueId, ArenaTypes arenaType)
|
||||
void BuildBattlegroundStatusHeader(BattlefieldStatusHeader header, Player player, uint ticketId, uint joinTime, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
header.Ticket = new RideTicket();
|
||||
header.Ticket.RequesterGuid = player.GetGUID();
|
||||
@@ -113,11 +113,11 @@ namespace Game.BattleGrounds
|
||||
header.Ticket.Type = RideType.Battlegrounds;
|
||||
header.Ticket.Time = (int)joinTime;
|
||||
header.QueueID.Add(queueId.GetPacked());
|
||||
header.RangeMin = (byte)bg.GetMinLevel();
|
||||
header.RangeMax = (byte)bg.GetMaxLevel();
|
||||
header.TeamSize = (byte)(bg.IsArena() ? arenaType : 0);
|
||||
header.InstanceID = bg.GetClientInstanceID();
|
||||
header.RegisteredMatch = bg.IsRated();
|
||||
header.RangeMin = 0; // seems to always be 0
|
||||
header.RangeMax = SharedConst.DefaultMaxLevel; // alwyas max level of current expansion. Might be limited to account
|
||||
header.TeamSize = queueId.TeamSize;
|
||||
header.InstanceID = 0; // seems to always be 0
|
||||
header.RegisteredMatch = queueId.Rated;
|
||||
header.TournamentRules = false;
|
||||
}
|
||||
|
||||
@@ -130,19 +130,19 @@ namespace Game.BattleGrounds
|
||||
battlefieldStatus.Ticket.Time = (int)joinTime;
|
||||
}
|
||||
|
||||
public void BuildBattlegroundStatusNeedConfirmation(out BattlefieldStatusNeedConfirmation battlefieldStatus, Battleground bg, Player player, uint ticketId, uint joinTime, uint timeout, ArenaTypes arenaType)
|
||||
public void BuildBattlegroundStatusNeedConfirmation(out BattlefieldStatusNeedConfirmation battlefieldStatus, Battleground bg, Player player, uint ticketId, uint joinTime, uint timeout, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
battlefieldStatus = new BattlefieldStatusNeedConfirmation();
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, bg, player, ticketId, joinTime, bg.GetQueueId(), arenaType);
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, player, ticketId, joinTime, queueId);
|
||||
battlefieldStatus.Mapid = bg.GetMapId();
|
||||
battlefieldStatus.Timeout = timeout;
|
||||
battlefieldStatus.Role = 0;
|
||||
}
|
||||
|
||||
public void BuildBattlegroundStatusActive(out BattlefieldStatusActive battlefieldStatus, Battleground bg, Player player, uint ticketId, uint joinTime, ArenaTypes arenaType)
|
||||
public void BuildBattlegroundStatusActive(out BattlefieldStatusActive battlefieldStatus, Battleground bg, Player player, uint ticketId, uint joinTime, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
battlefieldStatus = new BattlefieldStatusActive();
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, bg, player, ticketId, joinTime, bg.GetQueueId(), arenaType);
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, player, ticketId, joinTime, queueId);
|
||||
battlefieldStatus.ShutdownTimer = bg.GetRemainingTime();
|
||||
battlefieldStatus.ArenaFaction = (byte)(player.GetBGTeam() == Team.Horde ? TeamId.Horde : TeamId.Alliance);
|
||||
battlefieldStatus.LeftEarly = false;
|
||||
@@ -150,10 +150,10 @@ namespace Game.BattleGrounds
|
||||
battlefieldStatus.Mapid = bg.GetMapId();
|
||||
}
|
||||
|
||||
public void BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatus, Battleground bg, Player player, uint ticketId, uint joinTime, BattlegroundQueueTypeId queueId, uint avgWaitTime, ArenaTypes arenaType, bool asGroup)
|
||||
public void BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatus, Player player, uint ticketId, uint joinTime, BattlegroundQueueTypeId queueId, uint avgWaitTime, bool asGroup)
|
||||
{
|
||||
battlefieldStatus = new BattlefieldStatusQueued();
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, bg, player, ticketId, joinTime, queueId, arenaType);
|
||||
BuildBattlegroundStatusHeader(battlefieldStatus.Hdr, player, ticketId, joinTime, queueId);
|
||||
battlefieldStatus.AverageWaitTime = avgWaitTime;
|
||||
battlefieldStatus.AsGroup = asGroup;
|
||||
battlefieldStatus.SuspendedQueue = false;
|
||||
@@ -179,7 +179,7 @@ namespace Game.BattleGrounds
|
||||
if (instanceId == 0)
|
||||
return null;
|
||||
|
||||
if (bgTypeId != BattlegroundTypeId.None || bgTypeId == BattlegroundTypeId.RB || bgTypeId == BattlegroundTypeId.RandomEpic)
|
||||
if (bgTypeId != BattlegroundTypeId.None || IsRandomBattleground(bgTypeId))
|
||||
{
|
||||
var data = bgDataStore.LookupByKey(bgTypeId);
|
||||
return data.m_Battlegrounds.LookupByKey(instanceId);
|
||||
@@ -196,14 +196,6 @@ namespace Game.BattleGrounds
|
||||
return null;
|
||||
}
|
||||
|
||||
public Battleground GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
if (bgDataStore.ContainsKey(bgTypeId))
|
||||
return bgDataStore[bgTypeId].Template;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
uint CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
||||
{
|
||||
if (IsArenaType(bgTypeId))
|
||||
@@ -230,115 +222,92 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
|
||||
// create a new Battleground that will really be used to play
|
||||
public Battleground CreateNewBattleground(BattlegroundQueueTypeId queueId, PvpDifficultyRecord bracketEntry)
|
||||
public Battleground CreateNewBattleground(BattlegroundQueueTypeId queueId, BattlegroundBracketId bracketId)
|
||||
{
|
||||
BattlegroundTypeId bgTypeId = GetRandomBG((BattlegroundTypeId)queueId.BattlemasterListId);
|
||||
|
||||
// get the template BG
|
||||
Battleground bg_template = GetBattlegroundTemplate(bgTypeId);
|
||||
BattlegroundTemplate bg_template = GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (bg_template == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground: CreateNewBattleground - bg template not found for {0}", bgTypeId);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground: CreateNewBattleground - bg template not found for {bgTypeId}");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (bgTypeId == BattlegroundTypeId.RB || bgTypeId == BattlegroundTypeId.AA || bgTypeId == BattlegroundTypeId.RandomEpic)
|
||||
return null;
|
||||
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketById((uint)bg_template.BattlemasterEntry.MapId[0], bracketId);
|
||||
if (bracketEntry == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"Battleground: CreateNewBattleground: bg bracket entry not found for map {bg_template.BattlemasterEntry.MapId[0]} bracket id {bracketId}");
|
||||
return null;
|
||||
}
|
||||
|
||||
Battleground bg = null;
|
||||
// create a copy of the BG template
|
||||
Battleground bg = bg_template.GetCopy();
|
||||
switch (bgTypeId)
|
||||
{
|
||||
case BattlegroundTypeId.AV:
|
||||
bg = new BgAlteracValley(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.WS:
|
||||
bg = new BgWarsongGluch(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.AB:
|
||||
case BattlegroundTypeId.DomAb:
|
||||
bg = new BgArathiBasin(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.NA:
|
||||
bg = new BgNagrandArena(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.BE:
|
||||
bg = new BgBladesEdgeArena(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.EY:
|
||||
bg = new BgEyeofStorm(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.RL:
|
||||
bg = new BgRuinsOfLordaernon(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.SA:
|
||||
bg = new BgStrandOfAncients(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.DS:
|
||||
bg = new BgDalaranSewers(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.RV:
|
||||
bg = new BgTheRingOfValor(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.IC:
|
||||
bg = new BgIsleofConquest(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.TP:
|
||||
bg = new BgTwinPeaks(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.BFG:
|
||||
bg = new BgBattleforGilneas(bg_template);
|
||||
break;
|
||||
case BattlegroundTypeId.RB:
|
||||
case BattlegroundTypeId.AA:
|
||||
case BattlegroundTypeId.RandomEpic:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
bool isRandom = bgTypeId != (BattlegroundTypeId)queueId.BattlemasterListId && !bg.IsArena();
|
||||
|
||||
bg.SetQueueId(queueId);
|
||||
bg.SetBracket(bracketEntry);
|
||||
bg.SetInstanceID(Global.MapMgr.GenerateInstanceId());
|
||||
bg.SetClientInstanceID(CreateClientVisibleInstanceId((BattlegroundTypeId)queueId.BattlemasterListId, bracketEntry.GetBracketId()));
|
||||
bg.Reset(); // reset the new bg (set status to status_wait_queue from status_none)
|
||||
// reset the new bg (set status to status_wait_queue from status_none)
|
||||
// this shouldn't be needed anymore as a new Battleground instance is created each time. But some bg sub classes still depend on it.
|
||||
bg.Reset();
|
||||
bg.SetStatus(BattlegroundStatus.WaitJoin); // start the joining of the bg
|
||||
bg.SetArenaType((ArenaTypes)queueId.TeamSize);
|
||||
bg.SetRandomTypeID(bgTypeId);
|
||||
bg.SetRated(queueId.Rated);
|
||||
bg.SetRandom(isRandom);
|
||||
|
||||
return bg;
|
||||
}
|
||||
|
||||
// used to create the BG templates
|
||||
bool CreateBattleground(BattlegroundTemplate bgTemplate)
|
||||
{
|
||||
Battleground bg = GetBattlegroundTemplate(bgTemplate.Id);
|
||||
if (!bg)
|
||||
{
|
||||
// Create the BG
|
||||
switch (bgTemplate.Id)
|
||||
{
|
||||
//case BattlegroundTypeId.AV:
|
||||
// bg = new BattlegroundAV(bgTemplate);
|
||||
//break;
|
||||
case BattlegroundTypeId.WS:
|
||||
bg = new BgWarsongGluch(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.AB:
|
||||
case BattlegroundTypeId.DomAb:
|
||||
bg = new BgArathiBasin(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.NA:
|
||||
bg = new NagrandArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.BE:
|
||||
bg = new BladesEdgeArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.EY:
|
||||
bg = new BgEyeofStorm(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RL:
|
||||
bg = new RuinsofLordaeronArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.SA:
|
||||
bg = new BgStrandOfAncients(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.DS:
|
||||
bg = new DalaranSewersArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RV:
|
||||
bg = new RingofValorArena(bgTemplate);
|
||||
break;
|
||||
//case BattlegroundTypeId.IC:
|
||||
//bg = new BattlegroundIC(bgTemplate);
|
||||
//break;
|
||||
case BattlegroundTypeId.AA:
|
||||
bg = new Battleground(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RB:
|
||||
bg = new Battleground(bgTemplate);
|
||||
bg.SetRandom(true);
|
||||
break;
|
||||
/*
|
||||
case BattlegroundTypeId.TP:
|
||||
bg = new BattlegroundTP(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.BFG:
|
||||
bg = new BattlegroundBFG(bgTemplate);
|
||||
break;
|
||||
*/
|
||||
case BattlegroundTypeId.RandomEpic:
|
||||
bg = new Battleground(bgTemplate);
|
||||
bg.SetRandom(true);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bgDataStore.ContainsKey(bg.GetTypeID()))
|
||||
bgDataStore[bg.GetTypeID()] = new BattlegroundData();
|
||||
|
||||
bgDataStore[bg.GetTypeID()].Template = bg;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadBattlegroundTemplates()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
@@ -375,7 +344,7 @@ namespace Game.BattleGrounds
|
||||
bgTemplate.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(5));
|
||||
bgTemplate.BattlemasterEntry = bl;
|
||||
|
||||
if (bgTemplate.Id != BattlegroundTypeId.AA && bgTemplate.Id != BattlegroundTypeId.RB && bgTemplate.Id != BattlegroundTypeId.RandomEpic)
|
||||
if (bgTemplate.Id != BattlegroundTypeId.AA && !IsRandomBattleground(bgTemplate.Id))
|
||||
{
|
||||
uint startId = result.Read<uint>(1);
|
||||
WorldSafeLocsEntry start = Global.ObjectMgr.GetWorldSafeLoc(startId);
|
||||
@@ -402,12 +371,6 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
}
|
||||
|
||||
if (!CreateBattleground(bgTemplate))
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"Could not create battleground template class ({bgTemplate.Id})!");
|
||||
continue;
|
||||
}
|
||||
|
||||
_battlegroundTemplates[bgTypeId] = bgTemplate;
|
||||
|
||||
if (bgTemplate.BattlemasterEntry.MapId[1] == -1) // in this case we have only one mapId
|
||||
@@ -458,6 +421,11 @@ namespace Game.BattleGrounds
|
||||
|| bgTypeId == BattlegroundTypeId.DS || bgTypeId == BattlegroundTypeId.RV || bgTypeId == BattlegroundTypeId.RL;
|
||||
}
|
||||
|
||||
public bool IsRandomBattleground(BattlegroundTypeId battlemasterListId)
|
||||
{
|
||||
return battlemasterListId == BattlegroundTypeId.RB || battlemasterListId == BattlegroundTypeId.RandomEpic;
|
||||
}
|
||||
|
||||
public BattlegroundQueueTypeId BGQueueTypeId(ushort battlemasterListId, BattlegroundQueueIdType type, bool rated, ArenaTypes teamSize)
|
||||
{
|
||||
return new BattlegroundQueueTypeId(battlemasterListId, (byte)type, rated, (byte)teamSize);
|
||||
@@ -475,23 +443,6 @@ namespace Game.BattleGrounds
|
||||
Global.WorldMgr.SendWorldText(m_ArenaTesting ? CypherStrings.DebugArenaOn : CypherStrings.DebugArenaOff);
|
||||
}
|
||||
|
||||
public void ResetHolidays()
|
||||
{
|
||||
for (var i = BattlegroundTypeId.AV; i < BattlegroundTypeId.Max; i++)
|
||||
{
|
||||
Battleground bg = GetBattlegroundTemplate(i);
|
||||
if (bg != null)
|
||||
bg.SetHoliday(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHolidayActive(uint battlegroundId)
|
||||
{
|
||||
Battleground bg = GetBattlegroundTemplate((BattlegroundTypeId)battlegroundId);
|
||||
if (bg != null)
|
||||
bg.SetHoliday(true);
|
||||
}
|
||||
|
||||
public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
|
||||
{
|
||||
BattlemasterListRecord battlemasterList = CliDB.BattlemasterListStorage.LookupByKey(bgQueueTypeId.BattlemasterListId);
|
||||
@@ -521,9 +472,9 @@ namespace Game.BattleGrounds
|
||||
case BattlegroundQueueIdType.ArenaSkirmish:
|
||||
if (battlemasterList.InstanceType != (int)MapTypes.Arena)
|
||||
return false;
|
||||
if (bgQueueTypeId.Rated)
|
||||
if (!bgQueueTypeId.Rated)
|
||||
return false;
|
||||
if (bgQueueTypeId.TeamSize != 0)
|
||||
if (bgQueueTypeId.TeamSize != (int)ArenaTypes.Team3v3)
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
@@ -700,19 +651,19 @@ namespace Game.BattleGrounds
|
||||
return BattlegroundTypeId.None;
|
||||
}
|
||||
|
||||
public List<Battleground> GetBGFreeSlotQueueStore(BattlegroundQueueTypeId bgTypeId)
|
||||
public List<Battleground> GetBGFreeSlotQueueStore(uint mapId)
|
||||
{
|
||||
return m_BGFreeSlotQueue[bgTypeId];
|
||||
return m_BGFreeSlotQueue[mapId];
|
||||
}
|
||||
|
||||
public void AddToBGFreeSlotQueue(BattlegroundQueueTypeId bgTypeId, Battleground bg)
|
||||
public void AddToBGFreeSlotQueue(Battleground bg)
|
||||
{
|
||||
m_BGFreeSlotQueue.Add(bgTypeId, bg);
|
||||
m_BGFreeSlotQueue.Add(bg.GetMapId(), bg);
|
||||
}
|
||||
|
||||
public void RemoveFromBGFreeSlotQueue(BattlegroundQueueTypeId bgTypeId, uint instanceId)
|
||||
public void RemoveFromBGFreeSlotQueue(uint mapId, uint instanceId)
|
||||
{
|
||||
var queues = m_BGFreeSlotQueue[bgTypeId];
|
||||
var queues = m_BGFreeSlotQueue[mapId];
|
||||
foreach (var bg in queues)
|
||||
{
|
||||
if (bg.GetInstanceID() == instanceId)
|
||||
@@ -750,7 +701,7 @@ namespace Game.BattleGrounds
|
||||
return mBattleMastersMap.LookupByKey(entry);
|
||||
}
|
||||
|
||||
BattlegroundTemplate GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
|
||||
public BattlegroundTemplate GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
|
||||
{
|
||||
return _battlegroundTemplates.LookupByKey(id);
|
||||
}
|
||||
@@ -762,7 +713,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
Dictionary<BattlegroundTypeId, BattlegroundData> bgDataStore = new();
|
||||
Dictionary<BattlegroundQueueTypeId, BattlegroundQueue> m_BattlegroundQueues = new();
|
||||
MultiMap<BattlegroundQueueTypeId, Battleground> m_BGFreeSlotQueue = new();
|
||||
MultiMap<uint, Battleground> m_BGFreeSlotQueue = new();
|
||||
Dictionary<uint, BattlegroundTypeId> mBattleMastersMap = new();
|
||||
Dictionary<BattlegroundTypeId, BattlegroundTemplate> _battlegroundTemplates = new();
|
||||
Dictionary<uint, BattlegroundTemplate> _battlegroundMapTemplates = new();
|
||||
|
||||
@@ -115,10 +115,9 @@ namespace Game.BattleGrounds
|
||||
//announce to world, this code needs mutex
|
||||
if (!m_queueId.Rated && !isPremade && WorldConfig.GetBoolValue(WorldCfg.BattlegroundQueueAnnouncerEnable))
|
||||
{
|
||||
Battleground bg = Global.BattlegroundMgr.GetBattlegroundTemplate((BattlegroundTypeId)m_queueId.BattlemasterListId);
|
||||
if (bg)
|
||||
BattlegroundTemplate bg = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId((BattlegroundTypeId)m_queueId.BattlemasterListId);
|
||||
if (bg != null)
|
||||
{
|
||||
string bgName = bg.GetName();
|
||||
uint MinPlayers = bg.GetMinPlayersPerTeam();
|
||||
uint qHorde = 0;
|
||||
uint qAlliance = 0;
|
||||
@@ -135,18 +134,17 @@ namespace Game.BattleGrounds
|
||||
// Show queue status to player only (when joining queue)
|
||||
if (WorldConfig.GetBoolValue(WorldCfg.BattlegroundQueueAnnouncerPlayeronly))
|
||||
{
|
||||
leader.SendSysMessage(CypherStrings.BgQueueAnnounceSelf, bgName, q_min_level, q_max_level,
|
||||
leader.SendSysMessage(CypherStrings.BgQueueAnnounceSelf, bg.BattlemasterEntry.Name[Global.WorldMgr.GetDefaultDbcLocale()], q_min_level, q_max_level,
|
||||
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : 0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : 0);
|
||||
}
|
||||
// System message
|
||||
else
|
||||
{
|
||||
Global.WorldMgr.SendWorldText(CypherStrings.BgQueueAnnounceWorld, bgName, q_min_level, q_max_level,
|
||||
Global.WorldMgr.SendWorldText(CypherStrings.BgQueueAnnounceWorld, bg.BattlemasterEntry.Name[Global.WorldMgr.GetDefaultDbcLocale()], q_min_level, q_max_level,
|
||||
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : 0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//release mutex
|
||||
}
|
||||
|
||||
return ginfo;
|
||||
@@ -364,8 +362,8 @@ namespace Game.BattleGrounds
|
||||
// not yet invited
|
||||
// set invitation
|
||||
ginfo.IsInvitedToBGInstanceGUID = bg.GetInstanceID();
|
||||
BattlegroundTypeId bgTypeId = bg.GetTypeID();
|
||||
BattlegroundQueueTypeId bgQueueTypeId = bg.GetQueueId();
|
||||
BattlegroundTypeId bgTypeId = (BattlegroundTypeId)m_queueId.BattlemasterListId;
|
||||
BattlegroundQueueTypeId bgQueueTypeId = m_queueId;
|
||||
BattlegroundBracketId bracket_id = bg.GetBracketId();
|
||||
|
||||
// set ArenaTeamId for rated matches
|
||||
@@ -392,7 +390,7 @@ namespace Game.BattleGrounds
|
||||
player.SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo.IsInvitedToBGInstanceGUID);
|
||||
|
||||
// create remind invite events
|
||||
BGQueueInviteEvent inviteEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, (ArenaTypes)m_queueId.TeamSize, ginfo.RemoveInviteTime);
|
||||
BGQueueInviteEvent inviteEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, ginfo.RemoveInviteTime, m_queueId);
|
||||
m_events.AddEvent(inviteEvent, m_events.CalculateTime(TimeSpan.FromMilliseconds(BattlegroundConst.InvitationRemindTime)));
|
||||
// create automatic remove events
|
||||
BGQueueRemoveEvent removeEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo.RemoveInviteTime);
|
||||
@@ -401,10 +399,10 @@ namespace Game.BattleGrounds
|
||||
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
|
||||
|
||||
Log.outDebug(LogFilter.Battleground, "Battleground: invited player {0} ({1}) to BG instance {2} queueindex {3} bgtype {4}",
|
||||
player.GetName(), player.GetGUID().ToString(), bg.GetInstanceID(), queueSlot, bg.GetTypeID());
|
||||
player.GetName(), player.GetGUID().ToString(), bg.GetInstanceID(), queueSlot, m_queueId.BattlemasterListId);
|
||||
|
||||
BattlefieldStatusNeedConfirmation battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, player, queueSlot, player.GetBattlegroundQueueJoinTime(bgQueueTypeId), BattlegroundConst.InviteAcceptWaitTime, (ArenaTypes)m_queueId.TeamSize);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, player, queueSlot, player.GetBattlegroundQueueJoinTime(bgQueueTypeId), BattlegroundConst.InviteAcceptWaitTime, bgQueueTypeId);
|
||||
player.SendPacket(battlefieldStatus);
|
||||
}
|
||||
return true;
|
||||
@@ -589,15 +587,15 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
|
||||
// this method tries to create Battleground or arena with MinPlayersPerTeam against MinPlayersPerTeam
|
||||
bool CheckNormalMatch(Battleground bg_template, BattlegroundBracketId bracket_id, uint minPlayers, uint maxPlayers)
|
||||
bool CheckNormalMatch(BattlegroundBracketId bracketId, uint minPlayers, uint maxPlayers)
|
||||
{
|
||||
int[] teamIndex = new int[SharedConst.PvpTeamsCount];
|
||||
for (uint i = 0; i < SharedConst.PvpTeamsCount; i++)
|
||||
{
|
||||
teamIndex[i] = 0;
|
||||
for (; teamIndex[i] != m_QueuedGroups[(int)bracket_id][BattlegroundConst.BgQueueNormalAlliance + i].Count; ++teamIndex[i])
|
||||
for (; teamIndex[i] != m_QueuedGroups[(int)bracketId][BattlegroundConst.BgQueueNormalAlliance + i].Count; ++teamIndex[i])
|
||||
{
|
||||
var groupQueueInfo = m_QueuedGroups[(int)bracket_id][BattlegroundConst.BgQueueNormalAlliance + i][teamIndex[i]];
|
||||
var groupQueueInfo = m_QueuedGroups[(int)bracketId][BattlegroundConst.BgQueueNormalAlliance + i][teamIndex[i]];
|
||||
if (groupQueueInfo.IsInvitedToBGInstanceGUID == 0)
|
||||
{
|
||||
m_SelectionPools[i].AddGroup(groupQueueInfo, maxPlayers);
|
||||
@@ -616,9 +614,9 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
//we will try to invite more groups to team with less players indexed by j
|
||||
++(teamIndex[j]); //this will not cause a crash, because for cycle above reached break;
|
||||
for (; teamIndex[j] != m_QueuedGroups[(int)bracket_id][BattlegroundConst.BgQueueNormalAlliance + j].Count; ++teamIndex[j])
|
||||
for (; teamIndex[j] != m_QueuedGroups[(int)bracketId][BattlegroundConst.BgQueueNormalAlliance + j].Count; ++teamIndex[j])
|
||||
{
|
||||
var groupQueueInfo = m_QueuedGroups[(int)bracket_id][BattlegroundConst.BgQueueNormalAlliance + j][teamIndex[j]];
|
||||
var groupQueueInfo = m_QueuedGroups[(int)bracketId][BattlegroundConst.BgQueueNormalAlliance + j][teamIndex[j]];
|
||||
if (groupQueueInfo.IsInvitedToBGInstanceGUID == 0)
|
||||
if (!m_SelectionPools[j].AddGroup(groupQueueInfo, m_SelectionPools[(j + 1) % SharedConst.PvpTeamsCount].GetPlayerCount()))
|
||||
break;
|
||||
@@ -725,48 +723,48 @@ namespace Game.BattleGrounds
|
||||
|
||||
// Battleground with free slot for player should be always in the beggining of the queue
|
||||
// maybe it would be better to create bgfreeslotqueue for each bracket_id
|
||||
var bgQueues = Global.BattlegroundMgr.GetBGFreeSlotQueueStore(m_queueId);
|
||||
foreach (var bg in bgQueues)
|
||||
{
|
||||
// DO NOT allow queue manager to invite new player to rated games
|
||||
if (!bg.IsRated() && bg.GetBracketId() == bracket_id &&
|
||||
bg.GetStatus() > BattlegroundStatus.WaitQueue && bg.GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
{
|
||||
// clear selection pools
|
||||
m_SelectionPools[TeamId.Alliance].Init();
|
||||
m_SelectionPools[TeamId.Horde].Init();
|
||||
|
||||
// call a function that does the job for us
|
||||
FillPlayersToBG(bg, bracket_id);
|
||||
|
||||
// now everything is set, invite players
|
||||
foreach (var queueInfo in m_SelectionPools[TeamId.Alliance].SelectedGroups)
|
||||
InviteGroupToBG(queueInfo, bg, queueInfo.Team);
|
||||
|
||||
foreach (var queueInfo in m_SelectionPools[TeamId.Horde].SelectedGroups)
|
||||
InviteGroupToBG(queueInfo, bg, queueInfo.Team);
|
||||
|
||||
if (!bg.HasFreeSlots())
|
||||
bg.RemoveFromBGFreeSlotQueue();
|
||||
}
|
||||
}
|
||||
|
||||
// finished iterating through the bgs with free slots, maybe we need to create a new bg
|
||||
|
||||
Battleground bg_template = Global.BattlegroundMgr.GetBattlegroundTemplate((BattlegroundTypeId)m_queueId.BattlemasterListId);
|
||||
if (!bg_template)
|
||||
BattlegroundTemplate bg_template = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId((BattlegroundTypeId)m_queueId.BattlemasterListId);
|
||||
if (bg_template == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"Battleground: Update: bg template not found for {m_queueId.BattlemasterListId}");
|
||||
return;
|
||||
}
|
||||
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketById(bg_template.GetMapId(), bracket_id);
|
||||
if (bracketEntry == null)
|
||||
// loop over queues for every map
|
||||
foreach (var mapId in bg_template.BattlemasterEntry.MapId)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground: Update: bg bracket entry not found for map {0} bracket id {1}", bg_template.GetMapId(), bracket_id);
|
||||
return;
|
||||
if (mapId == -1)
|
||||
break;
|
||||
|
||||
var bgQueues = Global.BattlegroundMgr.GetBGFreeSlotQueueStore((uint)mapId);
|
||||
foreach (var bg in bgQueues)
|
||||
{
|
||||
// DO NOT allow queue manager to invite new player to rated games
|
||||
if (!bg.IsRated() && bg.GetBracketId() == bracket_id &&
|
||||
bg.GetStatus() > BattlegroundStatus.WaitQueue && bg.GetStatus() < BattlegroundStatus.WaitLeave)
|
||||
{
|
||||
// clear selection pools
|
||||
m_SelectionPools[TeamId.Alliance].Init();
|
||||
m_SelectionPools[TeamId.Horde].Init();
|
||||
|
||||
// call a function that does the job for us
|
||||
FillPlayersToBG(bg, bracket_id);
|
||||
|
||||
// now everything is set, invite players
|
||||
foreach (var queueInfo in m_SelectionPools[TeamId.Alliance].SelectedGroups)
|
||||
InviteGroupToBG(queueInfo, bg, queueInfo.Team);
|
||||
|
||||
foreach (var queueInfo in m_SelectionPools[TeamId.Horde].SelectedGroups)
|
||||
InviteGroupToBG(queueInfo, bg, queueInfo.Team);
|
||||
|
||||
if (!bg.HasFreeSlots())
|
||||
bg.RemoveFromBGFreeSlotQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finished iterating through the bgs with free slots, maybe we need to create a new bg
|
||||
|
||||
// get the min. players per team, properly for larger arenas as well. (must have full teams for arena matches!)
|
||||
uint MinPlayersPerTeam = bg_template.GetMinPlayersPerTeam();
|
||||
uint MaxPlayersPerTeam = bg_template.GetMaxPlayersPerTeam();
|
||||
@@ -782,12 +780,12 @@ namespace Game.BattleGrounds
|
||||
m_SelectionPools[TeamId.Alliance].Init();
|
||||
m_SelectionPools[TeamId.Horde].Init();
|
||||
|
||||
if (bg_template.IsBattleground())
|
||||
if (!bg_template.IsArena())
|
||||
{
|
||||
if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam))
|
||||
{
|
||||
// create new Battleground
|
||||
Battleground bg2 = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracketEntry);
|
||||
Battleground bg2 = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracket_id);
|
||||
if (bg2 == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"BattlegroundQueue.Update - Cannot create Battleground: {m_queueId.BattlemasterListId}");
|
||||
@@ -809,11 +807,11 @@ namespace Game.BattleGrounds
|
||||
if (!m_queueId.Rated)
|
||||
{
|
||||
// if there are enough players in pools, start new Battleground or non rated arena
|
||||
if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
|
||||
if (CheckNormalMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
|
||||
|| (bg_template.IsArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
|
||||
{
|
||||
// we successfully created a pool
|
||||
Battleground bg2 = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracketEntry);
|
||||
Battleground bg2 = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracket_id);
|
||||
if (bg2 == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"BattlegroundQueue.Update - Cannot create Battleground: {m_queueId.BattlemasterListId}");
|
||||
@@ -912,7 +910,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
GroupQueueInfo aTeam = queueArray[TeamId.Alliance];
|
||||
GroupQueueInfo hTeam = queueArray[TeamId.Horde];
|
||||
Battleground arena = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracketEntry);
|
||||
Battleground arena = Global.BattlegroundMgr.CreateNewBattleground(m_queueId, bracket_id);
|
||||
if (!arena)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "BattlegroundQueue.Update couldn't create arena instance for rated arena match!");
|
||||
@@ -1145,13 +1143,13 @@ namespace Game.BattleGrounds
|
||||
/// </summary>
|
||||
class BGQueueInviteEvent : BasicEvent
|
||||
{
|
||||
public BGQueueInviteEvent(ObjectGuid plGuid, uint bgInstanceGUID, BattlegroundTypeId bgTypeId, ArenaTypes arenaType, uint removeTime)
|
||||
public BGQueueInviteEvent(ObjectGuid plGuid, uint bgInstanceGUID, BattlegroundTypeId bgTypeId, uint removeTime, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
m_PlayerGuid = plGuid;
|
||||
m_BgInstanceGUID = bgInstanceGUID;
|
||||
m_BgTypeId = bgTypeId;
|
||||
m_ArenaType = arenaType;
|
||||
m_RemoveTime = removeTime;
|
||||
m_QueueId = queueId;
|
||||
}
|
||||
|
||||
public override bool Execute(ulong e_time, uint p_time)
|
||||
@@ -1166,16 +1164,15 @@ namespace Game.BattleGrounds
|
||||
if (bg == null)
|
||||
return true;
|
||||
|
||||
BattlegroundQueueTypeId bgQueueTypeId = bg.GetQueueId();
|
||||
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
|
||||
uint queueSlot = player.GetBattlegroundQueueIndex(m_QueueId);
|
||||
if (queueSlot < SharedConst.PvpTeamsCount) // player is in queue or in Battleground
|
||||
{
|
||||
// check if player is invited to this bg
|
||||
BattlegroundQueue bgQueue = Global.BattlegroundMgr.GetBattlegroundQueue(bgQueueTypeId);
|
||||
BattlegroundQueue bgQueue = Global.BattlegroundMgr.GetBattlegroundQueue(m_QueueId);
|
||||
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
|
||||
{
|
||||
BattlefieldStatusNeedConfirmation battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, player, queueSlot, player.GetBattlegroundQueueJoinTime(bgQueueTypeId), BattlegroundConst.InviteAcceptWaitTime - BattlegroundConst.InvitationRemindTime, m_ArenaType);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, player, queueSlot, player.GetBattlegroundQueueJoinTime(m_QueueId), BattlegroundConst.InviteAcceptWaitTime - BattlegroundConst.InvitationRemindTime, m_QueueId);
|
||||
player.SendPacket(battlefieldStatus);
|
||||
}
|
||||
}
|
||||
@@ -1187,8 +1184,8 @@ namespace Game.BattleGrounds
|
||||
ObjectGuid m_PlayerGuid;
|
||||
uint m_BgInstanceGUID;
|
||||
BattlegroundTypeId m_BgTypeId;
|
||||
ArenaTypes m_ArenaType;
|
||||
uint m_RemoveTime;
|
||||
BattlegroundQueueTypeId m_QueueId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class AlteracValley
|
||||
class BgAlteracValley : Battleground
|
||||
{
|
||||
public BgAlteracValley(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,10 +208,10 @@ namespace Game.BattleGrounds.Zones
|
||||
TriggerGameEvent(EventStartBattle);
|
||||
}
|
||||
|
||||
public override void AddPlayer(Player player)
|
||||
public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
base.AddPlayer(player);
|
||||
base.AddPlayer(player, queueId);
|
||||
if (!isInBattleground)
|
||||
PlayerScores[player.GetGUID()] = new BattlegroundABScore(player.GetGUID(), player.GetBGTeam());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BattleforGilneas
|
||||
class BgBattleforGilneas : Battleground
|
||||
{
|
||||
public BgBattleforGilneas(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgBladesEdgeArena : Battleground
|
||||
{
|
||||
public BgBladesEdgeArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgDalaranSewers : Battleground
|
||||
{
|
||||
public BgDalaranSewers(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class DeepwindGorge
|
||||
class BgDeepwindGorge : Battleground
|
||||
{
|
||||
public BgDeepwindGorge(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Game.Entities;
|
||||
using Framework.Constants;
|
||||
using System.Collections.Generic;
|
||||
using Game.Entities;
|
||||
using Game.Networking.Packets;
|
||||
using Game.DataStorage;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
@@ -367,10 +352,10 @@ namespace Game.BattleGrounds.Zones
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddPlayer(Player player)
|
||||
public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
base.AddPlayer(player);
|
||||
base.AddPlayer(player, queueId);
|
||||
if (!isInBattleground)
|
||||
PlayerScores[player.GetGUID()] = new BgEyeOfStormScore(player.GetGUID(), player.GetBGTeam());
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class IsleofConquest
|
||||
class BgIsleofConquest : Battleground
|
||||
{
|
||||
public BgIsleofConquest(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
|
||||
public struct ICCreatures
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgNagrandArena : Battleground
|
||||
{
|
||||
public BgNagrandArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgRuinsOfLordaernon : Battleground
|
||||
{
|
||||
public BgRuinsOfLordaernon(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class SilvershardMines
|
||||
class BgSilvershardMines : Battleground
|
||||
{
|
||||
public BgSilvershardMines(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,10 +416,10 @@ namespace Game.BattleGrounds.Zones
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddPlayer(Player player)
|
||||
public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
base.AddPlayer(player);
|
||||
base.AddPlayer(player, queueId);
|
||||
if (!isInBattleground)
|
||||
PlayerScores[player.GetGUID()] = new BattlegroundSAScore(player.GetGUID(), player.GetBGTeam());
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class TempleofKotmogu
|
||||
class BgTempleofKotmogu : Battleground
|
||||
{
|
||||
public BgTempleofKotmogu(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgTheRingOfValor : Battleground
|
||||
{
|
||||
public BgTheRingOfValor(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class TwinPeaks
|
||||
class BgTwinPeaks : Battleground
|
||||
{
|
||||
public BgTwinPeaks(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,10 +184,10 @@ namespace Game.BattleGrounds.Zones
|
||||
TriggerGameEvent(8563);
|
||||
}
|
||||
|
||||
public override void AddPlayer(Player player)
|
||||
public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId)
|
||||
{
|
||||
bool isInBattleground = IsPlayerInBattleground(player.GetGUID());
|
||||
base.AddPlayer(player);
|
||||
base.AddPlayer(player, queueId);
|
||||
if (!isInBattleground)
|
||||
PlayerScores[player.GetGUID()] = new BattlegroundWGScore(player.GetGUID(), player.GetBGTeam());
|
||||
}
|
||||
@@ -320,7 +320,7 @@ namespace Game.BattleGrounds.Zones
|
||||
UpdateWorldState(WSGWorldStates.FlagStateHorde, 1);
|
||||
UpdateWorldState(WSGWorldStates.StateTimerActive, 0);
|
||||
|
||||
RewardHonorToTeam(Honor[(int)m_HonorMode][(int)WSGRewards.Win], winner);
|
||||
RewardHonorToTeam(Honor[Global.BattlegroundMgr.IsBGWeekend(BattlegroundTypeId.WS) ? 1 : 0][(int)WSGRewards.Win], winner);
|
||||
EndBattleground(winner);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Game.Chat
|
||||
[Command("areatrigger_teleport", RBACPermissions.CommandReloadAreatriggerTeleport, true)]
|
||||
static bool HandleReloadAreaTriggerTeleportCommand(CommandHandler handler)
|
||||
{
|
||||
Log.outInfo(LogFilter.Server, "Re-Loading AreaTrigger teleport definitions...");
|
||||
Log.outInfo(LogFilter.Server, "Re-Loading Area Trigger Teleports definitions...");
|
||||
Global.ObjectMgr.LoadAreaTriggerTeleports();
|
||||
handler.SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded.");
|
||||
return true;
|
||||
|
||||
@@ -2317,11 +2317,11 @@ namespace Game.Entities
|
||||
{
|
||||
case 179785: // Silverwing Flag
|
||||
case 179786: // Warsong Flag
|
||||
if (bg.GetTypeID(true) == BattlegroundTypeId.WS)
|
||||
if (bg.GetTypeID() == BattlegroundTypeId.WS)
|
||||
bg.EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
case 184142: // Netherstorm Flag
|
||||
if (bg.GetTypeID(true) == BattlegroundTypeId.EY)
|
||||
if (bg.GetTypeID() == BattlegroundTypeId.EY)
|
||||
bg.EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1606,14 +1606,15 @@ namespace Game.Entities
|
||||
return;
|
||||
|
||||
// Expecting only one row
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
// SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_Battleground_data WHERE guid = ?
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
// SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell, queueTypeId FROM character_Battleground_data WHERE guid = ?
|
||||
m_bgData.bgInstanceID = result.Read<uint>(0);
|
||||
m_bgData.bgTeam = result.Read<ushort>(1);
|
||||
m_bgData.joinPos = new WorldLocation(result.Read<ushort>(6), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), result.Read<float>(5));
|
||||
m_bgData.taxiPath[0] = result.Read<uint>(7);
|
||||
m_bgData.taxiPath[1] = result.Read<uint>(8);
|
||||
m_bgData.mountSpell = result.Read<uint>(9);
|
||||
m_bgData.queueId = BattlegroundQueueTypeId.FromPacked(result.Read<ulong>(10));
|
||||
}
|
||||
void _LoadPetStable(uint summonedPetNumber, SQLResult result)
|
||||
{
|
||||
@@ -2776,6 +2777,7 @@ namespace Game.Entities
|
||||
stmt.AddValue(8, m_bgData.taxiPath[0]);
|
||||
stmt.AddValue(9, m_bgData.taxiPath[1]);
|
||||
stmt.AddValue(10, m_bgData.mountSpell);
|
||||
stmt.AddValue(11, m_bgData.queueId.GetPacked());
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
@@ -3031,16 +3033,18 @@ namespace Game.Entities
|
||||
{
|
||||
map = currentBg.GetBgMap();
|
||||
|
||||
BattlegroundQueueTypeId bgQueueTypeId = currentBg.GetQueueId();
|
||||
AddBattlegroundQueueId(bgQueueTypeId);
|
||||
BattlegroundPlayer bgPlayer = currentBg.GetBattlegroundPlayerData(GetGUID());
|
||||
if (bgPlayer != null)
|
||||
{
|
||||
AddBattlegroundQueueId(bgPlayer.queueTypeId);
|
||||
m_bgData.bgTypeID = (BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId;
|
||||
|
||||
m_bgData.bgTypeID = currentBg.GetTypeID();
|
||||
//join player to Battlegroundgroup
|
||||
currentBg.EventPlayerLoggedIn(this);
|
||||
|
||||
//join player to Battlegroundgroup
|
||||
currentBg.EventPlayerLoggedIn(this);
|
||||
|
||||
SetInviteForBattlegroundQueueType(bgQueueTypeId, currentBg.GetInstanceID());
|
||||
SetMercenaryForBattlegroundQueueType(bgQueueTypeId, currentBg.IsPlayerMercenaryInBattleground(GetGUID()));
|
||||
SetInviteForBattlegroundQueueType(bgPlayer.queueTypeId, currentBg.GetInstanceID());
|
||||
SetMercenaryForBattlegroundQueueType(bgPlayer.queueTypeId, currentBg.IsPlayerMercenaryInBattleground(GetGUID()));
|
||||
}
|
||||
}
|
||||
// Bg was not found - go to Entry Point
|
||||
else
|
||||
@@ -3256,7 +3260,7 @@ namespace Game.Entities
|
||||
m_InstanceValid = false;
|
||||
|
||||
if (player_at_bg)
|
||||
map.ToBattlegroundMap().GetBG().AddPlayer(this);
|
||||
map.ToBattlegroundMap().GetBG().AddPlayer(this, m_bgData.queueId);
|
||||
|
||||
// randomize first save time in range [CONFIG_INTERVAL_SAVE] around [CONFIG_INTERVAL_SAVE]
|
||||
// this must help in case next save after mass player load after server startup
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Game.Entities
|
||||
|
||||
//PVP
|
||||
BgBattlegroundQueueID_Rec[] m_bgBattlegroundQueueID = new BgBattlegroundQueueID_Rec[SharedConst.MaxPlayerBGQueues];
|
||||
BGData m_bgData;
|
||||
public BGData m_bgData;
|
||||
bool m_IsBGRandomWinner;
|
||||
public PvPInfo pvpInfo;
|
||||
uint m_ArenaTeamIdInvited;
|
||||
@@ -583,6 +583,7 @@ namespace Game.Entities
|
||||
public uint[] taxiPath = new uint[2];
|
||||
|
||||
public WorldLocation joinPos; //< From where player entered BG
|
||||
public BattlegroundQueueTypeId queueId;
|
||||
|
||||
public void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
|
||||
public bool HasTaxiPath() { return taxiPath[0] != 0 && taxiPath[1] != 0; }
|
||||
|
||||
@@ -6174,7 +6174,7 @@ namespace Game.Entities
|
||||
Battleground bg = GetBattleground();
|
||||
if (bg != null)
|
||||
{
|
||||
if (bg.GetTypeID(true) == BattlegroundTypeId.AV)
|
||||
if (bg.GetTypeID() == BattlegroundTypeId.AV)
|
||||
bones.loot.FillLoot(1, LootStorage.Creature, this, true);
|
||||
}
|
||||
// For wintergrasp Quests
|
||||
|
||||
@@ -418,10 +418,11 @@ namespace Game.Entities
|
||||
return GetBattlegroundQueueIndex(bgQueueTypeId) < SharedConst.MaxPlayerBGQueues;
|
||||
}
|
||||
|
||||
public void SetBattlegroundId(uint val, BattlegroundTypeId bgTypeId)
|
||||
public void SetBattlegroundId(uint val, BattlegroundTypeId bgTypeId, BattlegroundQueueTypeId queueId = default)
|
||||
{
|
||||
m_bgData.bgInstanceID = val;
|
||||
m_bgData.bgTypeID = bgTypeId;
|
||||
m_bgData.queueId = queueId;
|
||||
}
|
||||
|
||||
public uint AddBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
@@ -615,12 +616,12 @@ namespace Game.Entities
|
||||
|
||||
public bool IsDeserter() { return HasAura(26013); }
|
||||
|
||||
public bool CanJoinToBattleground(Battleground bg)
|
||||
public bool CanJoinToBattleground(BattlegroundTemplate bg)
|
||||
{
|
||||
RBACPermissions perm = RBACPermissions.JoinNormalBg;
|
||||
if (bg.IsArena())
|
||||
perm = RBACPermissions.JoinArenas;
|
||||
else if (bg.IsRandom())
|
||||
else if (Global.BattlegroundMgr.IsRandomBattleground(bg.Id))
|
||||
perm = RBACPermissions.JoinRandomBg;
|
||||
|
||||
return GetSession().HasPermission(perm);
|
||||
@@ -687,8 +688,8 @@ namespace Game.Entities
|
||||
public bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
// get a template bg instead of running one
|
||||
Battleground bg = Global.BattlegroundMgr.GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg)
|
||||
BattlegroundTemplate bg = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (bg == null)
|
||||
return false;
|
||||
|
||||
// limit check leel to dbc compatible level range
|
||||
|
||||
@@ -802,37 +802,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Battleground Holiday Data...");
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
// 0 1
|
||||
SQLResult result = DB.World.Query("SELECT EventEntry, BattlegroundID FROM game_event_battleground_holiday");
|
||||
if (result.IsEmpty())
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Battlegroundholidays in game events. DB table `game_event_battleground_holiday` is empty.");
|
||||
else
|
||||
{
|
||||
uint count = 0;
|
||||
do
|
||||
{
|
||||
ushort eventId = result.Read<byte>(0);
|
||||
|
||||
if (eventId >= mGameEvent.Length)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "`game_event_battleground_holiday` game event id ({0}) not exist in `game_event`", eventId);
|
||||
continue;
|
||||
}
|
||||
|
||||
mGameEventBattlegroundHolidays[eventId] = result.Read<uint>(1);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} Battlegroundholidays in game events in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Pool Data...");
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
@@ -915,7 +884,6 @@ namespace Game
|
||||
mGameEventCreatureQuests = new List<Tuple<uint, uint>>[maxEventId];
|
||||
mGameEventGameObjectQuests = new List<Tuple<uint, uint>>[maxEventId];
|
||||
mGameEventVendors = new Dictionary<uint, VendorItem>[maxEventId];
|
||||
mGameEventBattlegroundHolidays = new uint[maxEventId];
|
||||
mGameEventNPCFlags = new List<(ulong guid, ulong npcflag)>[maxEventId];
|
||||
mGameEventModelEquip = new List<Tuple<ulong, ModelEquip>>[maxEventId];
|
||||
for (var i = 0; i < maxEventId; ++i)
|
||||
@@ -1053,8 +1021,6 @@ namespace Game
|
||||
UpdateEventNPCFlags(event_id);
|
||||
// remove vendor items
|
||||
UpdateEventNPCVendor(event_id, false);
|
||||
// update bg holiday
|
||||
UpdateBattlegroundSettings();
|
||||
}
|
||||
|
||||
void ApplyNewEvent(ushort event_id)
|
||||
@@ -1079,8 +1045,6 @@ namespace Game
|
||||
UpdateEventNPCFlags(event_id);
|
||||
// add vendor items
|
||||
UpdateEventNPCVendor(event_id, true);
|
||||
// update bg holiday
|
||||
UpdateBattlegroundSettings();
|
||||
|
||||
//! Run SAI scripts with SMART_EVENT_GAME_EVENT_START
|
||||
RunSmartAIScripts(event_id, true);
|
||||
@@ -1126,14 +1090,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBattlegroundSettings()
|
||||
{
|
||||
Global.BattlegroundMgr.ResetHolidays();
|
||||
|
||||
foreach (ushort activeEventId in m_ActiveEvents)
|
||||
Global.BattlegroundMgr.SetHolidayActive(mGameEventBattlegroundHolidays[activeEventId]);
|
||||
}
|
||||
|
||||
void UpdateEventNPCVendor(ushort eventId, bool activate)
|
||||
{
|
||||
foreach (var npcEventVendor in mGameEventVendors[eventId])
|
||||
@@ -1698,7 +1654,6 @@ namespace Game
|
||||
List<Tuple<ulong, ModelEquip>>[] mGameEventModelEquip;
|
||||
List<uint>[] mGameEventPoolIds;
|
||||
GameEventData[] mGameEvent;
|
||||
uint[] mGameEventBattlegroundHolidays;
|
||||
Dictionary<uint, GameEventQuestToEventConditionNum> mQuestToEventConditions = new();
|
||||
List<(ulong guid, ulong npcflag)>[] mGameEventNPCFlags;
|
||||
List<ushort> m_ActiveEvents = new();
|
||||
|
||||
@@ -1151,14 +1151,14 @@ namespace Game.Groups
|
||||
}
|
||||
}
|
||||
|
||||
public GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint MinPlayerCount, uint MaxPlayerCount, bool isRated, uint arenaSlot, out ObjectGuid errorGuid)
|
||||
public GroupJoinBattlegroundResult CanJoinBattlegroundQueue(BattlegroundTemplate bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint MinPlayerCount, uint MaxPlayerCount, bool isRated, uint arenaSlot, out ObjectGuid errorGuid)
|
||||
{
|
||||
errorGuid = new ObjectGuid();
|
||||
// check if this group is LFG group
|
||||
if (IsLFGGroup())
|
||||
return GroupJoinBattlegroundResult.LfgCantUseBattleground;
|
||||
|
||||
BattlemasterListRecord bgEntry = CliDB.BattlemasterListStorage.LookupByKey(bgOrTemplate.GetTypeID());
|
||||
BattlemasterListRecord bgEntry = CliDB.BattlemasterListStorage.LookupByKey(bgOrTemplate.Id);
|
||||
if (bgEntry == null)
|
||||
return GroupJoinBattlegroundResult.BattlegroundJoinFailed; // shouldn't happen
|
||||
|
||||
@@ -1174,7 +1174,7 @@ namespace Game.Groups
|
||||
if (!reference)
|
||||
return GroupJoinBattlegroundResult.BattlegroundJoinFailed;
|
||||
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bgOrTemplate.GetMapId(), reference.GetLevel());
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel((uint)bgOrTemplate.BattlemasterEntry.MapId[0], reference.GetLevel());
|
||||
if (bracketEntry == null)
|
||||
return GroupJoinBattlegroundResult.BattlegroundJoinFailed;
|
||||
|
||||
@@ -1212,13 +1212,13 @@ namespace Game.Groups
|
||||
// don't let join if someone from the group is in bg queue random
|
||||
bool isInRandomBgQueue = member.InBattlegroundQueueForBattlegroundQueueType(Global.BattlegroundMgr.BGQueueTypeId((ushort)BattlegroundTypeId.RB, BattlegroundQueueIdType.Battleground, false, 0))
|
||||
|| member.InBattlegroundQueueForBattlegroundQueueType(Global.BattlegroundMgr.BGQueueTypeId((ushort)BattlegroundTypeId.RandomEpic, BattlegroundQueueIdType.Battleground, false, 0));
|
||||
if (bgOrTemplate.GetTypeID() != BattlegroundTypeId.AA && isInRandomBgQueue)
|
||||
if (bgOrTemplate.Id != BattlegroundTypeId.AA && isInRandomBgQueue)
|
||||
return GroupJoinBattlegroundResult.InRandomBg;
|
||||
// don't let join to bg queue random if someone from the group is already in bg queue
|
||||
if ((bgOrTemplate.GetTypeID() == BattlegroundTypeId.RB || bgOrTemplate.GetTypeID() == BattlegroundTypeId.RandomEpic) && member.InBattlegroundQueue(true) && !isInRandomBgQueue)
|
||||
if (Global.BattlegroundMgr.IsRandomBattleground(bgOrTemplate.Id) && member.InBattlegroundQueue(true) && !isInRandomBgQueue)
|
||||
return GroupJoinBattlegroundResult.InNonRandomBg;
|
||||
// check for deserter debuff in case not arena queue
|
||||
if (bgOrTemplate.GetTypeID() != BattlegroundTypeId.AA && member.IsDeserter())
|
||||
if (bgOrTemplate.Id != BattlegroundTypeId.AA && member.IsDeserter())
|
||||
return GroupJoinBattlegroundResult.Deserters;
|
||||
// check if member can join any more Battleground queues
|
||||
if (!member.HasFreeBattlegroundQueueId())
|
||||
|
||||
@@ -75,12 +75,12 @@ namespace Game
|
||||
return;
|
||||
|
||||
// get bg instance or bg template if instance not found
|
||||
Battleground bg = Global.BattlegroundMgr.GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg)
|
||||
BattlegroundTemplate bgTemplate = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (bgTemplate == null)
|
||||
return;
|
||||
|
||||
// expected bracket entry
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bg.GetMapId(), GetPlayer().GetLevel());
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel((uint)bgTemplate.BattlemasterEntry.MapId[0], GetPlayer().GetLevel());
|
||||
if (bracketEntry == null)
|
||||
return;
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Game
|
||||
Team getQueueTeam()
|
||||
{
|
||||
// mercenary applies only to unrated battlegrounds
|
||||
if (!bg.IsRated() && !bg.IsArena())
|
||||
if (!bgQueueTypeId.Rated && !bgTemplate.IsArena())
|
||||
{
|
||||
if (_player.HasAura(BattlegroundConst.SpellMercenaryContractHorde))
|
||||
return Team.Horde;
|
||||
@@ -115,7 +115,7 @@ namespace Game
|
||||
}
|
||||
|
||||
// check RBAC permissions
|
||||
if (!GetPlayer().CanJoinToBattleground(bg))
|
||||
if (!GetPlayer().CanJoinToBattleground(bgTemplate))
|
||||
{
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusFailed(out battlefieldStatusFailed, bgQueueTypeId, GetPlayer(), 0, GroupJoinBattlegroundResult.JoinTimedOut);
|
||||
SendPacket(battlefieldStatusFailed);
|
||||
@@ -132,7 +132,7 @@ namespace Game
|
||||
|
||||
bool isInRandomBgQueue = _player.InBattlegroundQueueForBattlegroundQueueType(Global.BattlegroundMgr.BGQueueTypeId((ushort)BattlegroundTypeId.RB, BattlegroundQueueIdType.Battleground, false, 0))
|
||||
|| _player.InBattlegroundQueueForBattlegroundQueueType(Global.BattlegroundMgr.BGQueueTypeId((ushort)BattlegroundTypeId.RandomEpic, BattlegroundQueueIdType.Battleground, false, 0));
|
||||
if (bgTypeId != BattlegroundTypeId.RB && bgTypeId != BattlegroundTypeId.RandomEpic && isInRandomBgQueue)
|
||||
if (!Global.BattlegroundMgr.IsRandomBattleground(bgTypeId) && isInRandomBgQueue)
|
||||
{
|
||||
// player is already in random queue
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusFailed(out battlefieldStatusFailed, bgQueueTypeId, GetPlayer(), 0, GroupJoinBattlegroundResult.InRandomBg);
|
||||
@@ -140,7 +140,7 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.InBattlegroundQueue(true) && !isInRandomBgQueue && (bgTypeId == BattlegroundTypeId.RB || bgTypeId == BattlegroundTypeId.RandomEpic))
|
||||
if (_player.InBattlegroundQueue(true) && !isInRandomBgQueue && Global.BattlegroundMgr.IsRandomBattleground(bgTypeId))
|
||||
{
|
||||
// player is already in queue, can't start random queue
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusFailed(out battlefieldStatusFailed, bgQueueTypeId, GetPlayer(), 0, GroupJoinBattlegroundResult.InNonRandomBg);
|
||||
@@ -170,7 +170,7 @@ namespace Game
|
||||
uint avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry.GetBracketId());
|
||||
uint queueSlot = GetPlayer().AddBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, bg, GetPlayer(), queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, 0, false);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, GetPlayer(), queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, false);
|
||||
SendPacket(battlefieldStatusQueued);
|
||||
|
||||
Log.outDebug(LogFilter.Battleground, $"Battleground: player joined queue for bg queue {bgQueueTypeId}, {_player.GetGUID()}, NAME {_player.GetName()}");
|
||||
@@ -181,8 +181,8 @@ namespace Game
|
||||
return;
|
||||
|
||||
ObjectGuid errorGuid;
|
||||
err = grp.CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg.GetMaxPlayersPerTeam(), false, 0, out errorGuid);
|
||||
isPremade = (grp.GetMembersCount() >= bg.GetMinPlayersPerTeam());
|
||||
err = grp.CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, 0, bgTemplate.GetMaxPlayersPerTeam(), false, 0, out errorGuid);
|
||||
isPremade = (grp.GetMembersCount() >= bgTemplate.GetMinPlayersPerTeam());
|
||||
|
||||
BattlegroundQueue bgQueue = Global.BattlegroundMgr.GetBattlegroundQueue(bgQueueTypeId);
|
||||
GroupQueueInfo ginfo = null;
|
||||
@@ -212,7 +212,7 @@ namespace Game
|
||||
// add to queue
|
||||
uint queueSlot = member.AddBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, bg, member, queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, 0, true);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, member, queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, true);
|
||||
member.SendPacket(battlefieldStatusQueued);
|
||||
Log.outDebug(LogFilter.Battleground, $"Battleground: player joined queue for bg queue {bgQueueTypeId}, {member.GetGUID()}, NAME {member.GetName()}");
|
||||
}
|
||||
@@ -288,31 +288,29 @@ namespace Game
|
||||
}
|
||||
|
||||
BattlegroundTypeId bgTypeId = (BattlegroundTypeId)bgQueueTypeId.BattlemasterListId;
|
||||
BattlegroundTemplate bgTemplate = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (bgTemplate == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, $"BattlegroundHandle: BattlegroundTemplate not found for type id {bgTypeId}.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint mapId = (uint)bgTemplate.BattlemasterEntry.MapId[0];
|
||||
|
||||
// BGTemplateId returns Battleground_AA when it is arena queue.
|
||||
// Do instance id search as there is no AA bg instances.
|
||||
Battleground bg = Global.BattlegroundMgr.GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId == BattlegroundTypeId.AA ? BattlegroundTypeId.None : bgTypeId);
|
||||
if (!bg)
|
||||
if (bg == null && battlefieldPort.AcceptedInvite)
|
||||
{
|
||||
if (battlefieldPort.AcceptedInvite)
|
||||
{
|
||||
Log.outDebug(LogFilter.Battleground, "CMSG_BATTLEFIELD_PORT {0} Slot: {1}, Unk: {2}, Time: {3}, AcceptedInvite: {4}. Cant find BG with id {5}!",
|
||||
GetPlayerInfo(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, battlefieldPort.AcceptedInvite, ginfo.IsInvitedToBGInstanceGUID);
|
||||
return;
|
||||
}
|
||||
|
||||
bg = Global.BattlegroundMgr.GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "BattlegroundHandler: bg_template not found for type id {0}.", bgTypeId);
|
||||
return;
|
||||
}
|
||||
Log.outDebug(LogFilter.Battleground, "CMSG_BATTLEFIELD_PORT {0} Slot: {1}, Unk: {2}, Time: {3}, AcceptedInvite: {4}. Cant find BG with id {5}!",
|
||||
GetPlayerInfo(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, battlefieldPort.AcceptedInvite, ginfo.IsInvitedToBGInstanceGUID);
|
||||
return;
|
||||
}
|
||||
|
||||
// get real bg type
|
||||
bgTypeId = bg.GetTypeID();
|
||||
else if (bg != null)
|
||||
mapId = bg.GetMapId();
|
||||
|
||||
// expected bracket entry
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bg.GetMapId(), GetPlayer().GetLevel());
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(mapId, GetPlayer().GetLevel());
|
||||
if (bracketEntry == null)
|
||||
return;
|
||||
|
||||
@@ -360,7 +358,7 @@ namespace Game
|
||||
GetPlayer().FinishTaxiFlight();
|
||||
|
||||
BattlefieldStatusActive battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusActive(out battlefieldStatus, bg, GetPlayer(), battlefieldPort.Ticket.Id, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), bg.GetArenaType());
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusActive(out battlefieldStatus, bg, GetPlayer(), battlefieldPort.Ticket.Id, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), bgQueueTypeId);
|
||||
SendPacket(battlefieldStatus);
|
||||
|
||||
// remove BattlegroundQueue status from BGmgr
|
||||
@@ -372,7 +370,7 @@ namespace Game
|
||||
currentBg.RemovePlayerAtLeave(GetPlayer().GetGUID(), false, true);
|
||||
|
||||
// set the destination instance id
|
||||
GetPlayer().SetBattlegroundId(bg.GetInstanceID(), bgTypeId);
|
||||
GetPlayer().SetBattlegroundId(bg.GetInstanceID(), bg.GetTypeID(), bgQueueTypeId);
|
||||
// set the destination team
|
||||
GetPlayer().SetBGTeam(ginfo.Team);
|
||||
|
||||
@@ -433,15 +431,18 @@ namespace Game
|
||||
continue;
|
||||
|
||||
BattlegroundTypeId bgTypeId = (BattlegroundTypeId)bgQueueTypeId.BattlemasterListId;
|
||||
ArenaTypes arenaType = (ArenaTypes)bgQueueTypeId.TeamSize;
|
||||
bg = _player.GetBattleground();
|
||||
if (bg && bg.GetQueueId() == bgQueueTypeId)
|
||||
if (bg != null)
|
||||
{
|
||||
//i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
|
||||
//so i must use bg pointer to get that information
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusActive(out BattlefieldStatusActive battlefieldStatus, bg, _player, i, _player.GetBattlegroundQueueJoinTime(bgQueueTypeId), arenaType);
|
||||
SendPacket(battlefieldStatus);
|
||||
continue;
|
||||
BattlegroundPlayer bgPlayer = bg.GetBattlegroundPlayerData(_player.GetGUID());
|
||||
if (bgPlayer != null && bgPlayer.queueTypeId == bgQueueTypeId)
|
||||
{
|
||||
//i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
|
||||
//so i must use bg pointer to get that information
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusActive(out BattlefieldStatusActive battlefieldStatus, bg, _player, i, _player.GetBattlegroundQueueJoinTime(bgQueueTypeId), bgQueueTypeId);
|
||||
SendPacket(battlefieldStatus);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//we are sending update to player about queue - he can be invited there!
|
||||
@@ -458,23 +459,23 @@ namespace Game
|
||||
continue;
|
||||
|
||||
BattlefieldStatusNeedConfirmation battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), Time.GetMSTimeDiff(Time.GetMSTime(), ginfo.RemoveInviteTime), arenaType);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), Time.GetMSTimeDiff(Time.GetMSTime(), ginfo.RemoveInviteTime), bgQueueTypeId);
|
||||
SendPacket(battlefieldStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
bg = Global.BattlegroundMgr.GetBattlegroundTemplate(bgTypeId);
|
||||
if (!bg)
|
||||
BattlegroundTemplate bgTemplate = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (bgTemplate == null)
|
||||
continue;
|
||||
|
||||
// expected bracket entry
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bg.GetMapId(), GetPlayer().GetLevel());
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel((uint)bgTemplate.BattlemasterEntry.MapId[0], _player.GetLevel());
|
||||
if (bracketEntry == null)
|
||||
continue;
|
||||
|
||||
uint avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry.GetBracketId());
|
||||
BattlefieldStatusQueued battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), bgQueueTypeId, avgTime, arenaType, ginfo.Players.Count > 1);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out battlefieldStatus, _player, i, _player.GetBattlegroundQueueJoinTime(bgQueueTypeId), bgQueueTypeId, avgTime, ginfo.Players.Count > 1);
|
||||
SendPacket(battlefieldStatus);
|
||||
}
|
||||
}
|
||||
@@ -490,8 +491,8 @@ namespace Game
|
||||
ArenaTypes arenatype = (ArenaTypes)ArenaTeam.GetTypeBySlot(packet.TeamSizeIndex);
|
||||
|
||||
//check existence
|
||||
Battleground bg = Global.BattlegroundMgr.GetBattlegroundTemplate(BattlegroundTypeId.AA);
|
||||
if (!bg)
|
||||
BattlegroundTemplate bgTemplate = Global.BattlegroundMgr.GetBattlegroundTemplateByTypeId(BattlegroundTypeId.AA);
|
||||
if (bgTemplate == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Battleground: template bg (all arenas) not found");
|
||||
return;
|
||||
@@ -503,9 +504,9 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
BattlegroundTypeId bgTypeId = bg.GetTypeID();
|
||||
BattlegroundTypeId bgTypeId = bgTemplate.Id;
|
||||
BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId((ushort)bgTypeId, BattlegroundQueueIdType.Arena, true, arenatype);
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bg.GetMapId(), GetPlayer().GetLevel());
|
||||
PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel((uint)bgTemplate.BattlemasterEntry.MapId[0], _player.GetLevel());
|
||||
if (bracketEntry == null)
|
||||
return;
|
||||
|
||||
@@ -536,7 +537,7 @@ namespace Game
|
||||
GroupQueueInfo ginfo = null;
|
||||
|
||||
ObjectGuid errorGuid;
|
||||
var err = grp.CanJoinBattlegroundQueue(bg, bgQueueTypeId, (uint)arenatype, (uint)arenatype, true, packet.TeamSizeIndex, out errorGuid);
|
||||
var err = grp.CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, (uint)arenatype, (uint)arenatype, true, packet.TeamSizeIndex, out errorGuid);
|
||||
if (err == 0)
|
||||
{
|
||||
Log.outDebug(LogFilter.Battleground, "Battleground: arena team id {0}, leader {1} queued with matchmaker rating {2} for type {3}", GetPlayer().GetArenaTeamId(packet.TeamSizeIndex), GetPlayer().GetName(), matchmakerRating, arenatype);
|
||||
@@ -559,7 +560,7 @@ namespace Game
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!GetPlayer().CanJoinToBattleground(bg))
|
||||
if (!GetPlayer().CanJoinToBattleground(bgTemplate))
|
||||
{
|
||||
BattlefieldStatusFailed battlefieldStatus;
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusFailed(out battlefieldStatus, bgQueueTypeId, GetPlayer(), 0, GroupJoinBattlegroundResult.BattlegroundJoinFailed, errorGuid);
|
||||
@@ -570,7 +571,7 @@ namespace Game
|
||||
// add to queue
|
||||
uint queueSlot = member.AddBattlegroundQueueId(bgQueueTypeId);
|
||||
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, bg, member, queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, arenatype, true);
|
||||
Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out BattlefieldStatusQueued battlefieldStatusQueued, member, queueSlot, ginfo.JoinTime, bgQueueTypeId, avgTime, true);
|
||||
member.SendPacket(battlefieldStatusQueued);
|
||||
|
||||
Log.outDebug(LogFilter.Battleground, $"Battleground: player joined queue for arena as group bg queue {bgQueueTypeId}, {member.GetGUID()}, NAME {member.GetName()}");
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace Game
|
||||
if (bg)
|
||||
{
|
||||
if (player.IsInvitedForBattlegroundInstance(player.GetBattlegroundId()))
|
||||
bg.AddPlayer(player);
|
||||
bg.AddPlayer(player, player.m_bgData.queueId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1246,7 +1246,7 @@ namespace Game.Spells
|
||||
Battleground bg = player.GetBattleground();
|
||||
if (bg)
|
||||
{
|
||||
if (bg.GetTypeID(true) == BattlegroundTypeId.EY)
|
||||
if (bg.GetTypeID() == BattlegroundTypeId.EY)
|
||||
bg.EventPlayerClickedOnFlag(player, gameObjTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ namespace Game
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading World locations...");
|
||||
Global.ObjectMgr.LoadWorldSafeLocs(); // must be before LoadAreaTriggerTeleports and LoadGraveyardZones
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading AreaTrigger definitions...");
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Area Trigger Teleports definitions...");
|
||||
Global.ObjectMgr.LoadAreaTriggerTeleports();
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loading Access Requirements...");
|
||||
|
||||
Reference in New Issue
Block a user