@@ -477,22 +477,20 @@ export class Settings extends AbstractEntity {
477
477
break ;
478
478
}
479
479
480
- if ( value != null ) {
481
- // console.log(position, key, value);
482
-
483
- this . configList [ key ] . setValue ( value ) ;
480
+ if ( value === null || value === undefined ) {
481
+ return ;
484
482
}
485
483
486
- this . scvErrorAttempts = 0 ;
487
- } catch ( exc ) {
488
- this . scvErrorAttempts += 1 ;
484
+ // console.log(position, key, value);
485
+ this . configList [ key ] . setValue ( value ) ;
489
486
490
- if ( this . scvErrorAttempts > 10 ) {
491
- wLogger . error (
492
- "ATD(setConfigValue) Can't set config value" ,
493
- position
494
- ) ;
495
- }
487
+ this . resetReportCount ( `ATD(setConfigValue)[${ position } ]` ) ;
488
+ } catch ( exc ) {
489
+ this . reportError (
490
+ `ATD(setConfigValue)[${ position } ]` ,
491
+ 10 ,
492
+ `ATD(setConfigValue)[${ position } ] ${ ( exc as any ) . message } `
493
+ ) ;
496
494
wLogger . debug ( exc ) ;
497
495
}
498
496
}
@@ -506,24 +504,21 @@ export class Settings extends AbstractEntity {
506
504
const value = process . readInt ( current + 0xc ) ;
507
505
508
506
const bindable = this . bindingList [ key ] ;
509
- if ( bindable ) {
510
- // console.log(position, Bindings[key], VirtualKeyCode[value]);
511
-
512
- bindable . setValue ( value ) ;
513
- } else {
507
+ if ( bindable === null || bindable === undefined ) {
514
508
// console.log('binding', key);
509
+ return ;
515
510
}
516
511
517
- this . sbvErrorAttempts = 0 ;
518
- } catch ( exc ) {
519
- this . sbvErrorAttempts += 1 ;
512
+ // console.log(position, Bindings[key], VirtualKeyCode[value]);
513
+ bindable . setValue ( value ) ;
520
514
521
- if ( this . sbvErrorAttempts > 10 ) {
522
- wLogger . error (
523
- "ATD(setBindingValue) Can't set binding value" ,
524
- position
525
- ) ;
526
- }
515
+ this . resetReportCount ( `ATD(setBindingValue)[${ position } ]` ) ;
516
+ } catch ( exc ) {
517
+ this . reportError (
518
+ `ATD(setBindingValue)[${ position } ]` ,
519
+ 10 ,
520
+ `ATD(setBindingValue)[${ position } ] ${ ( exc as any ) . message } `
521
+ ) ;
527
522
wLogger . debug ( exc ) ;
528
523
}
529
524
}
@@ -536,19 +531,36 @@ export class Settings extends AbstractEntity {
536
531
process . readSharpDictionary ( configurationAddr ) ;
537
532
for ( let i = 0 ; i < rawSharpDictionary . length ; i ++ ) {
538
533
const current = rawSharpDictionary [ i ] ;
539
- const keyAddress = process . readInt ( current ) ;
540
534
541
- const key = process . readSharpString ( keyAddress ) ;
535
+ try {
536
+ const keyAddress = process . readInt ( current ) ;
537
+ const key = process . readSharpString ( keyAddress ) ;
542
538
543
- if ( ! ( key in this . configList ) ) {
544
- continue ;
545
- }
539
+ if ( ! ( key in this . configList ) ) {
540
+ continue ;
541
+ }
546
542
547
- // console.log(i, current, key);
548
- this . configPositions . push ( i ) ;
543
+ // console.log(i, current, key);
544
+ this . configPositions . push ( i ) ;
545
+
546
+ this . resetReportCount ( `ATD(configOffset)[${ i } ]` ) ;
547
+ } catch ( exc ) {
548
+ this . reportError (
549
+ `ATD(configOffset)[${ i } ]` ,
550
+ 10 ,
551
+ `ATD(configOffset)[${ i } ] ${ ( exc as any ) . message } `
552
+ ) ;
553
+ wLogger . debug ( exc ) ;
554
+ }
549
555
}
556
+
557
+ this . resetReportCount ( 'ATD(findConfigOffsets)' ) ;
550
558
} catch ( exc ) {
551
- wLogger . error ( "ATD(updateConfigState) Can't find config offset" ) ;
559
+ this . reportError (
560
+ 'ATD(findConfigOffsets)' ,
561
+ 10 ,
562
+ `ATD(findConfigOffsets) ${ ( exc as any ) . message } `
563
+ ) ;
552
564
wLogger . debug ( exc ) ;
553
565
}
554
566
}
@@ -560,19 +572,36 @@ export class Settings extends AbstractEntity {
560
572
process . readSharpDictionary ( bindingConfigAddr ) ;
561
573
for ( let i = 0 ; i < rawSharpDictionary . length ; i ++ ) {
562
574
const current = rawSharpDictionary [ i ] ;
563
- const key = process . readInt ( current ) ;
564
- // const value = process.readInt(current + 0xc);
565
-
566
- if ( ! ( key in this . bindingList ) ) {
567
- continue ;
575
+ try {
576
+ const key = process . readInt ( current ) ;
577
+ // const value = process.readInt(current + 0xc);
578
+
579
+ if ( ! ( key in this . bindingList ) ) {
580
+ continue ;
581
+ }
582
+
583
+ // const bindable = Bindings[key];
584
+ // console.log(i, current, bindable, key, value);
585
+ this . bindingPositions . push ( i ) ;
586
+
587
+ this . resetReportCount ( `ATD(bindingOffset)[${ i } ]` ) ;
588
+ } catch ( exc ) {
589
+ this . reportError (
590
+ `ATD(bindingOffset)[${ i } ]` ,
591
+ 10 ,
592
+ `ATD(bindingOffset)[${ i } ] ${ ( exc as any ) . message } `
593
+ ) ;
594
+ wLogger . debug ( exc ) ;
568
595
}
569
-
570
- // const bindable = Bindings[key];
571
- // console.log(i, current, bindable, key, value);
572
- this . bindingPositions . push ( i ) ;
573
596
}
597
+
598
+ this . resetReportCount ( 'ATD(findBindingOffsets)' ) ;
574
599
} catch ( exc ) {
575
- wLogger . error ( "ATD(updateConfigState) Can't find binding offset" ) ;
600
+ this . reportError (
601
+ 'ATD(findBindingOffsets)' ,
602
+ 10 ,
603
+ `ATD(findBindingOffsets) ${ ( exc as any ) . message } `
604
+ ) ;
576
605
wLogger . debug ( exc ) ;
577
606
}
578
607
}
@@ -588,17 +617,13 @@ export class Settings extends AbstractEntity {
588
617
this . setConfigValue ( process , configurationAddr , position ) ;
589
618
}
590
619
591
- if ( this . configStateErrorAttempts !== 0 ) {
592
- this . configStateErrorAttempts = 0 ;
593
- }
620
+ this . resetReportCount ( 'ATD(updateConfigState)' ) ;
594
621
} catch ( exc ) {
595
- this . configStateErrorAttempts += 1 ;
596
-
597
- if ( this . configStateErrorAttempts > 5 ) {
598
- wLogger . error (
599
- "ATD(updateConfigState) Can't update config state"
600
- ) ;
601
- }
622
+ this . reportError (
623
+ 'ATD(updateConfigState)' ,
624
+ 10 ,
625
+ `ATD(updateConfigState) ${ ( exc as any ) . message } `
626
+ ) ;
602
627
wLogger . debug ( exc ) ;
603
628
}
604
629
}
@@ -614,17 +639,13 @@ export class Settings extends AbstractEntity {
614
639
this . setBindingValue ( process , bindingConfigAddr , position ) ;
615
640
}
616
641
617
- if ( this . bindingStateErrorAttempts !== 0 ) {
618
- this . bindingStateErrorAttempts = 0 ;
619
- }
642
+ this . resetReportCount ( 'ATD(updateBindingState)' ) ;
620
643
} catch ( exc ) {
621
- this . bindingStateErrorAttempts += 1 ;
622
-
623
- if ( this . bindingStateErrorAttempts > 5 ) {
624
- wLogger . error (
625
- "ATD(updateBindingState) Can't update binding state"
626
- ) ;
627
- }
644
+ this . reportError (
645
+ 'ATD(updateBindingState)' ,
646
+ 10 ,
647
+ `ATD(updateBindingState) ${ ( exc as any ) . message } `
648
+ ) ;
628
649
wLogger . debug ( exc ) ;
629
650
}
630
651
}
@@ -647,8 +668,14 @@ export class Settings extends AbstractEntity {
647
668
) ;
648
669
649
670
this . updateBindingState ( process , process . readPointer ( bindingsAddr ) ) ;
671
+
672
+ this . resetReportCount ( 'SETTINGS(updatestate)' ) ;
650
673
} catch ( exc ) {
651
- wLogger . error ( `S(updateState) ${ ( exc as any ) . message } ` ) ;
674
+ this . reportError (
675
+ 'SETTINGS(updatestate)' ,
676
+ 10 ,
677
+ `SETTINGS(updatestate) ${ ( exc as any ) . message } `
678
+ ) ;
652
679
wLogger . debug ( exc ) ;
653
680
}
654
681
}
0 commit comments