Exemple #1
0
        public static byte[] GetPacketDataWithoutType(SourceDemoInfo info, byte[] data, IEnumerable <int> forbiddenFruits)
        {
            PacketReader    reader = new PacketReader(info, data);
            BitWriterDeluxe writer = new BitWriterDeluxe();

            reader.MessageRead += (s, e) =>
            {
                if (!forbiddenFruits.Contains(e.Type))
                {
                    writer.MoveBitsIn(e.DataBitWriter);
                }
            };

            reader.Parse();
            var newData = writer.Data;

            if (PacketFormatValid(info, newData))
            {
                return(newData);
            }
            else
            {
                return(data);
            }
        }
Exemple #2
0
 public PacketReader(SourceDemoInfo demoInfo, byte[] data)
 {
     DemoInfo = demoInfo;
     Data     = data;
     InitHandlers();
     ShouldStop = false;
 }
Exemple #3
0
        public static bool PacketFormatValid(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader        = new PacketReader(info, data);
            bool         readCorrectly = false;

            reader.PacketSuccessfullyRead += (s, e) => { readCorrectly = true; };
            reader.Parse();

            return(readCorrectly);
        }
Exemple #4
0
        public static bool HasMSGType(SourceDemoInfo info, byte[] data, int type)
        {
            PacketReader  reader   = new PacketReader(info, data);
            HashSet <int> messages = new HashSet <int>();

            reader.MessageTypeRead += (s, e) => { messages.Add(e.Message); };
            reader.Parse();

            return(messages.Contains(type));
        }
Exemple #5
0
        public static void PacketBreakDown(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader = new PacketReader(info, data);

            reader.MessageTypeRead += (s, e) =>
            {
                Console.Write("{0} ", e.Message);
            };

            Console.Write("Messages: ");
            reader.Parse();
            Console.WriteLine();
        }
Exemple #6
0
        public static SignOnState GetSignonType(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader = new PacketReader(info, data);
            SignOnState  state  = SignOnState.None;

            reader.MessageRead += (s, e) =>
            {
                if (e.Type == 26)
                {
                    reader.Stop();
                    BitBuffer bb = new BitBuffer(e.WithoutType);
                    state = GetSignonState(bb);
                }
            };

            reader.Parse();
            return(state);
        }
Exemple #7
0
        public static int FindTick(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader = new PacketReader(info, data);
            int          tick   = -1;

            reader.MessageRead += (s, e) =>
            {
                if (e.Type == 3)
                {
                    reader.Stop();
                    BitBuffer bb = new BitBuffer(e.WithoutType);
                    tick = GetTick(bb);
                }
            };

            reader.Parse();
            return(tick);
        }
Exemple #8
0
        public static int FindDeltaFrom(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader    = new PacketReader(info, data);
            int          deltaFrom = -1;

            reader.MessageRead += (s, e) =>
            {
                if (e.Type == 26)
                {
                    reader.Stop();
                    BitBuffer bb = new BitBuffer(e.WithoutType);
                    deltaFrom = DeltaFrom(bb);
                }
            };

            reader.Parse();
            return(deltaFrom);
        }
Exemple #9
0
        public static bool IsRealDelta(SourceDemoInfo info, byte[] data)
        {
            PacketReader reader      = new PacketReader(info, data);
            bool         isRealDelta = false;

            reader.MessageRead += (s, e) =>
            {
                if (e.Type == 26)
                {
                    reader.Stop();
                    BitBuffer bb = new BitBuffer(e.WithoutType);
                    isRealDelta = !IsDeltaBaseline(bb);
                }
            };

            reader.Parse();
            return(isRealDelta);
        }
Exemple #10
0
 public DemoMessage(SourceDemoInfo info, MessageType type)
 {
     Info = info;
     Type = type;
 }