@@ -142,6 +142,12 @@ public class DemoParser : IDisposable
142142 /// </summary>
143143 public event EventHandler < FireEventArgs > FireNadeStarted ;
144144
145+ /// <summary>
146+ /// FireNadeStarted, but with correct ThrownBy player.
147+ /// Hint: Raised at the end of inferno_startburn tick instead of exactly when the event is parsed
148+ /// </summary>
149+ public EventHandler < FireEventArgs > FireNadeWithOwnerStarted ;
150+
145151 /// <summary>
146152 /// Occurs when fire nade ended.
147153 /// Hint: When a round ends, this is *not* caĺled.
@@ -415,6 +421,12 @@ public string TFlag
415421 /// </summary>
416422 internal List < Player > GEH_BlindPlayers = new List < Player > ( ) ;
417423
424+ /// <summary>
425+ /// Holds inferno_startburn event args so they can be matched with player
426+ /// </summary>
427+ internal Queue < Tuple < int , FireEventArgs > > GEH_StartBurns = new Queue < Tuple < int , FireEventArgs > > ( ) ;
428+
429+
418430 // These could be Dictionary<int, RecordedPropertyUpdate[]>, but I was too lazy to
419431 // define that class. Also: It doesn't matter anyways, we always have to cast.
420432
@@ -584,6 +596,12 @@ public bool ParseNextTick()
584596 }
585597 }
586598
599+ while ( GEH_StartBurns . Count > 0 ) {
600+ var fireTup = GEH_StartBurns . Dequeue ( ) ;
601+ fireTup . Item2 . ThrownBy = InfernoOwners [ fireTup . Item1 ] ;
602+ RaiseFireWithOwnerStart ( fireTup . Item2 ) ;
603+ }
604+
587605 if ( b ) {
588606 if ( TickDone != null )
589607 TickDone ( this , new TickDoneEventArgs ( ) ) ;
@@ -678,6 +696,8 @@ private void BindEntites()
678696 HandlePlayers ( ) ;
679697
680698 HandleWeapons ( ) ;
699+
700+ HandleInfernos ( ) ;
681701 }
682702
683703 private void HandleTeamScores ( )
@@ -1095,6 +1115,24 @@ private void HandleBombSites()
10951115 } ;
10961116
10971117 }
1118+
1119+ internal Dictionary < int , Player > InfernoOwners = new Dictionary < int , Player > ( ) ;
1120+ private void HandleInfernos ( )
1121+ {
1122+ var inferno = SendTableParser . FindByName ( "CInferno" ) ;
1123+
1124+ inferno . OnNewEntity += ( s , infEntity ) => {
1125+ infEntity . Entity . FindProperty ( "m_hOwnerEntity" ) . IntRecived += ( s2 , handleID ) => {
1126+ int playerEntityID = handleID . Value & INDEX_MASK ;
1127+ if ( playerEntityID < PlayerInformations . Length && PlayerInformations [ playerEntityID - 1 ] != null )
1128+ InfernoOwners [ infEntity . Entity . ID ] = PlayerInformations [ playerEntityID - 1 ] ;
1129+ } ;
1130+ } ;
1131+
1132+ inferno . OnDestroyEntity += ( s , infEntity ) => {
1133+ InfernoOwners . Remove ( infEntity . Entity . ID ) ;
1134+ } ;
1135+ }
10981136 #if SAVE_PROP_VALUES
10991137 [ Obsolete ( "This method is only for debugging-purposes and shuld never be used in production, so you need to live with this warning." ) ]
11001138 public string DumpAllEntities ( )
@@ -1290,6 +1328,15 @@ internal void RaiseFireStart(FireEventArgs args)
12901328 NadeReachedTarget ( this , args ) ;
12911329 }
12921330
1331+ internal void RaiseFireWithOwnerStart ( FireEventArgs args )
1332+ {
1333+ if ( FireNadeWithOwnerStarted != null )
1334+ FireNadeWithOwnerStarted ( this , args ) ;
1335+
1336+ if ( NadeReachedTarget != null )
1337+ NadeReachedTarget ( this , args ) ;
1338+ }
1339+
12931340 internal void RaiseFireEnd ( FireEventArgs args )
12941341 {
12951342 if ( FireNadeEnded != null )
@@ -1412,6 +1459,7 @@ public void Dispose ()
14121459 this . ExplosiveNadeExploded = null ;
14131460 this . FireNadeEnded = null ;
14141461 this . FireNadeStarted = null ;
1462+ this . FireNadeWithOwnerStarted = null ;
14151463 this . FlashNadeExploded = null ;
14161464 this . HeaderParsed = null ;
14171465 this . MatchStarted = null ;
0 commit comments