Skip to content

Commit

Permalink
Only read first entity snapshot from GOTV demos, fix position jitteri…
Browse files Browse the repository at this point in the history
…ng (#29)

Fixes #27
  • Loading branch information
saul authored Dec 23, 2023
1 parent 2e131ea commit 863c646
Show file tree
Hide file tree
Showing 19 changed files with 231 additions and 121 deletions.
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.6.1 (2023-12-23)

- Only read the first entity snapshot in GOTV demos (~10% perf improvement)
- Added `DemoFile.IsGotv`, indicating whether the demo was recorded by GOTV
- Fix pawn position jumping to multiples of 1024 for a single tick (https://github.com/saul/demofile-net/issues/27)

### 0.5.1 (2023-12-19)

- Fix decode exception caused by .NET runtime bug (https://github.com/dotnet/runtime/issues/96174)
Expand Down
11 changes: 10 additions & 1 deletion src/DemoFile.SdkGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,16 @@ private static void WriteClass(
builder.AppendLine($" var decoder = {decoderMethod}(field.FieldEncodingInfo);");
builder.AppendLine($" return ({classNameCs} @this, ReadOnlySpan<int> path, ref BitBuffer buffer) =>");
builder.AppendLine($" {{");
builder.AppendLine($" @this.{fieldCsPropertyName} = decoder(ref buffer);");

if (serializer == null)
{
builder.AppendLine($" @this.{fieldCsPropertyName} = decoder(ref buffer);");
}
else
{
builder.AppendLine($" @this.{fieldCsPropertyName} = decoder(@this, ref buffer);");
}

builder.AppendLine($" }};");
}

Expand Down
5 changes: 4 additions & 1 deletion src/DemoFile.Test/Integration/DemoParserIntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace DemoFile.Test.Integration;
using System.Text;
using System.Text.Json;

namespace DemoFile.Test.Integration;

[TestFixture]
public class DemoParserIntegrationTest
Expand Down
4 changes: 1 addition & 3 deletions src/DemoFile.Test/Integration/PlayerPropsIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ void OnSnapshotTimer()
OnSnapshotTimer);
}

demo.CreateTimer(
demo.CurrentDemoTick + playerSnapshotInterval,
OnSnapshotTimer);
demo.CreateTimer(DemoTick.Zero + playerSnapshotInterval, OnSnapshotTimer);

// Act
await demo.Start(GotvCompetitiveProtocol13963, default);
Expand Down
4 changes: 1 addition & 3 deletions src/DemoFile.Test/Integration/StringTableIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ void OnSnapshotTimer()
OnSnapshotTimer);
}

demo.CreateTimer(
demo.CurrentDemoTick + playerSnapshotInterval,
OnSnapshotTimer);
demo.CreateTimer(DemoTick.Zero + playerSnapshotInterval, OnSnapshotTimer);

// Act
await demo.Start(GotvCompetitiveProtocol13963, default);
Expand Down
110 changes: 55 additions & 55 deletions src/DemoFile.Test/Snapshots/Position.txt
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@
"Deaths": 1,
"LastPlaceName": "Catwalk",
"Origin": {
"X": -2048,
"Y": -1024,
"X": -1126.9736,
"Y": -457.4879,
"Z": -167.96875
},
"Rotation": {
Expand Down Expand Up @@ -1253,8 +1253,8 @@
"LastPlaceName": "Connector",
"ActiveWeapon": "CKnife",
"Origin": {
"X": -1024,
"Y": -1024,
"X": -638.097,
"Y": -989.56744,
"Z": -215.96875
},
"Rotation": {
Expand Down Expand Up @@ -1882,8 +1882,8 @@
"LastPlaceName": "CTSpawn",
"ActiveWeapon": "CKnife",
"Origin": {
"X": -2048,
"Y": -1024,
"X": -1323.4896,
"Y": -972.37964,
"Z": -167.96875
},
"Rotation": {
Expand Down Expand Up @@ -2938,8 +2938,8 @@
"Deaths": 3,
"LastPlaceName": "TopofMid",
"Origin": {
"X": 142.0862,
"Y": -562.2657,
"X": 142.30609,
"Y": -561.48395,
"Z": -166.96875
},
"Rotation": {
Expand Down Expand Up @@ -4062,9 +4062,9 @@
"LastPlaceName": "CTSpawn",
"ActiveWeapon": "CAK47",
"Origin": {
"X": -2048,
"Y": -2048,
"Z": -1024
"X": -2018.3505,
"Y": -1823.3798,
"Z": -297.2268
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -4580,7 +4580,7 @@
"Origin": {
"X": -1017.2227,
"Y": -2476.8035,
"Z": -1024
"Z": -167.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -4881,9 +4881,9 @@
"Deaths": 7,
"LastPlaceName": "TopofMid",
"Origin": {
"X": 0,
"Y": -1024,
"Z": -1024
"X": 188.59584,
"Y": -531.34357,
"Z": -163.02185
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -5732,8 +5732,8 @@
"Deaths": 6,
"LastPlaceName": "BombsiteB",
"Origin": {
"X": -1325.0907,
"Y": 284.59473,
"X": -1324.726,
"Y": 284.8755,
"Z": -167.96875
},
"Rotation": {
Expand Down Expand Up @@ -6053,7 +6053,7 @@
"Origin": {
"X": -1314.4999,
"Y": -967.75,
"Z": -1024
"Z": -168.49866
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -7296,9 +7296,9 @@
"Deaths": 8,
"LastPlaceName": "Underpass",
"Origin": {
"X": -1024,
"Y": -1024,
"Z": -1024
"X": -973.2541,
"Y": -158.43628,
"Z": -367.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -8369,7 +8369,7 @@
"Origin": {
"X": 17.928162,
"Y": -2234.481,
"Z": -1024
"Z": -39.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -8901,7 +8901,7 @@
"Class": "CKnife",
"Weapon": "weapon_bayonet",
"PaintKit": {
"Name": "am_doppler_phase3"
"Name": "default"
},
"Quality": "Unusual",
"Rarity": "Common",
Expand Down Expand Up @@ -8969,7 +8969,7 @@
"Class": "CKnife",
"Weapon": "weapon_knife_stiletto",
"PaintKit": {
"Name": "am_marble_fade"
"Name": "default"
},
"Quality": "Unusual",
"Rarity": "Common",
Expand Down Expand Up @@ -9134,7 +9134,7 @@
"Class": "CWeaponHKP2000",
"Weapon": "weapon_usp_silencer",
"PaintKit": {
"Name": "default"
"Name": "cu_usps_noir"
},
"Quality": "Unique",
"Rarity": "Common",
Expand Down Expand Up @@ -9423,8 +9423,8 @@
"Deaths": 8,
"LastPlaceName": "BombsiteA",
"Origin": {
"X": -1024,
"Y": -3072,
"X": -924.03253,
"Y": -2365.103,
"Z": -167.96875
},
"Rotation": {
Expand Down Expand Up @@ -10206,9 +10206,9 @@
"Deaths": 6,
"LastPlaceName": "SnipersNest",
"Origin": {
"X": -2048,
"Y": -1024,
"Z": -1024
"X": -1181.9132,
"Y": -530.4367,
"Z": -167.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -10678,7 +10678,7 @@
"Origin": {
"X": -1790.1093,
"Y": 421.96622,
"Z": -1024
"Z": -166.28693
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -12092,9 +12092,9 @@
"LastPlaceName": "TopofMid",
"ActiveWeapon": "CAK47",
"Origin": {
"X": 0,
"Y": -1024,
"Z": -1024
"X": 499.50363,
"Y": -622.48334,
"Z": -160.11359
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -12312,9 +12312,9 @@
"LastPlaceName": "SideAlley",
"ActiveWeapon": "CAK47",
"Origin": {
"X": 0,
"Y": 0,
"Z": -1024
"X": 241.293,
"Y": 94.06733,
"Z": -222.78912
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -13223,7 +13223,7 @@
"Class": "CKnife",
"Weapon": "weapon_knife_stiletto",
"PaintKit": {
"Name": "default"
"Name": "am_marble_fade"
},
"Quality": "Unusual",
"Rarity": "Common",
Expand Down Expand Up @@ -13368,9 +13368,9 @@
"Deaths": 12,
"LastPlaceName": "BombsiteB",
"Origin": {
"X": -3072,
"Y": -1024,
"Z": -1024
"X": -2265.3774,
"Y": -216.03796,
"Z": -167.19952
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -14302,7 +14302,7 @@
"Origin": {
"X": -1919.2693,
"Y": 748.9163,
"Z": -1024
"Z": -45.391968
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -14354,7 +14354,7 @@
"Class": "CKnife",
"Weapon": "weapon_bayonet",
"PaintKit": {
"Name": "default"
"Name": "am_doppler_phase3"
},
"Quality": "Unusual",
"Rarity": "Common",
Expand Down Expand Up @@ -14444,9 +14444,9 @@
"Deaths": 17,
"LastPlaceName": "BombsiteB",
"Origin": {
"X": -2048,
"Y": -1024,
"Z": -1024
"X": -1550.7078,
"Y": -174.88373,
"Z": -161.92578
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -14987,7 +14987,7 @@
"Class": "CAK47",
"Weapon": "weapon_ak47",
"PaintKit": {
"Name": "cu_ak47_cogthings"
"Name": "default"
},
"Quality": "Unique",
"Rarity": "Common",
Expand Down Expand Up @@ -15134,9 +15134,9 @@
"Deaths": 15,
"LastPlaceName": "BombsiteB",
"Origin": {
"X": -3072,
"Y": 0,
"Z": -1024
"X": -2321.2788,
"Y": 432.05084,
"Z": -167.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -15538,7 +15538,7 @@
"Class": "CAK47",
"Weapon": "weapon_ak47",
"PaintKit": {
"Name": "cu_ak47_cogthings"
"Name": "default"
},
"Quality": "Unique",
"Rarity": "Common",
Expand Down Expand Up @@ -15682,7 +15682,7 @@
"Origin": {
"X": -500.89966,
"Y": -2097.0513,
"Z": -179.96875
"Z": -179.83728
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -15751,7 +15751,7 @@
"Origin": {
"X": 367.96875,
"Y": -2178.7146,
"Z": -1024
"Z": -55.96875
},
"Rotation": {
"Pitch": 0,
Expand Down Expand Up @@ -16442,7 +16442,7 @@
"Class": "CAK47",
"Weapon": "weapon_ak47",
"PaintKit": {
"Name": "cu_ak47_cogthings"
"Name": "default"
},
"Quality": "Unique",
"Rarity": "Common",
Expand Down Expand Up @@ -17323,7 +17323,7 @@
"Class": "CAK47",
"Weapon": "weapon_ak47",
"PaintKit": {
"Name": "cu_ak47_cogthings"
"Name": "default"
},
"Quality": "Unique",
"Rarity": "Common",
Expand Down
Loading

0 comments on commit 863c646

Please sign in to comment.