Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DemoParser/src/Parser/Components/Packets/UserCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class UserCmd : DemoPacket {
public byte? Impulse;
public uint? WeaponSelect, WeaponSubtype;
public short? MouseDx, MouseDy;
// portal 2
public short? PlayerHeldEntityIndex;
public short? PlayerHeldEntityThroughPortalIndex;
public ushort? CommandAcksPending;
public byte? PredictedPortalTeleports;

public UserCmd(SourceDemo? demoRef, PacketFrame frameRef) : base(demoRef, frameRef) {}

Expand All @@ -43,6 +48,13 @@ protected override void Parse(ref BitStreamReader bsr) {
}
MouseDx = (short?)uBsr.ReadUShortIfExists();
MouseDy = (short?)uBsr.ReadUShortIfExists();
if (DemoInfo.Game == SourceGame.PORTAL_2) {
PlayerHeldEntityIndex = uBsr.ReadSShortIfExists();
PlayerHeldEntityThroughPortalIndex = uBsr.ReadSShortIfExists();
CommandAcksPending = uBsr.ReadUShortIfExists();
PredictedPortalTeleports = uBsr.ReadByteIfExists();
}
// missing fields for Dota 2 & Alien swarm - shared/usercmd.cpp
if (uBsr.HasOverflowed)
DemoRef.LogError($"{GetType().Name}: reader overflowed");
TimingAdjustment.AdjustFromUserCmd(this);
Expand All @@ -67,6 +79,12 @@ public override void PrettyWrite(IPrettyWriter pw) {
WeaponSelect?.ToString() ?? "null", WeaponSubtype?.ToString() ?? "null");
pw.AppendFormat("mouseDx, mouseDy: {0,4}, {1,4}",
MouseDx?.ToString() ?? "null", MouseDy?.ToString() ?? "null");
if (DemoInfo.Game == SourceGame.PORTAL_2) {
pw.Append($"\nplayer held entity index: {PlayerHeldEntityIndex?.ToString() ?? "null"}\n");
pw.Append($"held entity through portal index: {PlayerHeldEntityThroughPortalIndex?.ToString() ?? "null"}\n");
pw.Append($"command acknowledgements pending: {CommandAcksPending?.ToString() ?? "null"}\n");
pw.Append($"predicted portal teleports: {PredictedPortalTeleports?.ToString() ?? "null"}");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions DemoParser/src/Utils/BitStreams/BitStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public void ReadVector3(out Vector3 vec3) {
public byte? ReadByteIfExists() => ReadBool() ? ReadByte() : (byte?) null;
public uint? ReadUIntIfExists() => ReadBool() ? ReadUInt() : (uint?)null;
public ushort? ReadUShortIfExists() => ReadBool() ? ReadUShort() : (ushort?)null;
public short? ReadSShortIfExists() => ReadBool() ? ReadSShort() : (short?)null;
public float? ReadFloatIfExists() => ReadBool() ? ReadFloat() : (float?)null;
public uint? ReadUIntIfExists(int numBits) => ReadBool() ? ReadUInt(numBits) : (uint?)null;
public int? ReadSIntIfExists(int numBits) => ReadBool() ? ReadSInt(numBits) : (int?)null;
Expand Down
Loading