From f0b5a7e9d9827d531285c89de60bf9b279ce1ed1 Mon Sep 17 00:00:00 2001 From: Markus Walther Date: Fri, 24 Jan 2025 17:29:34 +0000 Subject: [PATCH] fix error if reserve-amo is nil (POV demos) --- pkg/demoinfocs/common/equipment.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/demoinfocs/common/equipment.go b/pkg/demoinfocs/common/equipment.go index 63f2926b..3acc9735 100644 --- a/pkg/demoinfocs/common/equipment.go +++ b/pkg/demoinfocs/common/equipment.go @@ -417,7 +417,7 @@ func (e *Equipment) AmmoReserve() int { } s2Prop := e.Entity.Property("m_pReserveAmmo.0000") - if s2Prop != nil { + if s2Prop != nil && s2Prop.Value().Any != nil { return s2Prop.Value().Int() } @@ -430,9 +430,17 @@ func (e *Equipment) AmmoReserve() int { return 0 } + if e.Class() == EqClassEquipment { + return 0 + } + // if the property doesn't exist we return 0 by default val, _ := e.Entity.PropertyValue("m_iPrimaryReserveAmmoCount") + if val.Any == nil { + return 0 + } + return val.IntVal }