@@ -890,20 +890,27 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
890
890
p .gameState .grenadeProjectiles [entityID ] = proj
891
891
892
892
if p .demoInfoProvider .IsSource2 () {
893
- player := p .demoInfoProvider .FindPlayerByPawnHandle (entity .PropertyValueMust ("m_hOwnerEntity" ).Handle ())
894
- proj .Thrower = player
895
- proj .Owner = player
893
+ ownerEntVal := entity .PropertyValueMust ("m_hOwnerEntity" )
894
+ if ownerEntVal .Any != nil {
895
+ player := p .demoInfoProvider .FindPlayerByPawnHandle (ownerEntVal .Handle ())
896
+ proj .Thrower = player
897
+ proj .Owner = player
898
+ }
896
899
}
897
900
898
901
var wep common.EquipmentType
899
902
entity .OnCreateFinished (func () { //nolint:wsl
900
903
if p .demoInfoProvider .IsSource2 () {
901
- model := entity .PropertyValueMust ("CBodyComponent.m_hModel" ).S2UInt64 ()
902
- weaponType , exists := p .equipmentTypePerModel [model ]
903
- if exists {
904
- wep = weaponType
905
- } else {
906
- fmt .Printf ("unknown grenade model %d" , model )
904
+ modelVal := entity .PropertyValueMust ("CBodyComponent.m_hModel" )
905
+
906
+ if modelVal .Any != nil {
907
+ model := modelVal .S2UInt64 ()
908
+ weaponType , exists := p .equipmentTypePerModel [model ]
909
+ if exists {
910
+ wep = weaponType
911
+ } else {
912
+ fmt .Printf ("unknown grenade model %d\n " , model )
913
+ }
907
914
}
908
915
}
909
916
@@ -968,6 +975,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
968
975
969
976
// @micvbang: not quite sure what the difference between Thrower and Owner is.
970
977
entity .Property ("m_hThrower" ).OnUpdate (func (val st.PropertyValue ) {
978
+ if val .Any == nil {
979
+ return
980
+ }
981
+
971
982
if p .demoInfoProvider .IsSource2 () {
972
983
proj .Thrower = p .demoInfoProvider .FindPlayerByPawnHandle (val .Handle ())
973
984
} else {
@@ -976,6 +987,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
976
987
})
977
988
978
989
entity .Property ("m_hOwnerEntity" ).OnUpdate (func (val st.PropertyValue ) {
990
+ if val .Any == nil {
991
+ return
992
+ }
993
+
979
994
if p .demoInfoProvider .IsSource2 () {
980
995
proj .Owner = p .gameState .Participants ().FindByPawnHandle (val .Handle ())
981
996
} else {
@@ -997,6 +1012,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
997
1012
// So we need to check for nil and can't send out bounce events if it's missing
998
1013
if bounceProp := entity .Property ("m_nBounces" ); bounceProp != nil {
999
1014
bounceProp .OnUpdate (func (val st.PropertyValue ) {
1015
+ if val .Any == nil {
1016
+ return
1017
+ }
1018
+
1000
1019
bounceNumber := val .Int ()
1001
1020
if bounceNumber != 0 {
1002
1021
p .eventDispatcher .Dispatch (events.GrenadeProjectileBounce {
@@ -1054,6 +1073,7 @@ func (p *parser) bindWeaponS2(entity st.Entity) {
1054
1073
1055
1074
if wepType == common .EqUnknown {
1056
1075
fmt .Println ("unknown equipment with index" , itemIndex )
1076
+
1057
1077
p .msgDispatcher .Dispatch (events.ParserWarn {
1058
1078
Message : fmt .Sprintf ("unknown equipment with index %d" , itemIndex ),
1059
1079
Type : events .WarnTypeUnknownEquipmentIndex ,
@@ -1118,10 +1138,15 @@ func (p *parser) bindWeaponS2(entity st.Entity) {
1118
1138
// WeaponFire events for grenades are dispatched when the grenade's projectile is created.
1119
1139
if p .isSource2 () && equipment .Class () != common .EqClassGrenade && ! p .disableMimicSource1GameEvents {
1120
1140
entity .Property ("m_fLastShotTime" ).OnUpdate (func (val st.PropertyValue ) {
1141
+ if val .Any == nil {
1142
+ return
1143
+ }
1144
+
1121
1145
shooter := p .GameState ().Participants ().FindByPawnHandle (entity .PropertyValueMust ("m_hOwnerEntity" ).Handle ())
1122
1146
if shooter == nil {
1123
1147
shooter = equipment .Owner
1124
1148
}
1149
+
1125
1150
if shooter != nil && val .Float () > 0 {
1126
1151
p .eventDispatcher .Dispatch (events.WeaponFire {
1127
1152
Shooter : shooter ,
@@ -1191,13 +1216,22 @@ func (p *parser) bindWeapon(entity st.Entity, wepType common.EquipmentType) {
1191
1216
}
1192
1217
1193
1218
func (p * parser ) bindNewInferno (entity st.Entity ) {
1194
- throwerHandle := entity .PropertyValueMust ("m_hOwnerEntity" ).Handle ()
1219
+ ownerEntVal := entity .PropertyValueMust ("m_hOwnerEntity" )
1220
+
1221
+ if ownerEntVal .Any == nil {
1222
+ return
1223
+ }
1224
+
1225
+ throwerHandle := ownerEntVal .Handle ()
1226
+
1195
1227
var thrower * common.Player
1228
+
1196
1229
if p .isSource2 () {
1197
1230
thrower = p .gameState .Participants ().FindByPawnHandle (throwerHandle )
1198
1231
} else {
1199
1232
thrower = p .gameState .Participants ().FindByHandle64 (throwerHandle )
1200
1233
}
1234
+
1201
1235
inf := common .NewInferno (p .demoInfoProvider , entity , thrower )
1202
1236
p .gameState .infernos [entity .ID ()] = inf
1203
1237
0 commit comments