Example #1
0
		private static void ExtractVehicleIds(ParsedUpdatePacket packet)
		{
			foreach (var block in packet.Blocks)
			{
				if (block.Type == UpdateType.Create)
				{
					var movement = block.Movement;
					if ((movement.UpdateFlags & UpdateFlags.Vehicle) != 0)
					{
						var isChar = block.EntityId.High == HighId.Player;
						string suffix;
						if (isChar)
						{
							suffix = "";
						}
						else
						{
							suffix = string.Format(" {0} ({1})", block.EntityId.Entry, (int)block.EntityId.Entry);
						}

						writer.WriteLine("{0}{1}", isChar ? "Player" : "NPC", suffix);
						writer.IndentLevel++;
						writer.WriteLine("VehicleId: " + movement.VehicleId);
						writer.WriteLine("VehicleAimAdjustment: " + movement.VehicleAimAdjustment);
						writer.WriteLine("Hoverheight: " + block.GetFloat(UnitFields.HOVERHEIGHT));
						writer.IndentLevel--;
					}
				}
			}
		}
Example #2
0
        /*public static void Dump(byte[] packetContent, bool isSingleBlock, IndentTextWriter writer)
         * {
         *      Dump(packetContent, isSingleBlock, writer, false);
         * }
         *
         * public static void Dump(PacketIn packet, IndentTextWriter writer)
         * {
         *      Dump(GetBytes(packet), false, writer, false);
         * }
         *
         * public static void Dump(byte[] packetContent, bool isSingleBlock, IndentTextWriter writer, bool isCompressed)
         * {
         *      Dump(DateTime.Now, packetContent, isSingleBlock, writer, isCompressed);
         * }*/

        public static void Dump(DateTime timeStamp, byte[] packetContent, bool isSingleBlock, IndentTextWriter writer, bool isCompressed)
        {
            if (isCompressed)
            {
                packetContent = UpdateFieldsUtil.Decompress(packetContent);
            }
            var packet = new ParsedUpdatePacket(packetContent, isSingleBlock);

            writer.WriteLine("");
            packet.Dump("", writer);
        }
Example #3
0
        public UpdateBlock(ParsedUpdatePacket parser, int index)
        {
            this.index = index;
            packet = parser;
            //Offset = parser.index;

            Type = (UpdateType)ReadByte();

            if (!Enum.IsDefined(typeof(UpdateType), (byte)Type))
            {
                throw new Exception("Invalid UpdateType '" + Type + "' in Block " + this);
            }

            // Console.WriteLine("Reading {0}-Block...", Type);

            if (Type == UpdateType.OutOfRange ||
                Type == UpdateType.Near)
            {
                var count = ReadUInt();
                EntityIds = new EntityId[count];
                for (var i = 0; i < count; i++)
                {
                    EntityIds[i] = ReadPackedEntityId();
                }
            }
            else
            {
                EntityId = ReadPackedEntityId();

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf)
                {
                    ObjectType = (ObjectTypeId)ReadByte();
                }

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf ||
                    Type == UpdateType.Movement)
                {
                    m_movement = ReadMovementBlock();
                }

                if (Type != UpdateType.Movement)
                {
                    Values = ReadValues();
                }
            }

            if (Type != UpdateType.Create && Type != UpdateType.CreateSelf)
            {
                ObjectType = EntityId.ObjectType;
            }
        }
Example #4
0
        public UpdateBlock(ParsedUpdatePacket parser, int index)
        {
            this.index = index;
            packet     = parser;
            //Offset = parser.index;

            Type = (UpdateType)ReadByte();

            if (!Enum.IsDefined(typeof(UpdateType), (byte)Type))
            {
                throw new Exception("Invalid UpdateType '" + Type + "' in Block " + this);
            }

            // Console.WriteLine("Reading {0}-Block...", Type);

            if (Type == UpdateType.OutOfRange ||
                Type == UpdateType.Near)
            {
                var count = ReadUInt();
                EntityIds = new EntityId[count];
                for (var i = 0; i < count; i++)
                {
                    EntityIds[i] = ReadPackedEntityId();
                }
            }
            else
            {
                EntityId = ReadPackedEntityId();

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf)
                {
                    ObjectType = (ObjectTypeId)ReadByte();
                }

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf ||
                    Type == UpdateType.Movement)
                {
                    m_movement = ReadMovementBlock();
                }

                if (Type != UpdateType.Movement)
                {
                    Values = ReadValues();
                }
            }

            if (Type != UpdateType.Create && Type != UpdateType.CreateSelf)
            {
                ObjectType = EntityId.ObjectType;
            }
        }
Example #5
0
 /// <summary>
 /// Write human-readable version of log to ParsedQuestOutput.txt
 /// </summary>
 /// <param name="packet">Any kind of Update-packet</param>
 public static void HandleUpdatePackets(ParsedUpdatePacket packet)
 {
     // iterate over all Creation-UpdateBlocks in the UpdatePacket
     foreach (var block in packet.GetBlocks(UpdateType.Create))
     {
         // We only want NPC-information
         if (block.ObjectType == ObjectTypeId.Unit)
         {
             // write all NPCs that I encountered and have Level > 80 to a file
             // add a "u" (for unsigned in uint) to the number, since the Level is a uint
             if (block.GetUInt(UnitFields.LEVEL) > 80u)
             {
                 packet.Dump(level80MobsWriter);
                 level80MobsWriter.WriteLine();		// empty line in between entries
             }
         }
     }
 }
Example #6
0
        public void AddRealmSMSG(PacketIn packet)
        {
            if (PacketUtil.GetUpdatePackets &&
                (packet.PacketId == RealmServerOpCode.SMSG_UPDATE_OBJECT ||
                packet.PacketId == RealmServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT))
            {
                var parsedPacket = new ParsedUpdatePacket(packet);

                // check if all bytes were read - if not, the submitted update-count was too small
                //Assert.AreEqual(0, parsedPacket.RemainingLength, "Count in UpdatePacket does not match with actual packet-size");

                UpdatePackets.Add(parsedPacket);
            }
            else
            {
                AddRealmPacket(SMSGPackets, PacketSender.Server, packet, this);
            }
        }
		static void HandleUpdates(ParsedUpdatePacket packet)
		{
			foreach (var block in packet.Blocks)
			{
				if (block.EntityId.High == HighId.Unit && 
					block.Values != null && 
					block.IsSet(UnitFields.FACTIONTEMPLATE))
				{
					var factionTemplate = block.GetUInt(UnitFields.FACTIONTEMPLATE);
					//var factionIndex = 
					//if (!InfosByEntity.Contains(factionIndex))
					//{
					//    InfosByEntity.Add(GetInfo(factionIndex));
					//}
					
				}
			}
		}
Example #8
0
        /*public static void Dump(byte[] packetContent, bool isSingleBlock, IndentTextWriter writer)
        {
            Dump(packetContent, isSingleBlock, writer, false);
        }

        public static void Dump(PacketIn packet, IndentTextWriter writer)
        {
            Dump(GetBytes(packet), false, writer, false);
        }

        public static void Dump(byte[] packetContent, bool isSingleBlock, IndentTextWriter writer, bool isCompressed)
        {
            Dump(DateTime.Now, packetContent, isSingleBlock, writer, isCompressed);
        }*/
        public static void Dump(DateTime timeStamp, byte[] packetContent, bool isSingleBlock, IndentTextWriter writer, bool isCompressed)
        {
            if (isCompressed)
            {
                packetContent = UpdateFieldsUtil.Decompress(packetContent);
            }
            var packet = new ParsedUpdatePacket(packetContent, isSingleBlock);
            writer.WriteLine("");
            packet.Dump("", writer);
        }