@@ -890,20 +890,27 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
890890 p .gameState .grenadeProjectiles [entityID ] = proj
891891
892892 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+ }
896899 }
897900
898901 var wep common.EquipmentType
899902 entity .OnCreateFinished (func () { //nolint:wsl
900903 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+ }
907914 }
908915 }
909916
@@ -968,6 +975,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
968975
969976 // @micvbang: not quite sure what the difference between Thrower and Owner is.
970977 entity .Property ("m_hThrower" ).OnUpdate (func (val st.PropertyValue ) {
978+ if val .Any == nil {
979+ return
980+ }
981+
971982 if p .demoInfoProvider .IsSource2 () {
972983 proj .Thrower = p .demoInfoProvider .FindPlayerByPawnHandle (val .Handle ())
973984 } else {
@@ -976,6 +987,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
976987 })
977988
978989 entity .Property ("m_hOwnerEntity" ).OnUpdate (func (val st.PropertyValue ) {
990+ if val .Any == nil {
991+ return
992+ }
993+
979994 if p .demoInfoProvider .IsSource2 () {
980995 proj .Owner = p .gameState .Participants ().FindByPawnHandle (val .Handle ())
981996 } else {
@@ -997,6 +1012,10 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
9971012 // So we need to check for nil and can't send out bounce events if it's missing
9981013 if bounceProp := entity .Property ("m_nBounces" ); bounceProp != nil {
9991014 bounceProp .OnUpdate (func (val st.PropertyValue ) {
1015+ if val .Any == nil {
1016+ return
1017+ }
1018+
10001019 bounceNumber := val .Int ()
10011020 if bounceNumber != 0 {
10021021 p .eventDispatcher .Dispatch (events.GrenadeProjectileBounce {
@@ -1054,6 +1073,7 @@ func (p *parser) bindWeaponS2(entity st.Entity) {
10541073
10551074 if wepType == common .EqUnknown {
10561075 fmt .Println ("unknown equipment with index" , itemIndex )
1076+
10571077 p .msgDispatcher .Dispatch (events.ParserWarn {
10581078 Message : fmt .Sprintf ("unknown equipment with index %d" , itemIndex ),
10591079 Type : events .WarnTypeUnknownEquipmentIndex ,
@@ -1118,10 +1138,15 @@ func (p *parser) bindWeaponS2(entity st.Entity) {
11181138 // WeaponFire events for grenades are dispatched when the grenade's projectile is created.
11191139 if p .isSource2 () && equipment .Class () != common .EqClassGrenade && ! p .disableMimicSource1GameEvents {
11201140 entity .Property ("m_fLastShotTime" ).OnUpdate (func (val st.PropertyValue ) {
1141+ if val .Any == nil {
1142+ return
1143+ }
1144+
11211145 shooter := p .GameState ().Participants ().FindByPawnHandle (entity .PropertyValueMust ("m_hOwnerEntity" ).Handle ())
11221146 if shooter == nil {
11231147 shooter = equipment .Owner
11241148 }
1149+
11251150 if shooter != nil && val .Float () > 0 {
11261151 p .eventDispatcher .Dispatch (events.WeaponFire {
11271152 Shooter : shooter ,
@@ -1191,13 +1216,22 @@ func (p *parser) bindWeapon(entity st.Entity, wepType common.EquipmentType) {
11911216}
11921217
11931218func (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+
11951227 var thrower * common.Player
1228+
11961229 if p .isSource2 () {
11971230 thrower = p .gameState .Participants ().FindByPawnHandle (throwerHandle )
11981231 } else {
11991232 thrower = p .gameState .Participants ().FindByHandle64 (throwerHandle )
12001233 }
1234+
12011235 inf := common .NewInferno (p .demoInfoProvider , entity , thrower )
12021236 p .gameState .infernos [entity .ID ()] = inf
12031237
0 commit comments