diff --git a/Source/Framework/Constants/BattleFieldConst.cs b/Source/Framework/Constants/BattleFieldConst.cs index ce86046f0..6b190dd99 100644 --- a/Source/Framework/Constants/BattleFieldConst.cs +++ b/Source/Framework/Constants/BattleFieldConst.cs @@ -35,17 +35,6 @@ namespace Framework.Constants HordeAllianceChallenge } - public enum BFLeaveReason - { - Close = 1, - //BF_LEAVE_REASON_UNK1 = 2, (not used) - //BF_LEAVE_REASON_UNK2 = 4, (not used) - Exited = 8, - LowLevel = 10, - NotWhileInRaid = 15, - Deserter = 16 - } - public enum BattlefieldState { Inactive = 0, diff --git a/Source/Game/BattleFields/BattleField.cs b/Source/Game/BattleFields/BattleField.cs index 9c6272190..5b8488c9f 100644 --- a/Source/Game/BattleFields/BattleField.cs +++ b/Source/Game/BattleFields/BattleField.cs @@ -95,7 +95,6 @@ namespace Game.BattleFields if (m_PlayersInWar[player.GetTeamId()].Contains(player.GetGUID())) { m_PlayersInWar[player.GetTeamId()].Remove(player.GetGUID()); - player.GetSession().SendBfLeaveMessage(GetQueueId(), GetState(), player.GetZoneId() == GetZoneId()); Group group = player.GetGroup(); if (group) // Remove the player from the raid group group.RemoveMember(player.GetGUID()); @@ -209,7 +208,7 @@ namespace Game.BattleFields return; if (m_PlayersInQueue[player.GetTeamId()].Count <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player.GetTeamId())].Count >= m_MinPlayer) - player.GetSession().SendBfInvitePlayerToQueue(GetQueueId(), GetState()); + PlayerAcceptInviteToQueue(player); } void InvitePlayersInQueueToWar() @@ -282,7 +281,7 @@ namespace Game.BattleFields m_PlayersWillBeKick[player.GetTeamId()].Remove(player.GetGUID()); m_InvitedPlayers[player.GetTeamId()][player.GetGUID()] = GameTime.GetGameTime() + m_TimeForAcceptInvite; - player.GetSession().SendBfInvitePlayerToWar(GetQueueId(), m_ZoneId, m_TimeForAcceptInvite); + PlayerAcceptInviteToWar(player); } public void InitStalker(uint entry, Position pos) @@ -369,8 +368,6 @@ namespace Game.BattleFields { // Add player in queue m_PlayersInQueue[player.GetTeamId()].Add(player.GetGUID()); - // Send notification - player.GetSession().SendBfQueueInviteResponse(GetQueueId(), m_ZoneId, GetState()); } // Called in WorldSession:HandleBfExitRequest @@ -396,7 +393,6 @@ namespace Game.BattleFields if (AddOrSetPlayerToCorrectBfGroup(player)) { - player.GetSession().SendBfEntered(GetQueueId(), player.GetZoneId() != GetZoneId(), player.GetTeamId() == GetAttackerTeam()); m_PlayersInWar[player.GetTeamId()].Add(player.GetGUID()); m_InvitedPlayers[player.GetTeamId()].Remove(player.GetGUID()); diff --git a/Source/Game/Handlers/BattleFieldHandler.cs b/Source/Game/Handlers/BattleFieldHandler.cs deleted file mode 100644 index 271db143f..000000000 --- a/Source/Game/Handlers/BattleFieldHandler.cs +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2012-2020 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 . - */ - -using Framework.Constants; -using Game.BattleFields; -using Game.Networking.Packets; - -namespace Game -{ - public partial class WorldSession - { - /// - /// This send to player windows for invite player to join the war. - /// - /// The queue id of Bf - /// The zone where the battle is (4197 for wg) - /// Time in second that the player have for accept - public void SendBfInvitePlayerToWar(ulong queueId, uint zoneId, uint acceptTime) - { - BFMgrEntryInvite bfMgrEntryInvite = new(); - bfMgrEntryInvite.QueueID = queueId; - bfMgrEntryInvite.AreaID = (int)zoneId; - bfMgrEntryInvite.ExpireTime = GameTime.GetGameTime() + acceptTime; - SendPacket(bfMgrEntryInvite); - } - - /// - /// This send invitation to player to join the queue. - /// - /// The queue id of Bf - /// Battlefield State - public void SendBfInvitePlayerToQueue(ulong queueId, BattlefieldState battleState) - { - BFMgrQueueInvite bfMgrQueueInvite = new(); - bfMgrQueueInvite.QueueID = queueId; - bfMgrQueueInvite.BattleState = battleState; - SendPacket(bfMgrQueueInvite); - } - - /// - /// This send packet for inform player that he join queue. - /// - /// The queue id of Bf - /// The zone where the battle is (4197 for wg) - /// Battlefield status - /// if able to queue - /// on log in send queue status - public void SendBfQueueInviteResponse(ulong queueId, uint zoneId, BattlefieldState battleStatus, bool canQueue = true, bool loggingIn = false) - { - BFMgrQueueRequestResponse bfMgrQueueRequestResponse = new(); - bfMgrQueueRequestResponse.QueueID = queueId; - bfMgrQueueRequestResponse.AreaID = (int)zoneId; - bfMgrQueueRequestResponse.Result = (sbyte)(canQueue ? 1 : 0); - bfMgrQueueRequestResponse.BattleState = battleStatus; - bfMgrQueueRequestResponse.LoggingIn = loggingIn; - SendPacket(bfMgrQueueRequestResponse); - } - - /// - /// This is call when player accept to join war. - /// - /// The queue id of Bf - /// Whether player is added to Bf on the spot or teleported from queue - /// Whether player belongs to attacking team or not - public void SendBfEntered(ulong queueId, bool relocated, bool onOffense) - { - BFMgrEntering bfMgrEntering = new(); - bfMgrEntering.ClearedAFK = _player.IsAFK(); - bfMgrEntering.Relocated = relocated; - bfMgrEntering.OnOffense = onOffense; - bfMgrEntering.QueueID = queueId; - SendPacket(bfMgrEntering); - } - - /// - /// This is call when player leave battlefield zone. - /// - /// The queue id of Bf - /// Battlefield status - /// Whether player is added to Bf on the spot or teleported from queue - /// Reason why player left battlefield - public void SendBfLeaveMessage(ulong queueId, BattlefieldState battleState, bool relocated, BFLeaveReason reason = BFLeaveReason.Exited) - { - BFMgrEjected bfMgrEjected = new(); - bfMgrEjected.QueueID = queueId; - bfMgrEjected.Reason = reason; - bfMgrEjected.BattleState = battleState; - bfMgrEjected.Relocated = relocated; - SendPacket(bfMgrEjected); - } - - /// - /// Send by client on clicking in accept or refuse of invitation windows for join game. - /// - //[WorldPacketHandler(ClientOpcodes.BfMgrEntryInviteResponse)] - void HandleBfEntryInviteResponse(BFMgrEntryInviteResponse bfMgrEntryInviteResponse) - { - BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrEntryInviteResponse.QueueID); - if (bf == null) - return; - - // If player accept invitation - if (bfMgrEntryInviteResponse.AcceptedInvite) - { - bf.PlayerAcceptInviteToWar(GetPlayer()); - } - else - { - if (GetPlayer().GetZoneId() == bf.GetZoneId()) - bf.KickPlayerFromBattlefield(GetPlayer().GetGUID()); - } - } - - /// - /// Send by client when he click on accept for queue. - /// - //[WorldPacketHandler(ClientOpcodes.BfMgrQueueInviteResponse)] - void HandleBfQueueInviteResponse(BFMgrQueueInviteResponse bfMgrQueueInviteResponse) - { - BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrQueueInviteResponse.QueueID); - if (bf == null) - return; - - if (bfMgrQueueInviteResponse.AcceptedInvite) - bf.PlayerAcceptInviteToQueue(GetPlayer()); - } - - /// - /// Send by client when exited battlefield - /// - //[WorldPacketHandler(ClientOpcodes.BfMgrQueueExitRequest)] - void HandleBfExitRequest(BFMgrQueueExitRequest bfMgrQueueExitRequest) - { - BattleField bf = Global.BattleFieldMgr.GetBattlefieldByQueueId(bfMgrQueueExitRequest.QueueID); - if (bf == null) - return; - - bf.AskToLeaveQueue(GetPlayer()); - } - } -} diff --git a/Source/Game/Networking/Packets/BattleGroundPackets.cs b/Source/Game/Networking/Packets/BattleGroundPackets.cs index 7986ab7cc..ac49820df 100644 --- a/Source/Game/Networking/Packets/BattleGroundPackets.cs +++ b/Source/Game/Networking/Packets/BattleGroundPackets.cs @@ -61,6 +61,20 @@ namespace Game.Networking.Packets public ObjectGuid HealerGuid; } + public class AreaSpiritHealerTime : ServerPacket + { + public AreaSpiritHealerTime() : base(ServerOpcodes.AreaSpiritHealerTime) { } + + public override void Write() + { + _worldPacket.WritePackedGuid(HealerGuid); + _worldPacket.WriteUInt32(TimeLeft); + } + + public ObjectGuid HealerGuid; + public uint TimeLeft; + } + public class AreaSpiritHealerQueue : ClientPacket { public AreaSpiritHealerQueue(WorldPacket packet) : base(packet) { } diff --git a/Source/Game/Networking/Packets/BattlefieldPackets.cs b/Source/Game/Networking/Packets/BattlefieldPackets.cs deleted file mode 100644 index 822441b71..000000000 --- a/Source/Game/Networking/Packets/BattlefieldPackets.cs +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2012-2020 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 . - */ - -using Framework.Constants; -using Game.Entities; - -namespace Game.Networking.Packets -{ - class BFMgrEntryInvite : ServerPacket - { - public BFMgrEntryInvite() : base(ServerOpcodes.None) { } - - public override void Write() - { - _worldPacket.WriteUInt64(QueueID); - _worldPacket.WriteInt32(AreaID); - _worldPacket.WriteUInt32((uint)ExpireTime); - } - - public ulong QueueID; - public int AreaID; - public long ExpireTime; - } - - class BFMgrEntryInviteResponse : ClientPacket - { - public BFMgrEntryInviteResponse(WorldPacket packet) : base(packet) { } - - public override void Read() - { - QueueID = _worldPacket.ReadUInt64(); - AcceptedInvite = _worldPacket.HasBit(); - } - - public ulong QueueID; - public bool AcceptedInvite; - } - - class BFMgrQueueInvite : ServerPacket - { - public BFMgrQueueInvite() : base(ServerOpcodes.None) { } - - public override void Write() - { - _worldPacket.WriteUInt64(QueueID); - _worldPacket.WriteInt8((sbyte)BattleState); - _worldPacket.WriteUInt32(Timeout); - _worldPacket.WriteInt32(MinLevel); - _worldPacket.WriteInt32(MaxLevel); - _worldPacket.WriteInt32(MapID); - _worldPacket.WriteUInt32(InstanceID); - _worldPacket.WriteBit(Index != 0); - _worldPacket.FlushBits(); - } - - public ulong QueueID; - public BattlefieldState BattleState; - public uint Timeout = uint.MaxValue; // unused in client - public int MinLevel; // unused in client - public int MaxLevel; // unused in client - public int MapID; // unused in client - public uint InstanceID; // unused in client - public sbyte Index; // unused in client - } - - class BFMgrQueueInviteResponse : ClientPacket - { - public BFMgrQueueInviteResponse(WorldPacket packet) : base(packet) { } - - public override void Read() - { - QueueID = _worldPacket.ReadUInt64(); - AcceptedInvite = _worldPacket.HasBit(); - } - - public ulong QueueID; - public bool AcceptedInvite; - } - - class BFMgrQueueRequestResponse : ServerPacket - { - public BFMgrQueueRequestResponse() : base(ServerOpcodes.None) { } - - public override void Write() - { - _worldPacket.WriteUInt64(QueueID); - _worldPacket.WriteInt32(AreaID); - _worldPacket.WriteInt8(Result); - _worldPacket.WritePackedGuid(FailedPlayerGUID); - _worldPacket.WriteInt8((sbyte)BattleState); - _worldPacket.WriteBit(LoggingIn); - _worldPacket.FlushBits(); - } - - public ulong QueueID; - public int AreaID; - public sbyte Result; - public ObjectGuid FailedPlayerGUID; - public BattlefieldState BattleState; - public bool LoggingIn; - } - - class BFMgrQueueExitRequest : ClientPacket - { - public BFMgrQueueExitRequest(WorldPacket packet) : base(packet) { } - - public override void Read() - { - QueueID = _worldPacket.ReadUInt64(); - } - - public ulong QueueID; - } - - class BFMgrEntering : ServerPacket - { - public BFMgrEntering() : base(ServerOpcodes.None, ConnectionType.Instance) { } - - public override void Write() - { - _worldPacket.WriteBit(ClearedAFK); - _worldPacket.WriteBit(Relocated); - _worldPacket.WriteBit(OnOffense); - _worldPacket.WriteUInt64(QueueID); - } - - public bool ClearedAFK; - public bool Relocated; - public bool OnOffense; - public ulong QueueID; - } - - class BFMgrEjected : ServerPacket - { - public BFMgrEjected() : base(ServerOpcodes.None, ConnectionType.Instance) { } - - public override void Write() - { - _worldPacket.WriteUInt64(QueueID); - _worldPacket.WriteInt8((sbyte)Reason); - _worldPacket.WriteInt8((sbyte)BattleState); - _worldPacket.WriteBit(Relocated); - _worldPacket.FlushBits(); - } - - public ulong QueueID; - public BFLeaveReason Reason; - public BattlefieldState BattleState; - public bool Relocated; - } - - public class AreaSpiritHealerTime : ServerPacket - { - public AreaSpiritHealerTime() : base(ServerOpcodes.AreaSpiritHealerTime) { } - - public override void Write() - { - _worldPacket.WritePackedGuid(HealerGuid); - _worldPacket.WriteUInt32(TimeLeft); - } - - public ObjectGuid HealerGuid; - public uint TimeLeft; - } -}