@@ -26,11 +26,12 @@ internal class GameWatcher
26
26
public event EventHandler GroupDisbanded ;
27
27
public event EventHandler < GroupUserLeaveEventArgs > GroupUserLeave ;
28
28
public event EventHandler MapLoading ;
29
- public event EventHandler < MatchingStartedEventArgs > MatchingStarted ;
30
- public event EventHandler < MatchFoundEventArgs > MatchFound ; // only fires on initial load into a raid
31
- public event EventHandler < MatchFoundEventArgs > MapLoaded ; // fires on initial and subsequent loads into a raid
32
- public event EventHandler < MatchingCancelledEventArgs > MatchingAborted ;
33
- public event EventHandler < RaidLoadedEventArgs > RaidLoaded ;
29
+ public event EventHandler < RaidInfoEventArgs > MatchingStarted ;
30
+ public event EventHandler < RaidInfoEventArgs > MatchFound ; // only fires on initial load into a raid
31
+ public event EventHandler < RaidInfoEventArgs > MapLoaded ; // fires on initial and subsequent loads into a raid
32
+ public event EventHandler < RaidInfoEventArgs > MatchingAborted ;
33
+ public event EventHandler < RaidInfoEventArgs > RaidCountdown ;
34
+ public event EventHandler < RaidInfoEventArgs > RaidStarted ;
34
35
public event EventHandler < RaidExitedEventArgs > RaidExited ;
35
36
public event EventHandler < TaskModifiedEventArgs > TaskModified ;
36
37
public event EventHandler < TaskEventArgs > TaskStarted ;
@@ -98,21 +99,27 @@ private void ScreenshotWatcher_FolderCreated(object sender, FileSystemEventArgs
98
99
}
99
100
private void ScreenshotWatcher_Created ( object sender , FileSystemEventArgs e )
100
101
{
101
- var match = Regex . Match ( e . Name , @"\d{4}-\d{2}-\d{2}\[\d{2}-\d{2}\]_(?<position>.+) \(\d\)\.png" ) ;
102
- if ( ! match . Success )
103
- {
104
- return ;
105
- }
106
- var position = Regex . Match ( match . Groups [ "position" ] . Value , @"(?<x>-?[\d.]+), (?<y>-?[\d.]+), (?<z>-?[\d.]+)_.*" ) ;
107
- if ( ! position . Success )
102
+ try
108
103
{
109
- return ;
110
- }
111
- if ( lastKnownMap == null )
104
+ var match = Regex . Match ( e . Name , @"\d{4}-\d{2}-\d{2}\[\d{2}-\d{2}\]_(?<position>.+) \(\d\)\.png" ) ;
105
+ if ( ! match . Success )
106
+ {
107
+ return ;
108
+ }
109
+ var position = Regex . Match ( match . Groups [ "position" ] . Value , @"(?<x>-?[\d.]+), (?<y>-?[\d.]+), (?<z>-?[\d.]+)_.*" ) ;
110
+ if ( ! position . Success )
111
+ {
112
+ return ;
113
+ }
114
+ if ( lastKnownMap == null )
115
+ {
116
+ return ;
117
+ }
118
+ PlayerPosition ? . Invoke ( this , new ( lastKnownMap , new Position ( position . Groups [ "x" ] . Value , position . Groups [ "y" ] . Value , position . Groups [ "z" ] . Value ) ) ) ;
119
+ } catch ( Exception ex )
112
120
{
113
- //return ;
121
+ ExceptionThrown ? . Invoke ( this , new ExceptionEventArgs ( ex , $ "parsing screenshot { e . Name } " ) ) ;
114
122
}
115
- PlayerPosition ? . Invoke ( this , new ( lastKnownMap , new Position ( position . Groups [ "x" ] . Value , position . Groups [ "y" ] . Value , position . Groups [ "z" ] . Value ) ) ) ;
116
123
}
117
124
118
125
public void Start ( )
@@ -196,7 +203,7 @@ internal void GameWatcher_NewLogData(object? sender, NewLogDataEventArgs e)
196
203
// The map has been loaded and the game is searching for a match
197
204
raidInfo = new ( )
198
205
{
199
- MapLoadTime = float . Parse ( Regex . Match ( eventLine , @"LocationLoaded:[0-9.]+ real:(?<loadTime>[0-9.]+)" ) . Groups [ "loadTime" ] . Value )
206
+ MapLoadTime = float . Parse ( Regex . Match ( eventLine , @"LocationLoaded:[0-9., ]+ real:(?<loadTime>[0-9., ]+)" ) . Groups [ "loadTime" ] . Value . Replace ( "," , "." ) )
200
207
} ;
201
208
MatchingStarted ? . Invoke ( this , new ( raidInfo ) ) ;
202
209
}
@@ -206,8 +213,8 @@ internal void GameWatcher_NewLogData(object? sender, NewLogDataEventArgs e)
206
213
// Just the queue time is available so far
207
214
// Occurs on initial raid load and when the user cancels matching
208
215
// Does not occur when the user re-connects to a raid in progress
209
- var queueTimeMatch = Regex . Match ( eventLine , @"MatchingCompleted:[0-9.]+ real:(?<queueTime>[0-9.]+)" ) ;
210
- raidInfo . QueueTime = float . Parse ( queueTimeMatch . Groups [ "queueTime" ] . Value ) ;
216
+ var queueTimeMatch = Regex . Match ( eventLine , @"MatchingCompleted:[0-9., ]+ real:(?<queueTime>[0-9., ]+)" ) ;
217
+ raidInfo . QueueTime = float . Parse ( queueTimeMatch . Groups [ "queueTime" ] . Value . Replace ( "," , "." ) ) ;
211
218
}
212
219
if ( eventLine . Contains ( "application|TRACE-NetworkGameCreate profileStatus" ) )
213
220
{
@@ -228,10 +235,7 @@ internal void GameWatcher_NewLogData(object? sender, NewLogDataEventArgs e)
228
235
{
229
236
// The raid start countdown begins. Only happens for PMCs.
230
237
raidInfo . RaidType = RaidType . PMC ;
231
- if ( raidInfo . Online )
232
- {
233
- RaidLoaded ? . Invoke ( this , new ( raidInfo ) ) ;
234
- }
238
+ RaidCountdown ? . Invoke ( this , new ( raidInfo ) ) ;
235
239
}
236
240
if ( eventLine . Contains ( "application|GameStarted" ) )
237
241
{
@@ -244,8 +248,9 @@ internal void GameWatcher_NewLogData(object? sender, NewLogDataEventArgs e)
244
248
if ( raidInfo . Online && raidInfo . RaidType != RaidType . PMC )
245
249
{
246
250
// We already raised the RaidLoaded event for PMC, so only raise here if not PMC
247
- RaidLoaded ? . Invoke ( this , new ( raidInfo ) ) ;
251
+ //RaidStarted ?.Invoke(this, new(raidInfo));
248
252
}
253
+ RaidStarted ? . Invoke ( this , new ( raidInfo ) ) ;
249
254
raidInfo = new ( ) ;
250
255
}
251
256
if ( eventLine . Contains ( "application|Network game matching aborted" ) || eventLine . Contains ( "application|Network game matching cancelled" ) )
@@ -593,42 +598,14 @@ public override string ToString()
593
598
return $ "{ this . PlayerInfo . Nickname } ({ this . PlayerLoadout . Info . Side } , { this . PlayerLoadout . Info . Level } )";
594
599
}
595
600
}
596
- public class MatchingStartedEventArgs : EventArgs
601
+ public class RaidInfoEventArgs : EventArgs
597
602
{
598
- public float MapLoadTime { get ; set ; }
599
- public MatchingStartedEventArgs ( RaidInfo raidInfo )
600
- {
601
- MapLoadTime = raidInfo . MapLoadTime ;
602
- }
603
- }
604
- public class MatchingCancelledEventArgs : MatchingStartedEventArgs
605
- {
606
- public float QueueTime { get ; set ; }
607
- public MatchingCancelledEventArgs ( RaidInfo raidInfo ) : base ( raidInfo )
608
- {
609
- QueueTime = raidInfo . QueueTime ;
610
- }
611
- }
612
- public class MatchFoundEventArgs : MatchingStartedEventArgs
613
- {
614
- public string Map { get ; set ; }
615
- public string RaidId { get ; set ; }
616
- public float QueueTime { get ; set ; }
617
- public MatchFoundEventArgs ( RaidInfo raidInfo ) : base ( raidInfo )
603
+ public RaidInfo RaidInfo { get ; set ; }
604
+ public RaidInfoEventArgs ( RaidInfo raidInfo )
618
605
{
619
- Map = raidInfo . Map ;
620
- RaidId = raidInfo . RaidId ;
621
- QueueTime = raidInfo . QueueTime ;
606
+ RaidInfo = raidInfo ;
622
607
}
623
608
}
624
- public class RaidLoadedEventArgs : MatchFoundEventArgs
625
- {
626
- public RaidType RaidType { get ; set ; }
627
- public RaidLoadedEventArgs ( RaidInfo raidInfo ) : base ( raidInfo )
628
- {
629
- RaidType = raidInfo . RaidType ;
630
- }
631
- }
632
609
public class FleaSoldEventArgs : EventArgs
633
610
{
634
611
public string Buyer { get ; set ; }
0 commit comments