Skip to content

Commit f0b5a7e

Browse files
committed
fix error if reserve-amo is nil (POV demos)
1 parent 7cdb3cd commit f0b5a7e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/demoinfocs/common/equipment.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (e *Equipment) AmmoReserve() int {
417417
}
418418

419419
s2Prop := e.Entity.Property("m_pReserveAmmo.0000")
420-
if s2Prop != nil {
420+
if s2Prop != nil && s2Prop.Value().Any != nil {
421421
return s2Prop.Value().Int()
422422
}
423423

@@ -430,9 +430,17 @@ func (e *Equipment) AmmoReserve() int {
430430
return 0
431431
}
432432

433+
if e.Class() == EqClassEquipment {
434+
return 0
435+
}
436+
433437
// if the property doesn't exist we return 0 by default
434438
val, _ := e.Entity.PropertyValue("m_iPrimaryReserveAmmoCount")
435439

440+
if val.Any == nil {
441+
return 0
442+
}
443+
436444
return val.IntVal
437445
}
438446

0 commit comments

Comments
 (0)