Skip to content

Commit

Permalink
fix: weapon may be incorrect in kill events
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Dec 29, 2023
1 parent d0cce14 commit a147be9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/demoinfocs/common/equipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,18 @@ func MapEquipment(eqName string) EquipmentType {
wep = EqKnife
} else {
// If the eqName isn't known it will be EqUnknown as that is the default value for EquipmentType
wep = eqNameToWeapon[eqName]
if strings.HasPrefix(eqName, "m4a1_silencer") {
wep = EqM4A1
} else if strings.HasPrefix(eqName, "vesthelm") {
wep = EqHelmet
} else {
for name := range eqNameToWeapon {
if strings.HasPrefix(eqName, name) {
wep = eqNameToWeapon[name]
break
}
}
}
}

return wep
Expand Down
2 changes: 2 additions & 0 deletions pkg/demoinfocs/common/equipment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func TestMapEquipment(t *testing.T) {
assert.Equal(t, EqKnife, MapEquipment("weapon_knife_butterfly"), "'weapon_knife_butterfly' should be mapped to EqKnife")
assert.Equal(t, EqM4A4, MapEquipment("weapon_m4a1"), "'weapon_m4a1' should be mapped to EqM4A4") // This is correct, weapon_m4a1 == M4A4
assert.Equal(t, EqM4A1, MapEquipment("weapon_m4a1_silencer"), "'weapon_m4a1_silencer' should be mapped to EqM4A1")
assert.Equal(t, EqKevlar, MapEquipment("weapon_vest"), "'weapon_vest' should be mapped to EqKevlar")
assert.Equal(t, EqHelmet, MapEquipment("weapon_vesthelm"), "'weapon_vesthelm' should be mapped to EqHelmet")
assert.Equal(t, EqUnknown, MapEquipment("asdf"), "'asdf' should be mapped to EqUnknown")
}

Expand Down

0 comments on commit a147be9

Please sign in to comment.