public InstanceBattlegroundQueue(Battleground bg)
		{
			m_battleground = bg;

			m_Template = bg.Template;
			m_MinLevel = bg.MinLevel;
			m_MaxLevel = bg.MaxLevel;
		}
Exemplo n.º 2
0
		public BattlegroundTeam(BattlegroundTeamQueue queue, BattlegroundSide side, Battleground battleground)
		{
			Queue = queue;
			Side = side;
			_battleground = battleground;

			var templ = battleground.Template;
			if (side == BattlegroundSide.Alliance)
			{
				_startPosition = templ.AllianceStartPosition;
				_startOrientation = templ.AllianceStartOrientation;
			}
			else
			{
				_startPosition = templ.HordeStartPosition;
				_startOrientation = templ.HordeStartOrientation;
			}
		}
Exemplo n.º 3
0
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();

            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
            	var winner = bg.Winner;

                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    // TODO: Arena
                    for (var i = 0; i < 2; i++)
                    {
                        packet.Write(0); // old rating
                        packet.Write(3999); // new rating (3000 + diff)
                        packet.Write(0); // matchmaking value (lvl group/rank?)
                    }

                    packet.WriteCString(string.Empty); // arena team names
                    packet.WriteCString(string.Empty);
                }

                var isFinished = bg.Winner != null;
                packet.Write(isFinished);
                if (isFinished)
                {
                    packet.Write((byte)bg.Winner.Side);
                }

				var chrs = bg.Characters;

				var chrCount = 0;
            	var chrCountPos = packet.Position;
            	packet.Position += 4;
                for (var i = 0; i < chrCount; i++)
                {
                	var chr = chrs[i];
					if (!chr.IsInBattleground)
					{
						continue;
					}

                	var stats = chr.Battlegrounds.Stats;

                	++chrCount;
                    packet.Write(chr.EntityId); // player guid
					packet.Write(stats.KillingBlows);

                    if (bg.IsArena)
					{
                        packet.Write(winner != null && chr.Battlegrounds.Team == winner); // is on the winning team
                    }
                    else
                    {
						packet.Write(stats.HonorableKills);
						packet.Write(stats.Deaths);
						packet.Write(stats.BonusHonor);
                    }

					packet.Write(stats.TotalDamage);
					packet.Write(stats.TotalHealing);

                    packet.Write(stats.SpecialStatCount);

                	stats.WriteSpecialStats(packet);
                }

            	packet.Position = chrCountPos;
            	packet.Write(chrCount);

                reciever.Send(packet);
            }
        }
Exemplo n.º 4
0
        public static void SendStatusActive(Character chr, Battleground bg, int queueIndex)
        {
            var status = BattlegroundStatus.Active;
            var side = chr.FactionGroup.GetBattlegroundSide();

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_STATUS))
            {
				packet.Write(queueIndex);

                var bgId = bg.Template.Id;

                // 64-bit guid start
                packet.Write((byte)ArenaType.None);
                packet.Write((byte)1); // affects level range calculation?
                packet.Write((uint)bgId);
                packet.Write((ushort)8080);
                // 64-bit guid stop

				packet.Write((byte)0);				// since 3.3
				packet.Write((byte)0);				// since 3.3
                packet.Write(bg.InstanceId); // instance id
                packet.Write((byte)0); // bool isRatedMatch
                packet.Write((int)status);

                packet.Write((int)bg.Id);

                // the number of milliseconds before the Battlefield will close after a battle is finished.
                // This is 0 before the battle is finished
                packet.Write(bg.RemainingShutdownDelay);

                // start time, in ms. clientGetTickCount - this = instance runtime
                packet.Write(bg.RuntimeMillis);
                packet.Write((byte)side); // arena faction - 0 or 1
                chr.Send(packet);
            }
        }
Exemplo n.º 5
0
		int Dequeue(int amount, Battleground bg, LinkedListNode<BattlegroundRelation> node)
		{
			var team = bg.GetTeam(Side);
			var added = 0;

			do
			{
				var relation = node.Value;
				if (relation.Count <= amount)
				{
					m_chrCount -= relation.Characters.CharacterCount;

					added += team.Invite(relation.Characters);

					relation.IsEnqueued = false;

					var next = node.Next;
					PendingRequests.Remove(node);
					node = next;

					if (node == null)
					{
						// was the last node
						break;
					}

					// next node already selected
					continue;
				}
			} while ((node = node.Next) != null && added <= amount);

			return added;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Removes the given amount of Characters from this Queue and adds them
		/// to the given <see cref="Battleground"/>
		/// </summary>
		/// <param name="amount"></param>
		/// <param name="bg"></param>
		/// <returns>The amount of dequeued Characters</returns>
		internal int DequeueCharacters(int amount, Battleground bg)
		{
			bg.EnsureContext();

			var node = PendingRequests.First;
			if (node == null)
			{
				return 0;
			}

			if (_parentQueue.RequiresLocking)
			{
				lock (PendingRequests)
				{
					return Dequeue(amount, bg, node);
				}
			}
			else
			{
				return Dequeue(amount, bg, node);
			}
		}
Exemplo n.º 7
0
			public static void DisplayInfo(CmdTrigger<RealmServerCmdArgs> trigger, Battleground bg)
			{
				trigger.Reply(bg.ToString());
				trigger.Reply(" " + bg.GetTeam(BattlegroundSide.Alliance));
				trigger.Reply(" " + bg.GetTeam(BattlegroundSide.Horde));
			}
		protected internal override void Dispose()
		{
			base.Dispose();

			m_battleground = null;
		}
Exemplo n.º 9
0
		public void Dispose()
		{
			_members = null;
			_battleground = null;
		}
Exemplo n.º 10
0
 public void Dispose()
 {
     _members      = null;
     _battleground = null;
 }
Exemplo n.º 11
0
        protected internal override void Dispose()
        {
            base.Dispose();

            m_battleground = null;
        }
Exemplo n.º 12
0
 internal void OnRemove(Battleground bg)
 {
     Instances.Remove(bg);
 }
Exemplo n.º 13
0
 private void InitBG(Battleground bg)
 {
     Instances.Add(bg);
     bg.ParentQueue = this;
     bg.InitMap(m_Template.MapTemplate);
 }
Exemplo n.º 14
0
 protected internal override void Dispose()
 {
     base.Dispose();
     this.m_battleground = (Battleground)null;
 }