Skip to content

Commit a147be9

Browse files
committed
fix: weapon may be incorrect in kill events
1 parent d0cce14 commit a147be9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/demoinfocs/common/equipment.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,18 @@ func MapEquipment(eqName string) EquipmentType {
281281
wep = EqKnife
282282
} else {
283283
// If the eqName isn't known it will be EqUnknown as that is the default value for EquipmentType
284-
wep = eqNameToWeapon[eqName]
284+
if strings.HasPrefix(eqName, "m4a1_silencer") {
285+
wep = EqM4A1
286+
} else if strings.HasPrefix(eqName, "vesthelm") {
287+
wep = EqHelmet
288+
} else {
289+
for name := range eqNameToWeapon {
290+
if strings.HasPrefix(eqName, name) {
291+
wep = eqNameToWeapon[name]
292+
break
293+
}
294+
}
295+
}
285296
}
286297

287298
return wep

pkg/demoinfocs/common/equipment_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func TestMapEquipment(t *testing.T) {
2424
assert.Equal(t, EqKnife, MapEquipment("weapon_knife_butterfly"), "'weapon_knife_butterfly' should be mapped to EqKnife")
2525
assert.Equal(t, EqM4A4, MapEquipment("weapon_m4a1"), "'weapon_m4a1' should be mapped to EqM4A4") // This is correct, weapon_m4a1 == M4A4
2626
assert.Equal(t, EqM4A1, MapEquipment("weapon_m4a1_silencer"), "'weapon_m4a1_silencer' should be mapped to EqM4A1")
27+
assert.Equal(t, EqKevlar, MapEquipment("weapon_vest"), "'weapon_vest' should be mapped to EqKevlar")
28+
assert.Equal(t, EqHelmet, MapEquipment("weapon_vesthelm"), "'weapon_vesthelm' should be mapped to EqHelmet")
2729
assert.Equal(t, EqUnknown, MapEquipment("asdf"), "'asdf' should be mapped to EqUnknown")
2830
}
2931

0 commit comments

Comments
 (0)