Skip to content

Commit 6a71590

Browse files
committed
Merge from upstream/Master (v4.2.2)
2 parents 927c217 + a303e0a commit 6a71590

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

Source/ModuleManager/MMPatchLoader.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ public IEnumerable<IProtoUrlConfig> Run()
219219
logger.Error("Patch log does not exist: " + patchLogPath);
220220
}
221221

222-
logger.Info(status);
222+
if (KSP.Localization.Localizer.Instance != null)
223+
KSP.Localization.Localizer.SwitchToLanguage(KSP.Localization.Localizer.CurrentLanguage);
224+
225+
logger.Info(status + "\n" + errors);
223226

224227
this.timings.Patching.Stop();
225228
logger.Info("Ran in " + this.timings.Patching);
@@ -236,7 +239,6 @@ private void LoadPhysicsConfig()
236239
// Since it loaded the default config badly (sub node only) we clear it first
237240
physicsUrlFile.configs.Clear();
238241
// And reload it properly
239-
ConfigNode physicsContent = ConfigNode.Load(PHYSICS_DEFAULT.Path);
240242
physicsContent.name = PHYSICS_NODE_NAME;
241243
physicsUrlFile.AddConfig(physicsContent);
242244
gameDataDir.files.Add(physicsUrlFile);
@@ -549,7 +551,7 @@ private void StatusUpdate(Progress.IPatchProgress progress, string activity = nu
549551
#region Applying Patches
550552

551553
// Name is group 1, index is group 2, vector related filed is group 3, vector separator is group 4, operator is group 5
552-
private static readonly Regex parseValue = new Regex(@"([\w\&\-\.\?\*+/^!\(\) ]+(?:,[^*\d][\w\&\-\.\?\*\(\) ]*)*)(?:,(-?[0-9\*]+))?(?:\[((?:[0-9\*]+)+)(?:,(.))?\])?");
554+
private static readonly Regex parseValue = new Regex(@"([\w\&\-\.\?\*\#+/^!\(\) ]+(?:,[^*\d][\w\&\-\.\?\*\(\) ]*)*)(?:,(-?[0-9\*]+))?(?:\[((?:[0-9\*]+)+)(?:,(.))?\])?");
553555

554556
// ModifyNode applies the ConfigNode mod as a 'patch' to ConfigNode original, then returns the patched ConfigNode.
555557
// it uses FindConfigNodeIn(src, nodeType, nodeName, nodeTag) to recurse.
@@ -1717,19 +1719,26 @@ public static ConfigNode FindConfigNodeIn(
17171719
string nodeName = null,
17181720
int index = 0)
17191721
{
1720-
ConfigNode[] nodes = src.GetNodes(nodeType);
1721-
if (nodes.Length == 0)
1722+
List<ConfigNode> nodes = new List<ConfigNode>();
1723+
int c = src.nodes.Count;
1724+
for(int i = 0; i < c; ++i)
1725+
{
1726+
if (WildcardMatch(src.nodes[i].name, nodeType))
1727+
nodes.Add(src.nodes[i]);
1728+
}
1729+
int nodeCount = nodes.Count;
1730+
if (nodeCount == 0)
17221731
return null;
17231732
if (nodeName == null)
17241733
{
17251734
if (index >= 0)
1726-
return nodes[Math.Min(index, nodes.Length - 1)];
1727-
return nodes[Math.Max(0, nodes.Length + index)];
1735+
return nodes[Math.Min(index, nodeCount - 1)];
1736+
return nodes[Math.Max(0, nodeCount + index)];
17281737
}
17291738
ConfigNode last = null;
17301739
if (index >= 0)
17311740
{
1732-
for (int i = 0; i < nodes.Length; ++i)
1741+
for (int i = 0; i < nodeCount; ++i)
17331742
{
17341743
if (nodes[i].HasValue("name") && WildcardMatch(nodes[i].GetValue("name"), nodeName))
17351744
{
@@ -1740,7 +1749,7 @@ public static ConfigNode FindConfigNodeIn(
17401749
}
17411750
return last;
17421751
}
1743-
for (int i = nodes.Length - 1; i >= 0; --i)
1752+
for (int i = nodeCount - 1; i >= 0; --i)
17441753
{
17451754
if (nodes[i].HasValue("name") && WildcardMatch(nodes[i].GetValue("name"), nodeName))
17461755
{

0 commit comments

Comments
 (0)