Skip to content

Commit

Permalink
Format and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed May 23, 2015
1 parent ee11e48 commit ac9d308
Showing 1 changed file with 55 additions and 62 deletions.
117 changes: 55 additions & 62 deletions moduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ internal void Awake()
GameEvents.onGUIRnDComplexSpawn.Add(OnRnDCenterSpawn);
GameEvents.onGUIRnDComplexDespawn.Add(OnRnDCenterDeSpawn);


LoadingScreen screen = FindObjectOfType<LoadingScreen>();
if (screen == null)
{
log("Can't find LoadingScreen type. Aborting ModuleManager execution");
return;
}
List<LoadingSystem> list = LoadingScreen.Instance.loaders;

if (list != null)
{
// So you can insert a LoadingSystem object in this list at any point.
Expand All @@ -100,7 +100,7 @@ internal void Awake()
log(string.Format("Adding ModuleManager to the loading screen {0}", list.Count));
list.Insert(1, loader);
}

tex = new Texture2D(33, 20, TextureFormat.ARGB32, false);
tex.LoadImage(Properties.Resources.cat);
Color[] pix = tex.GetPixels(0, 0, 1, tex.height);
Expand Down Expand Up @@ -644,7 +644,7 @@ Coroutine StartCoroutine(IEnumerator enumerator, bool blocking)
{
if (blocking)
{
while (enumerator.MoveNext()) {}
while (enumerator.MoveNext()) { }
return null;
}
else
Expand Down Expand Up @@ -710,7 +710,7 @@ private IEnumerator ProcessPatch(bool blocking)

// :Final node
yield return StartCoroutine(ApplyPatch(excludePaths, ":FINAL"), blocking);


PurgeUnused(excludePaths);

Expand Down Expand Up @@ -777,7 +777,7 @@ private void LoadPhysicsConfig()
// Since it loaded the default config badly (sub node only) we clear it first
physicsUrlFile.configs.Clear();
// And reload it properly
ConfigNode physicsContent = ConfigNode.Load(defaultPhysicsPath);
ConfigNode physicsContent = ConfigNode.Load(defaultPhysicsPath);
physicsContent.name = "PHYSICSGLOBALS";
physicsUrlFile.AddConfig(physicsContent);
gameDataDir.files.Add(physicsUrlFile);
Expand Down Expand Up @@ -826,7 +826,7 @@ static bool checkValues(ConfigNode node)
if (value.name.Length == -1)
return true;
}

foreach (ConfigNode subNode in node.nodes)
{
if (checkValues(subNode))
Expand Down Expand Up @@ -911,9 +911,9 @@ private void CreateCache()
private void SaveModdedTechTree()
{
UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("TechTree");


if (configs.Length == 0 )

if (configs.Length == 0)
{
log("No TechTree node found. No custom TechTree will be saved");
return;
Expand Down Expand Up @@ -1020,7 +1020,7 @@ private void CheckNeeds(List<String> excludePaths)
}
catch (Exception ex)
{
log("Exception while checking needs : " + mod.url + " with a type of " + mod.type +"\n" + ex);
log("Exception while checking needs : " + mod.url + " with a type of " + mod.type + "\n" + ex);
log("Node is : " + PrettyConfig(mod));
}
}
Expand Down Expand Up @@ -1055,12 +1055,12 @@ private void CheckNeeds(ConfigNode subMod, string url, List<string> path)
catch (ArgumentOutOfRangeException e)
{
log("ArgumentOutOfRangeException in CheckNeeds for value \"" + val.name + "\"\n" + e);
throw e;
throw;
}
catch (Exception e)
{
log("General Exception " + e.GetType().Name + " for value \"" + val.name + " = " + val.value + "\"\n" + e.ToString());
throw e;
throw;
}
}

Expand Down Expand Up @@ -1088,13 +1088,13 @@ private void CheckNeeds(ConfigNode subMod, string url, List<string> path)
catch (ArgumentOutOfRangeException e)
{
log("ArgumentOutOfRangeException in CheckNeeds for node \"" + node.name + "\"\n" + e);
throw e;
throw;
}
catch (Exception e)
{
log("General Exception " + e.GetType().Name + " for node \"" + node.name + "\"\n " + e.ToString());

throw e;
throw;
}
}

Expand Down Expand Up @@ -1570,7 +1570,7 @@ public ConfigNode ModifyNode(ConfigNode original, ConfigNode mod)
constraints = subName.Substring(start + 5, subName.LastIndexOf(']') - start - 5);
subName = subName.Substring(0, start);
}

if (subName.Contains(","))
{
tag = subName.Split(',')[1];
Expand Down Expand Up @@ -1819,7 +1819,7 @@ private ConfigNode RecurseNodeSearch(string path, ConfigNode currentNode)
//log("NewPath : \"" + path + "\"");
return RecurseNodeSearch(path, currentNode);
}

return currentNode;
}

Expand Down Expand Up @@ -2312,7 +2312,7 @@ public static bool WildcardMatchValues(ConfigNode node, string type, string valu
{
if (!compare && WildcardMatch(values[i], value))
return true;

double val2;
if (compare && Double.TryParse(values[i], out val2)
&& ((value[0] == '<' && val2 < val) || (value[0] == '>' && val2 > val)))
Expand Down Expand Up @@ -2403,7 +2403,7 @@ private static ConfigNode DeepCopy(ConfigNode from)
private string PrettyConfig(UrlDir.UrlConfig config)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}[{1}]\n",config.type ?? "NULL", config.name ?? "NULL");
sb.AppendFormat("{0}[{1}]\n", config.type ?? "NULL", config.name ?? "NULL");
try
{
if (config.config != null)
Expand All @@ -2414,74 +2414,67 @@ private string PrettyConfig(UrlDir.UrlConfig config)
{
sb.Append("NULL\n");
}
sb.Append("\n");
sb.Append("\n");
}
catch( Exception e )
catch (Exception e)
{
log("PrettyConfig Exception " +e);
log("PrettyConfig Exception " + e);
}
return sb.ToString();
}

private void PrettyConfig(ConfigNode node, ref StringBuilder sb, string indent)
{
try
sb.AppendFormat("{0}{1}\n{2}{{\n", indent, node.name ?? "NULL", indent);
string newindent = indent + " ";
if (node.values != null)
{
sb.AppendFormat("{0}{1}\n{2}{{\n", indent, node.name ?? "NULL", indent);
string newindent = indent + " ";
if (node.values != null)
foreach (ConfigNode.Value value in node.values)
{
foreach (ConfigNode.Value value in node.values)
if (value != null)
{
if (value != null)
try
{
try
{
sb.AppendFormat("{0}{1} = {2}\n", newindent, value.name ?? "null", value.value ?? "null");
}
catch (Exception e)
{
log("value.name.Length=" + value.name.Length);
log("value.name.IsNullOrEmpty=" + string.IsNullOrEmpty(value.name));
log("n " +value.name ?? "null");
log("v " + value.value ?? "null");
throw e;
}
sb.AppendFormat("{0}{1} = {2}\n", newindent, value.name ?? "null", value.value ?? "null");
}
else
catch (Exception)
{
sb.AppendFormat("{0} Null value\n", newindent);
log("value.name.Length=" + value.name.Length);
log("value.name.IsNullOrEmpty=" + string.IsNullOrEmpty(value.name));
log("n " + value.name);
log("v " + value.value);
throw;
}
}
}
else
{
sb.AppendFormat("{0} Null values\n", newindent);
}
if (node.nodes != null)
{
foreach (ConfigNode subnode in node.nodes)
else
{
if (subnode != null)
{
PrettyConfig(subnode, ref sb, newindent);
}
else
{
sb.AppendFormat("{0} Null Subnode\n", newindent);
}
sb.AppendFormat("{0} Null value\n", newindent);
}
}
else
}
else
{
sb.AppendFormat("{0} Null values\n", newindent);
}
if (node.nodes != null)
{
foreach (ConfigNode subnode in node.nodes)
{
sb.AppendFormat("{0} Null nodes\n", newindent);
if (subnode != null)
{
PrettyConfig(subnode, ref sb, newindent);
}
else
{
sb.AppendFormat("{0} Null Subnode\n", newindent);
}
}
sb.AppendFormat("{0}}}\n", indent);
}
catch (Exception e)
else
{
throw e;
sb.AppendFormat("{0} Null nodes\n", newindent);
}
sb.AppendFormat("{0}}}\n", indent);
}

//FindConfigNodeIn finds and returns a ConfigNode in src of type nodeType.
Expand Down

0 comments on commit ac9d308

Please sign in to comment.