Skip to content

Commit

Permalink
fix error if reserve-amo is nil (POV demos)
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Jan 24, 2025
1 parent 7cdb3cd commit f0b5a7e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/demoinfocs/common/equipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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
}

Expand Down

0 comments on commit f0b5a7e

Please sign in to comment.