@@ -620,10 +620,10 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
620
620
621
621
#region Values
622
622
623
- string vals = "modding values" ;
623
+ List < string > logModdingValues = new List < string > ( ) ;
624
624
foreach ( ConfigNode . Value modVal in mod . values )
625
625
{
626
- vals += " \n " + modVal . name + "= " + modVal . value ;
626
+ string logModdingValue = modVal . name + " = " + modVal . value ;
627
627
628
628
Command cmd = CommandParser . Parse ( modVal . name , out string valName ) ;
629
629
@@ -808,7 +808,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
808
808
if ( value != null )
809
809
{
810
810
if ( origVal . value != value )
811
- vals += ": " + origVal . value + " -> " + value ;
811
+ logModdingValue += " ( was " + origVal . value + ")" ;
812
812
813
813
if ( cmd != Command . Copy )
814
814
origVal . value = value ;
@@ -904,8 +904,10 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
904
904
}
905
905
break ;
906
906
}
907
+ logModdingValues . Add ( logModdingValue ) ;
907
908
}
908
- log . Trace ( vals ) ;
909
+ if ( 0 != logModdingValues . Count )
910
+ log . Trace ( "\t modding values: {0}" , string . Join ( " ; " , logModdingValues . ToArray ( ) ) ) ;
909
911
910
912
#endregion Values
911
913
@@ -983,7 +985,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
983
985
string tag = "" ;
984
986
string nodeType , nodeName ;
985
987
int index = 0 ;
986
- List < string > logspam_msg = new List < string > ( ) ;
988
+ List < string > logspam_msg = new List < string > ( ) ; logspam_msg . Add ( "" ) ;
987
989
List < ConfigNode > subNodes = new List < ConfigNode > ( ) ;
988
990
989
991
// three ways to specify:
@@ -1034,7 +1036,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
1034
1036
}
1035
1037
}
1036
1038
else
1037
- logspam_msg . Add ( " cannot wildcard a % node: " + subMod . name ) ;
1039
+ logspam_msg . Add ( "Cannot wildcard a % node: " + subMod . name ) ;
1038
1040
}
1039
1041
else
1040
1042
{
@@ -1049,15 +1051,15 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
1049
1051
// if the original exists modify it
1050
1052
if ( subNodes . Count > 0 )
1051
1053
{
1052
- logspam_msg . Add ( " Applying subnode " + subMod . name ) ;
1054
+ logspam_msg . Add ( "Applying subnode " + subMod . name ) ;
1053
1055
ConfigNode newSubNode = ModifyNode ( log , nodeStack . Push ( subNodes [ 0 ] ) , subMod , context ) ;
1054
1056
subNodes [ 0 ] . ShallowCopyFrom ( newSubNode ) ;
1055
1057
subNodes [ 0 ] . name = newSubNode . name ;
1056
1058
}
1057
1059
else
1058
1060
{
1059
1061
// if not add the mod node without the % in its name
1060
- logspam_msg . Add ( " Adding subnode " + subMod . name ) ;
1062
+ logspam_msg . Add ( "Adding subnode " + subMod . name ) ;
1061
1063
1062
1064
ConfigNode copy = new ConfigNode ( nodeType ) ;
1063
1065
@@ -1072,7 +1074,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
1072
1074
{
1073
1075
if ( subNodes . Count == 0 )
1074
1076
{
1075
- logspam_msg . Add ( " Adding subnode " + subMod . name ) ;
1077
+ logspam_msg . Add ( "Adding subnode " + subMod . name ) ;
1076
1078
1077
1079
ConfigNode copy = new ConfigNode ( nodeType ) ;
1078
1080
@@ -1087,11 +1089,11 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
1087
1089
{
1088
1090
// find each original subnode to modify, modify it and add the modified.
1089
1091
if ( subNodes . Count == 0 ) // no nodes to modify!
1090
- logspam_msg . Add ( " Could not find node(s) to modify: " + subMod . name ) ;
1092
+ logspam_msg . Add ( "Could not find node(s) to modify: " + subMod . name ) ;
1091
1093
1092
1094
foreach ( ConfigNode subNode in subNodes )
1093
1095
{
1094
- logspam_msg . Add ( " Applying subnode " + subMod . name ) ;
1096
+ logspam_msg . Add ( "Applying subnode " + subMod . name ) ;
1095
1097
ConfigNode newSubNode ;
1096
1098
switch ( command )
1097
1099
{
@@ -1118,7 +1120,8 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
1118
1120
}
1119
1121
}
1120
1122
}
1121
- log . Trace ( String . Join ( "\n " , logspam_msg . ToArray ( ) ) ) ; //FIXME: This is wasting a lot of CPU when Trace is deactivated!
1123
+ if ( logspam_msg . Count > 1 ) // Remember we added an empty line on initialization
1124
+ log . Trace ( String . Join ( "\n \t " , logspam_msg . ToArray ( ) ) ) ;
1122
1125
}
1123
1126
}
1124
1127
@@ -1412,6 +1415,7 @@ private static ConfigNode.Value RecurseVariableSearch(IBasicLogger log, string p
1412
1415
1413
1416
private static string ProcessVariableSearch ( IBasicLogger log , string value , NodeStack nodeStack , PatchContext context )
1414
1417
{
1418
+ string r = value ;
1415
1419
// value = #xxxx$yyyyy$zzzzz$aaaa$bbbb
1416
1420
// There is 2 or more '$'
1417
1421
if ( value . Length > 0 && value [ 0 ] == '#' && value . IndexOf ( '$' ) != - 1 && value . IndexOf ( '$' ) != value . LastIndexOf ( '$' ) )
@@ -1433,10 +1437,10 @@ private static string ProcessVariableSearch(IBasicLogger log, string value, Node
1433
1437
builder . Append ( result . value ) ;
1434
1438
builder . Append ( split [ i + 1 ] ) ;
1435
1439
}
1436
- value = builder . ToString ( ) ;
1437
- log . Info ( "variable search output : = \" {0 }\" " , value ) ;
1440
+ r = builder . ToString ( ) ;
1441
+ log . Detail ( "variable search output : {0} = \" {1 }\" " , value , r ) ;
1438
1442
}
1439
- return value ;
1443
+ return r ;
1440
1444
}
1441
1445
1442
1446
#endregion Applying Patches
@@ -1513,10 +1517,10 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
1513
1517
}
1514
1518
if ( last != null )
1515
1519
{
1516
- log . Trace ( "CheckConstraints : {0} {1}" , constraints , ( not ^ any ) ) ;
1520
+ log . Trace ( "\t CheckConstraints : {0} {1}" , constraints , ( not ^ any ) ) ;
1517
1521
return not ^ any ;
1518
1522
}
1519
- log . Trace ( "CheckConstraints : {0} {1}" , constraints , ( not ^ false ) ) ;
1523
+ log . Trace ( "\t CheckConstraints : {0} {1}" , constraints , ( not ^ false ) ) ;
1520
1524
return not ^ false ;
1521
1525
1522
1526
case '#' :
@@ -1525,10 +1529,10 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
1525
1529
if ( node . HasValue ( type ) && WildcardMatchValues ( node , type , name ) )
1526
1530
{
1527
1531
bool ret2 = CheckConstraints ( log , node , remainingConstraints ) ;
1528
- log . Trace ( "CheckConstraints : {0} {1}" , constraints , ret2 ) ;
1532
+ log . Trace ( "\t CheckConstraints : {0} {1}" , constraints , ret2 ) ;
1529
1533
return ret2 ;
1530
1534
}
1531
- log . Trace ( "CheckConstraints : {0} false" , constraints ) ;
1535
+ log . Trace ( "\t CheckConstraints : {0} false" , constraints ) ;
1532
1536
return false ;
1533
1537
1534
1538
case '~' :
@@ -1537,20 +1541,20 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
1537
1541
// or: ~breakingForce[100] will be true if it's present but not 100, too.
1538
1542
if ( name == "" && node . HasValue ( type ) )
1539
1543
{
1540
- log . Trace ( "CheckConstraints : {0} false" , constraints ) ;
1544
+ log . Trace ( "\t CheckConstraints : {0} false" , constraints ) ;
1541
1545
return false ;
1542
1546
}
1543
1547
if ( name != "" && WildcardMatchValues ( node , type , name ) )
1544
1548
{
1545
- log . Trace ( "CheckConstraints : {0} false" , constraints ) ;
1549
+ log . Trace ( "\t CheckConstraints : {0} false" , constraints ) ;
1546
1550
return false ;
1547
1551
}
1548
1552
bool ret = CheckConstraints ( log , node , remainingConstraints ) ;
1549
- log . Trace ( "CheckConstraints : {0} {1}" , constraints , ret ) ;
1553
+ log . Trace ( "\t CheckConstraints : {0} {1}" , constraints , ret ) ;
1550
1554
return ret ;
1551
1555
1552
1556
default :
1553
- log . Trace ( "CheckConstraints : {0} false" , constraints ) ;
1557
+ log . Trace ( "\t CheckConstraints : {0} false" , constraints ) ;
1554
1558
return false ;
1555
1559
}
1556
1560
}
@@ -1560,7 +1564,7 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
1560
1564
{
1561
1565
ret3 = ret3 && CheckConstraints ( log , node , constraint ) ;
1562
1566
}
1563
- log . Trace ( "CheckConstraints : {0} {1}" , constraints , ret3 ) ;
1567
+ log . Trace ( "\t CheckConstraints : {0} {1}" , constraints , ret3 ) ;
1564
1568
return ret3 ;
1565
1569
}
1566
1570
0 commit comments