Skip to content

Commit 02f91df

Browse files
committed
fix: forgot to include z velocity
1 parent 50b1819 commit 02f91df

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pkg/demoinfocs/common/player.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ func (p *Player) Velocity() r3.Vector {
532532
return r3.Vector{
533533
X: diff.X * t,
534534
Y: diff.Y * t,
535+
Z: diff.Z * t,
535536
}
536537
}
537538

pkg/demoinfocs/common/player_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func TestPlayer_Velocity(t *testing.T) {
428428
assert.Equal(t, expected, pl.Velocity())
429429
}
430430

431-
func TestPlayer_VelocityS2(t *testing.T) {
431+
func createPlayerForVelocityTest() *Player {
432432
controllerEntity := entityWithProperties([]fakeProp{
433433
{propName: "m_hPlayerPawn", value: st.PropertyValue{Any: uint64(1), S2: true}},
434434
})
@@ -446,10 +446,23 @@ func TestPlayer_VelocityS2(t *testing.T) {
446446
1: pawnEntity,
447447
},
448448
}
449-
pl.LastPositions = []r3.Vector{{X: 10, Y: 200, Z: 0}, {X: 20, Y: 300, Z: 0}}
450449
pl.demoInfoProvider = demoInfoProvider
451450

452-
expected := r3.Vector{X: 640, Y: 6400, Z: 0}
451+
return pl
452+
}
453+
454+
func TestPlayer_VelocityS2(t *testing.T) {
455+
pl := createPlayerForVelocityTest()
456+
pl.LastPositions = []r3.Vector{{X: 10, Y: 200, Z: 50}, {X: 20, Y: 300, Z: 100}}
457+
458+
expected := r3.Vector{X: 640, Y: 6400, Z: 3200}
459+
assert.Equal(t, expected, pl.Velocity())
460+
}
461+
462+
func TestPlayer_VelocityS2WithoutPositions(t *testing.T) {
463+
pl := createPlayerForVelocityTest()
464+
465+
expected := r3.Vector{X: 0, Y: 0, Z: 0}
453466
assert.Equal(t, expected, pl.Velocity())
454467
}
455468

0 commit comments

Comments
 (0)