Skip to content

Commit

Permalink
Fix issues with configs getting lost.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed May 7, 2016
1 parent e31c00a commit 714f3f6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Source/Engines/ModuleEngineConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,20 @@ public override void OnLoad(ConfigNode node)
massDelta = part.mass - part.partInfo.partPrefab.mass;
}


if (configs == null)
configs = new List<ConfigNode>();
else

ConfigNode[] cNodes = node.GetNodes("CONFIG");
if (cNodes != null && cNodes.Length > 0)
{
configs.Clear();

foreach (ConfigNode subNode in node.GetNodes ("CONFIG")) {
//Debug.Log("*RFMEC* Load Engine Configs. Part " + part.name + " has config " + subNode.GetValue("name"));
ConfigNode newNode = new ConfigNode("CONFIG");
subNode.CopyTo (newNode);
configs.Add (newNode);
foreach (ConfigNode subNode in cNodes) {
//Debug.Log("*RFMEC* Load Engine Configs. Part " + part.name + " has config " + subNode.GetValue("name"));
ConfigNode newNode = new ConfigNode("CONFIG");
subNode.CopyTo(newNode);
configs.Add(newNode);
}
}


Expand Down Expand Up @@ -1562,7 +1565,7 @@ protected void ConfigSaveLoad()
{
if (!RFSettings.Instance.engineConfigs.ContainsKey(partName))
{
RFSettings.Instance.engineConfigs[partName] = configs;
RFSettings.Instance.engineConfigs[partName] = new List<ConfigNode>(configs);
/*Debug.Log("*RFMEC* Saved " + configs.Count + " configs");
Debug.Log("Current nodes:" + Utilities.PrintConfigs(configs));*/
}
Expand All @@ -1571,15 +1574,15 @@ protected void ConfigSaveLoad()
/*Debug.Log("*RFMEC* ERROR: part " + partName + " already in database! Current count = " + configs.Count + ", db count = " + RFSettings.Instance.engineConfigs[partName].Count);
Debug.Log("DB nodes:" + Utilities.PrintConfigs(RFSettings.Instance.engineConfigs[partName]));
Debug.Log("Current nodes:" + Utilities.PrintConfigs(configs));*/
configs = RFSettings.Instance.engineConfigs[partName]; // just in case.
//configs = RFSettings.Instance.engineConfigs[partName]; // just in case.
}

}
else
{
if (RFSettings.Instance.engineConfigs.ContainsKey(partName))
{
configs = RFSettings.Instance.engineConfigs[partName];
configs = new List<ConfigNode>(RFSettings.Instance.engineConfigs[partName]);
/*Debug.Log("Found " + configs.Count + " configs!");
Debug.Log("Current nodes:" + Utilities.PrintConfigs(configs));*/
}
Expand Down

0 comments on commit 714f3f6

Please sign in to comment.