Skip to content

Commit

Permalink
Add unknown L4D-specific field in SvcVoiceData
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWillian committed Sep 19, 2023
1 parent f67aaef commit 0de593e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion DemoParser/src/Parser/Components/Messages/SvcVoiceData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DemoParser.Parser.Components.Abstract;
using DemoParser.Utils;
using DemoParser.Utils.BitStreams;
using System;

namespace DemoParser.Parser.Components.Messages;

Expand All @@ -9,6 +10,7 @@ public class SvcVoiceData : DemoMessage {
public byte FromClient;
public bool Proximity;
public int BitLen;
public bool[]? Unknown;

public SvcVoiceData(SourceDemo? demoRef, byte value) : base(demoRef, value) {}

Expand All @@ -17,13 +19,24 @@ protected override void Parse(ref BitStreamReader bsr) {
FromClient = bsr.ReadByte();
Proximity = bsr.ReadByte() != 0;
BitLen = bsr.ReadUShort();

if (DemoRef.DemoInfo.IsLeft4Dead()) {
Unknown = new bool[4];
for (int i = 0; i < 4; i++)
Unknown[i] = bsr.ReadBool();
}
BitStreamReader dataBsr = bsr.ForkAndSkip(BitLen);
}

public override void PrettyWrite(IPrettyWriter pw) {
pw.AppendLine($"client: {FromClient}");
pw.AppendLine($"proximity: {Proximity}");
pw.Append($"bit length: {BitLen}");
if (Unknown != null ) {
pw.AppendLine();
pw.Append("unknown bits: ");
foreach (var v in Unknown) {
pw.Append($" {v}");
}
}
}
}

0 comments on commit 0de593e

Please sign in to comment.