Пример #1
0
        /// <summary>
        /// Parses the tick internally
        /// </summary>
        /// <returns><c>true</c>, if tick was parsed, <c>false</c> otherwise.</returns>
        private bool ParseTick()
        {
            DemoCommand command = (DemoCommand)BitStream.ReadByte();

            BitStream.ReadInt(32);          // tick number
            BitStream.ReadByte();           // player slot

            this.CurrentTick++;             // = TickNum;

            switch (command)
            {
            case DemoCommand.Synctick:
                break;

            case DemoCommand.Stop:
                return(false);

            case DemoCommand.ConsoleCommand:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                BitStream.EndChunk();
                break;

            case DemoCommand.DataTables:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                SendTableParser.ParsePacket(BitStream);
                BitStream.EndChunk();

                //Map the weapons in the equipmentMapping-Dictionary.
                MapEquipment();

                //And now we have the entities, we can bind events on them.
                BindEntites();

                break;

            case DemoCommand.StringTables:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                StringTables.ParsePacket(BitStream, this);
                BitStream.EndChunk();
                break;

            case DemoCommand.UserCommand:
                BitStream.ReadInt(32);
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                BitStream.EndChunk();
                break;

            case DemoCommand.Signon:
            case DemoCommand.Packet:
                ParseDemoPacket();
                break;

            default:
                throw new Exception("Can't handle Demo-Command " + command);
            }

            return(true);
        }
Пример #2
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt))
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             return((int)reader.ReadSignedVarInt());
         }
     }
     else
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Пример #3
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt))
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             Trace.WriteLine("signed varints are not implemented. BAAAAAAD.", "PropDecoder:DecodeInt()");
             return((int)reader.ReadVarInt());
         }
     }
     else
     {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned))
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Пример #4
0
 static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if ((prop.Flags & SendPropertyFlags.VarInt) == SendPropertyFlags.VarInt)
     {
         if ((prop.Flags & SendPropertyFlags.Unsigned) == SendPropertyFlags.Unsigned)
         {
             return((int)reader.ReadVarInt());
         }
         else
         {
             // TODO implement
             throw new NotImplementedException("signed varints are not implemented. BAAAAAAD.");
             //return (int)reader.ReadVarInt();
         }
     }
     else
     {
         if ((prop.Flags & SendPropertyFlags.Unsigned) == SendPropertyFlags.Unsigned)
         {
             return((int)reader.ReadInt(prop.NumberOfBits));
         }
         else
         {
             return(reader.ReadSignedInt(prop.NumberOfBits));
         }
     }
 }
Пример #5
0
        public int ReadSignedInt(int bits)
        {
            var a = A.ReadSignedInt(bits);
            var b = B.ReadSignedInt(bits);

            Verify(a, b);
            return(a);
        }
Пример #6
0
        }                                             // length of sigondata in bytes

        public static DemoHeader ParseFrom(IBitStream reader)
        {
            return(new DemoHeader
            {
                Filestamp = reader.ReadCString(8),
                Protocol = reader.ReadSignedInt(32),
                NetworkProtocol = reader.ReadSignedInt(32),
                ServerName = reader.ReadCString(MAX_OSPATH),
                ClientName = reader.ReadCString(MAX_OSPATH),
                MapName = reader.ReadCString(MAX_OSPATH),
                GameDirectory = reader.ReadCString(MAX_OSPATH),
                PlaybackTime = reader.ReadFloat(),
                PlaybackTicks = reader.ReadSignedInt(32),
                PlaybackFrames = reader.ReadSignedInt(32),
                SignonLength = reader.ReadSignedInt(32)
            });
        }
Пример #7
0
 public static DemoHeader ParseFrom(IBitStream reader)
 {
     return(new DemoHeader
     {
         Filestamp = reader.ReadCString(8),
         Protocol = reader.ReadSignedInt(32),
         NetworkProtocol = Math.Abs(reader.ReadSignedInt(32)),
         ServerName = reader.ReadCString(MaxOspath),
         ClientName = reader.ReadCString(MaxOspath),
         MapName = reader.ReadCString(MaxOspath),
         GameDirectory = reader.ReadCString(MaxOspath),
         PlaybackTime = Math.Abs(reader.ReadFloat()),
         PlaybackTicks = Math.Abs(reader.ReadSignedInt(32)),
         EventCount = Math.Abs(reader.ReadSignedInt(32)),
         SignonLength = Math.Abs(reader.ReadSignedInt(32))
     });
 }
Пример #8
0
        public int SignonLength { get; private set; }				// length of sigondata in bytes

        public static DemoHeader ParseFrom(IBitStream reader)
        {
            return new DemoHeader() {
                Filestamp = reader.ReadCString(8),
                Protocol = reader.ReadSignedInt(32),
				NetworkProtocol = reader.ReadSignedInt(32),
                ServerName = reader.ReadCString(MAX_OSPATH),

                ClientName = reader.ReadCString(MAX_OSPATH),
                MapName = reader.ReadCString(MAX_OSPATH),
                GameDirectory = reader.ReadCString(MAX_OSPATH),
				PlaybackTime = reader.ReadFloat(),

				PlaybackTicks = reader.ReadSignedInt(32),
				PlaybackFrames = reader.ReadSignedInt(32),
				SignonLength = reader.ReadSignedInt(32),
            };
        }
Пример #9
0
        public void TestReadSignedInt()
        {
            int bitOffset = 0;
            int totalBits = data.Length * 8;

            while (bitOffset < totalBits)
            {
                int thisTime = Math.Min(rng.Next(32) + 1, totalBits - bitOffset);
                dbgAll.ReadSignedInt(thisTime);
                bitOffset += thisTime;
            }
        }
Пример #10
0
 public static Split Parse(IBitStream reader)
 {
     return(new Split
     {
         Flags = reader.ReadSignedInt(32),
         viewOrigin = Vector.Parse(reader),
         viewAngles = QAngle.Parse(reader),
         localViewAngles = QAngle.Parse(reader),
         viewOrigin2 = Vector.Parse(reader),
         viewAngles2 = QAngle.Parse(reader),
         localViewAngles2 = QAngle.Parse(reader)
     });
 }
Пример #11
0
		public static int DecodeInt(SendTableProperty prop, IBitStream reader)
		{
			if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt)) {
				if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
					return (int)reader.ReadVarInt();
				} else {
					return (int)reader.ReadSignedVarInt();
				}
			} else {
				if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
					return (int)reader.ReadInt(prop.NumberOfBits);
				} else {
					return reader.ReadSignedInt(prop.NumberOfBits);
				}
			}
		}
Пример #12
0
 public static int DecodeInt(SendTableProperty prop, IBitStream reader)
 {
     if (prop.Flags.HasFlagFast(SendPropertyFlags.VarInt)) {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
             return (int)reader.ReadVarInt();
         } else {
             Trace.WriteLine("signed varints are not implemented. BAAAAAAD.", "PropDecoder:DecodeInt()");
             return (int)reader.ReadVarInt();
         }
     } else {
         if (prop.Flags.HasFlagFast(SendPropertyFlags.Unsigned)) {
             return (int)reader.ReadInt(prop.NumberOfBits);
         } else {
             return reader.ReadSignedInt(prop.NumberOfBits);
         }
     }
 }
Пример #13
0
        private bool ParseTick()
        {
            DemoCommand command = (DemoCommand)BitStream.ReadByte();

            BitStream.ReadInt(32);          // tick number
            BitStream.ReadByte();           // player slot

            this.CurrentTick++;             // = TickNum;

            switch (command)
            {
            case DemoCommand.Synctick:
                break;

            case DemoCommand.Stop:
                return(false);

            case DemoCommand.ConsoleCommand:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                BitStream.EndChunk();
                break;

            case DemoCommand.DataTables:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                SendTableParser.ParsePacket(BitStream);
                BitStream.EndChunk();

                for (int i = 0; i < SendTableParser.ServerClasses.Count; i++)
                {
                    var sc = SendTableParser.ServerClasses[i];

                    if (sc.BaseClasses.Count > 6 && sc.BaseClasses [6].Name == "CWeaponCSBase")
                    {
                        //It is a "weapon" (Gun, C4, ... (...is the cz still a "weapon" after the nerf?))
                        if (sc.BaseClasses.Count > 7)
                        {
                            if (sc.BaseClasses [7].Name == "CWeaponCSBaseGun")
                            {
                                //it is a ratatatata-weapon.
                                var s = sc.DTName.Substring(9).ToLower();
                                equipmentMapping.Add(sc, Equipment.MapEquipment(s));
                            }
                            else if (sc.BaseClasses [7].Name == "CBaseCSGrenade")
                            {
                                //"boom"-weapon.
                                equipmentMapping.Add(sc, Equipment.MapEquipment(sc.DTName.Substring(3).ToLower()));
                            }
                        }
                        else if (sc.Name == "CC4")
                        {
                            //Bomb is neither "ratatata" nor "boom", its "booooooom".
                            equipmentMapping.Add(sc, EquipmentElement.Bomb);
                        }
                        else if (sc.Name == "CKnife" || (sc.BaseClasses.Count > 6 && sc.BaseClasses [6].Name == "CKnife"))
                        {
                            //tsching weapon
                            equipmentMapping.Add(sc, EquipmentElement.Knife);
                        }
                        else if (sc.Name == "CWeaponNOVA" || sc.Name == "CWeaponSawedoff" || sc.Name == "CWeaponXM1014")
                        {
                            equipmentMapping.Add(sc, Equipment.MapEquipment(sc.Name.Substring(7).ToLower()));
                        }
                    }
                }

                BindEntites();

                break;

            case DemoCommand.StringTables:
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                StringTables.ParsePacket(BitStream, this);
                BitStream.EndChunk();
                break;

            case DemoCommand.UserCommand:
                BitStream.ReadInt(32);
                BitStream.BeginChunk(BitStream.ReadSignedInt(32) * 8);
                BitStream.EndChunk();
                break;

            case DemoCommand.Signon:
            case DemoCommand.Packet:
                ParseDemoPacket();
                break;

            default:
                throw new Exception("Can't handle Demo-Command " + command);
            }

            return(true);
        }
Пример #14
0
        public static Split Parse(IBitStream reader)
        {
            return new Split
            {
                Flags = reader.ReadSignedInt(32),
                viewOrigin = Vector.Parse(reader),
                viewAngles = QAngle.Parse(reader),
                localViewAngles = QAngle.Parse(reader),

                viewOrigin2 = Vector.Parse(reader),
                viewAngles2 = QAngle.Parse(reader),
                localViewAngles2 = QAngle.Parse(reader),
            };
        }