Skip to content

Commit 9a0cc3e

Browse files
committed
bug: fix ammo parsing
1 parent 475eaac commit 9a0cc3e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

internal/parser/shots.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,12 @@ func (s *state) onWeaponFire(e events.WeaponFire) {
161161
// AmmoInMagazine is captured AFTER the shot fires; add 1 to recover
162162
// the pre-shot count. Downstream uses a sequence of these values to
163163
// infer reloads (count increases between consecutive shots).
164+
// Some weapons (knife, grenades that route through here, edge cases
165+
// in CS2 demos) return a uint32 sentinel like 0xFFFFFFFF — cap to a
166+
// sane range so the int4 DB column doesn't overflow.
164167
if e.Weapon != nil {
165168
ammoAfter := e.Weapon.AmmoInMagazine()
166-
if ammoAfter >= 0 {
169+
if ammoAfter >= 0 && ammoAfter < 1000 {
167170
ammoBefore := ammoAfter + 1
168171
ev.AmmoInMagazine = &ammoBefore
169172
}

0 commit comments

Comments
 (0)