18
18
namespace FlashpointSecurePlayer {
19
19
public partial class FlashpointSecurePlayer : Form {
20
20
private const string APPLICATION_MUTEX_NAME = "Flashpoint Secure Player" ;
21
+ private const string EMPTY_MODE_NAME = "" ;
21
22
private const string FLASHPOINT_LAUNCHER_PARENT_PROCESS_EXE_FILE_NAME = "cmd.exe" ;
22
23
private const string FLASHPOINT_LAUNCHER_PROCESS_NAME = "flashpoint" ;
23
24
private Mutex ApplicationMutex = null ;
@@ -32,8 +33,8 @@ public partial class FlashpointSecurePlayer : Form {
32
33
private bool RunAsAdministratorModification = false ;
33
34
private List < string > DownloadsBeforeModificationNames = null ;
34
35
private bool ActiveX = false ;
35
- private string Server = null ;
36
- private string Software = null ;
36
+ private string Server = EMPTY_MODE_NAME ;
37
+ private string Software = EMPTY_MODE_NAME ;
37
38
private ProcessStartInfo SoftwareProcessStartInfo = null ;
38
39
private delegate void ErrorDelegate ( string text ) ;
39
40
@@ -315,7 +316,7 @@ private async Task StartSecurePlayback() {
315
316
ShowError ( Properties . Resources . GameNotActiveXControl ) ;
316
317
return ;
317
318
}
318
-
319
+
319
320
GetBinaryType ( ModificationsName , out BINARY_TYPE binaryType ) ;
320
321
321
322
// first, we install the control without a registry backup running
@@ -405,33 +406,7 @@ private async Task StartSecurePlayback() {
405
406
securePlaybackProgressBar . Value = 100 ;
406
407
ShowOutput ( Properties . Resources . RegistryBackupWasSuccessful ) ;
407
408
return ;
408
- } else if ( ! String . IsNullOrEmpty ( Server ) ) {
409
- // switch to server form
410
- ResetProgressBar ( ) ;
411
- ShowOutput ( Properties . Resources . RequiredComponentsAreLoading ) ;
412
-
413
- try {
414
- await ActivateModificationsAsync ( null , delegate ( string text ) {
415
- if ( text . IndexOf ( "\n " ) == - 1 ) {
416
- ShowError ( text ) ;
417
- } else {
418
- ShowError ( ) ;
419
- MessageBox . Show ( text , Properties . Resources . FlashpointSecurePlayer , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
420
- }
421
-
422
- throw new InvalidModificationException ( ) ;
423
- } ) . ConfigureAwait ( true ) ;
424
- } catch ( InvalidModificationException ) {
425
- return ;
426
- }
427
-
428
- Server serverForm = new Server ( new Uri ( Server ) ) ;
429
-
430
- securePlaybackProgressBar . Value = 100 ;
431
- Hide ( ) ;
432
- serverForm . Show ( ) ;
433
- return ;
434
- } else if ( ! String . IsNullOrEmpty ( Software ) ) {
409
+ } else {
435
410
// switch to synced process
436
411
ResetProgressBar ( ) ;
437
412
ShowOutput ( Properties . Resources . RequiredComponentsAreLoading ) ;
@@ -451,50 +426,60 @@ await ActivateModificationsAsync(Software, delegate (string text) {
451
426
return ;
452
427
}
453
428
454
- securePlaybackProgressBar . Value = 50 ;
429
+ if ( ! String . IsNullOrEmpty ( Server ) ) {
430
+ securePlaybackProgressBar . Value = 50 ;
431
+ Server serverForm = new Server ( new Uri ( Server ) ) ;
455
432
456
- try {
457
- // default to zero in case of error
458
- int argc = 0 ;
459
- string [ ] argv = CommandLineToArgv ( Software , out argc ) ;
433
+ securePlaybackProgressBar . Value = 100 ;
434
+ Hide ( ) ;
435
+ serverForm . Show ( ) ;
436
+ return ;
437
+ } else if ( ! String . IsNullOrEmpty ( Software ) ) {
438
+ securePlaybackProgressBar . Value = 50 ;
460
439
461
- if ( SoftwareProcessStartInfo == null ) {
462
- SoftwareProcessStartInfo = new ProcessStartInfo ( ) ;
463
- }
440
+ try {
441
+ // default to zero in case of error
442
+ int argc = 0 ;
443
+ string [ ] argv = CommandLineToArgv ( Software , out argc ) ;
464
444
465
- SoftwareProcessStartInfo . FileName = Path . GetFullPath ( argv [ 0 ] ) ;
466
- SoftwareProcessStartInfo . Arguments = GetCommandLineArgumentRange ( Software , 1 , - 1 ) ;
467
- SoftwareProcessStartInfo . ErrorDialog = false ;
468
- SoftwareProcessStartInfo . WorkingDirectory = Path . GetDirectoryName ( Path . GetFullPath ( argv [ 0 ] ) ) ;
445
+ if ( SoftwareProcessStartInfo == null ) {
446
+ SoftwareProcessStartInfo = new ProcessStartInfo ( ) ;
447
+ }
469
448
470
- Process process = Process . Start ( SoftwareProcessStartInfo ) ;
449
+ SoftwareProcessStartInfo . FileName = Path . GetFullPath ( argv [ 0 ] ) ;
450
+ SoftwareProcessStartInfo . Arguments = GetCommandLineArgumentRange ( Software , 1 , - 1 ) ;
451
+ SoftwareProcessStartInfo . ErrorDialog = false ;
452
+ SoftwareProcessStartInfo . WorkingDirectory = Path . GetDirectoryName ( Path . GetFullPath ( argv [ 0 ] ) ) ;
471
453
472
- try {
473
- ProcessSync . Start ( process ) ;
474
- } catch ( JobObjectException ) {
475
- // popup message box and blow up
476
- ShowError ( ) ;
477
- MessageBox . Show ( Properties . Resources . JobObjectNotCreated , Properties . Resources . FlashpointSecurePlayer , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
478
- process . Kill ( ) ;
479
- Environment . Exit ( - 1 ) ;
480
- return ;
481
- }
454
+ Process process = Process . Start ( SoftwareProcessStartInfo ) ;
482
455
483
- securePlaybackProgressBar . Value = 100 ;
484
- Hide ( ) ;
456
+ try {
457
+ ProcessSync . Start ( process ) ;
458
+ } catch ( JobObjectException ) {
459
+ // popup message box and blow up
460
+ ShowError ( ) ;
461
+ MessageBox . Show ( Properties . Resources . JobObjectNotCreated , Properties . Resources . FlashpointSecurePlayer , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
462
+ process . Kill ( ) ;
463
+ Environment . Exit ( - 1 ) ;
464
+ return ;
465
+ }
485
466
486
- if ( ! process . HasExited ) {
487
- process . WaitForExit ( ) ;
488
- }
467
+ securePlaybackProgressBar . Value = 100 ;
468
+ Hide ( ) ;
489
469
490
- Application . Exit ( ) ;
491
- } catch {
492
- Show ( ) ;
493
- ShowError ( ) ;
494
- MessageBox . Show ( Properties . Resources . ProcessFailedStart , Properties . Resources . FlashpointSecurePlayer , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
495
- Application . Exit ( ) ;
470
+ if ( ! process . HasExited ) {
471
+ process . WaitForExit ( ) ;
472
+ }
473
+
474
+ Application . Exit ( ) ;
475
+ } catch {
476
+ Show ( ) ;
477
+ ShowError ( ) ;
478
+ MessageBox . Show ( Properties . Resources . ProcessFailedStart , Properties . Resources . FlashpointSecurePlayer , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
479
+ Application . Exit ( ) ;
480
+ }
481
+ return ;
496
482
}
497
- return ;
498
483
}
499
484
throw new InvalidCurationException ( ) ;
500
485
}
0 commit comments