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); } }
public PacketReader(SourceDemoInfo demoInfo, byte[] data) { DemoInfo = demoInfo; Data = data; InitHandlers(); ShouldStop = false; }
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); }
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)); }
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(); }
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); }
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); }
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); }
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); }
public DemoMessage(SourceDemoInfo info, MessageType type) { Info = info; Type = type; }